CSSE 132 Mini-reading · Computer Networks
Computer Networks: Names, Addresses, and Ports
Follow a message from an application to another computer. Allow about 7–9 minutes.
Why This Matters
Network communication is another form of I/O: your program exchanges data with a program on another computer. Before writing socket programs, you need to distinguish the destination computer, the destination service, and the rules used to deliver data. Worksheet 20 practices those distinctions.
Core Idea
A network solves several problems in layers. Physical signals carry bits; local network devices move information between nearby machines; IP addresses support delivery across networks; transport protocols support communication between applications. Each layer has a different job, so a name, an IP address, and a port number are not interchangeable.
| Question | Concept |
|---|---|
| What readable name do I know? | A hostname, such as example.com |
| What network destination should receive the traffic? | An IP address |
| Which service on that destination? | A transport port number |
| What delivery behavior does the application need? | A transport protocol, such as TCP or UDP |
Think of an IP address as locating a network interface and a port as identifying a service endpoint there. This is more precise than assuming every computer has exactly one permanent address. A computer can have multiple interfaces and addresses.
From a wire to many networks
The legacy slides begin with two computers: electrical signals over wire, radio signals through space, or light through fiber must represent bits. With more computers, a local area network (LAN) also needs rules for sharing communication and identifying local destinations.
A hub repeats incoming signals to other ports. A switch uses MAC addresses to decide where to forward local Ethernet frames. A router forwards IP packets between networks. The Internet connects many networks through routers; it is not one enormous LAN. You do not need the modulation equations or channel-access algorithms to answer Worksheet 20's questions.
Worked Examples
1. Read an IPv4 address one byte at a time
IPv4 addresses contain 32 bits. Their usual written form splits those bits into four 8-bit groups and writes each group in decimal, separated by dots. Each group therefore ranges from 0 to 255.
0x89 0x70 0x2E 0x83
137 112 46 131
0x89 = 8 × 16 + 9 = 137
0x70 = 7 × 16 + 0 = 112
0x2E = 2 × 16 + 14 = 46
0x83 = 8 × 16 + 3 = 131
IPv4 address: 137.112.46.131
This is the legacy slide's address example, not a promise about a currently running service. Read these groups as the written address order; this is not a dump of an integer's bytes from little-endian memory. Four groups of eight bits give 32 bits and 232 possible bit patterns. IPv6 uses 128 bits, providing a much larger address space. NAT (Network Address Translation), also named in the slides, lets private-network addresses be translated for communication outside that network.
2. Separate DNS, IP, and port
Suppose a browser opens https://example.com/notes. Identify the parts before thinking about delivery:
example.comis the hostname. DNS, the Domain Name System, can resolve this name to IP addresses.- The browser uses a returned address as a network destination. DNS may return multiple addresses; the answer need not stay the same forever.
- The service also has a port. For a typical HTTPS service, that is port 443. The path
/notesidentifies a resource for the web service; it is not part of the hostname sent for DNS resolution.
Two services can share an IP address while using different ports. For example, a teaching server could listen on port 8000 for one application and port 9000 for another. Knowing only its IP address would not say which service you intend to contact. Port numbers are interpreted in the context of the transport protocol; a TCP port and a UDP port with the same number are distinct endpoints.
3. Choose TCP or UDP based on delivery needs
TCP (Transmission Control Protocol) establishes a connection and provides a reliable, ordered byte stream. It uses acknowledgments and retransmission to recover from loss. If recovery fails, communication can fail; reliability does not mean the network can never break. For a file transfer, receiving all bytes in order matters.
UDP (User Datagram Protocol) sends individual messages called datagrams without first establishing a TCP-style connection. UDP does not guarantee delivery, order, or protection against duplicate delivery. An application can tolerate loss or implement recovery itself. For a live update, a newer value may be more useful than waiting for an older missing value.
UDP avoids TCP's built-in connection and recovery work, but “UDP is always faster” is not a guarantee. Also, lack of retransmission is different from lack of error detection: UDP has a checksum mechanism. Choose based on the application's needs rather than memorizing “correct versus incorrect.”
4. Interpret ping output
For Worksheet 20, run ping with a hostname, without https:// or a page path:
ping example.com
# Use Ctrl-C to stop repeated requests.
A typical first line shows the hostname and a resolved IP address in parentheses. Record the address your own run displays; addresses and output formats can vary. This illustrates name resolution before sending probe packets.
Ping uses ICMP probes, rather than contacting a TCP or UDP application port. Replies show that the probes received responses, not that every service works. A host or network may block probes, so missing replies alone do not prove that the website is down. Name-resolution failure is also different from successful resolution followed by unanswered probes.
Common Mistakes
Giving DNS a whole URL
DNS resolves the hostname. The scheme and resource path have other jobs.
Using an IP address as a service identifier
The destination service also needs a port and transport protocol.
Assuming UDP delivers everything
UDP itself does not recover missing messages or restore their order.
Treating ping as a web-service test
A probe reply and a successful web request test different behavior.
Quick Reference
| Term | Remember |
|---|---|
| IPv4 / IPv6 | 32-bit / 128-bit addresses |
| DNS | Domain Name System; resolves hostnames to addresses |
| Port | Identifies a service endpoint within a transport protocol |
| TCP | Connection; reliable, ordered byte stream |
| UDP | Datagrams; no built-in delivery or ordering guarantee |
| Switch / router | Local forwarding using MAC addresses / forwarding between IP networks |
Check Yourself
- Convert the written IPv4 groups
0xC0 0x00 0x02 0x05to dotted decimal. - In
https://example.com/notes, which part does DNS resolve? - Two services use the same IP address and TCP. What identifier can distinguish their listening endpoints?
- An application must receive all bytes in order. Which transport provides that behavior? What happens if UDP loses a datagram?
- Ping prints an IP address but receives no replies. Has name resolution necessarily failed? Does this prove the web service is down?
Answers
Show the answers
192.0.2.5: 0xC0 = 12 × 16 = 192; the other groups are 0, 2, and 5.example.com, the hostname; neither the scheme nor /notes.- Different TCP port numbers distinguish the services at that IP address.
- TCP provides a reliable, ordered byte stream. UDP itself does not retransmit a lost datagram; recovery would require application behavior.
- No. The printed resolved address indicates resolution succeeded. ICMP probes may be blocked even when the web service works.
Next Step
Try Worksheet 20: Computer Network. For each question, decide whether it concerns a name, address, service endpoint, or delivery rule. These distinctions carry directly into socket programming.