Data networks and protocols
With the original 64 KB window and a 100 ms round trip, a TCP connection cannot exceed 5.2 Mbit/s even if the link is one gigabit. The limit is not in the cable.
01Layers and encapsulation
A data network solves many problems at once: transmitting bits over a medium, sharing the medium among stations, finding the path between networks, delivering the data complete and in order, and giving it meaning. So that each problem can be solved separately, protocols are organized in layers: each one uses the service of the one below and offers one to the one above. The OSI model has seven; the TCP/IP stack, which is the one actually used, has four:
| TCP/IP layer | Function | Examples | Unit |
|---|---|---|---|
| Application | The meaning of the data | HTTP, DNS, MQTT, SSH | Message |
| Transport | Process-to-process communication, reliability | TCP, UDP | Segment |
| Internet | Addressing and routing between networks | IPv4, IPv6, ICMP | Packet |
| Network access | Transmission on a link | Ethernet, Wi-Fi | Frame |
Each layer adds its header to the data from the layer above: this is encapsulation. A TCP segment with 1460 bytes of data travels with 20 bytes of TCP, 20 of IP and, on Ethernet, 14 of header, 4 of check sequence, 8 of preamble and 12 of inter-frame gap: 1538 bytes on the wire, 95% efficiency. Short-range buses were covered in serial protocols.
02Link and network: Ethernet and IP
Ethernet identifies each interface with a 48-bit physical address. Switches learn which port each address is on and forward each frame only toward its destination; with full-duplex links there are no collisions anymore. Wi-Fi, by contrast, shares the medium and uses carrier-sense access with collision avoidance.
IP gives each interface a logical address, 32 bits in IPv4 and 128 in IPv6, organized in networks with a prefix: in 192.168.1.0/24, the first 24 bits identify the network and 254 addresses remain for hosts. Routers forward each packet according to their table, toward the next hop, without guaranteeing that it arrives or in what order. Within a local network, the ARP protocol translates the IP address into the physical one.
03Transport: UDP and TCP
UDP delivers datagrams with no guarantees and no connection: it is what suits voice, live video or periodic measurements, where a late datum is useless. TCP builds a reliable, ordered stream: it numbers the bytes, the receiver acknowledges what it received and the sender retransmits what is lost. To avoid waiting for an acknowledgment for each segment, it keeps a window of unacknowledged data in flight, and that limits its speed:
To fill a link, the window has to reach the bandwidth-delay product: the data that fit "in the wire". The original TCP window was 64 KB; with a 100 ms RTT that limits the rate to 5.2 Mbit/s even if the link is 1 Gbit/s. The window scaling option extends it up to 1 GB.
The three bounds on the throughput of a connection: the link, the window and the losses. The throughput is the smallest; the highlighted bar is the one in control. Segments of 1460 bytes.
04Applications and the Internet of Things
Application protocols run on top of TCP and UDP. HTTP transfers pages and web service data; DNS translates names into addresses; TLS encrypts and authenticates the connection beneath HTTPS. In the Internet of Things, where devices have little memory and energy, lightweight protocols are used: MQTT, publish-subscribe over TCP, and CoAP, over UDP. A sensor that sends one measurement per minute hardly uses any bandwidth: what matters is how long the radio has to stay on to do it.
05In the laboratory
Use Wireshark to capture the loading of a page and identify in one frame the Ethernet, IP, TCP and HTTP headers.
Measure the throughput between two hosts with iperf, and add delay and losses with the operating system’s network emulator. Compare with the bounds from the lab.
Publish sensor measurements from a Wi-Fi microcontroller to an MQTT server and subscribe from a computer.
06Common mistakes
- Expecting a faster link to speed up a distant transfer. With a small window or losses, the link is not the limit.
- Confusing the physical address with the IP. The first identifies the interface on the link; the second, in the network.
- Using TCP for real-time audio. Retransmissions arrive late; UDP with its own loss tolerance is better.
- Forgetting the header on small packets. With few bytes of data, the efficiency drops a lot.
07Self-assessment
How many host addresses does a /26 network have?
\( 2^6 - 2 = 62 \).
What window is needed to fill 1 Gbit/s with a 50 ms RTT?
\( 10^9 \cdot 0.05/8 \approx 6.25 \) MB.
With a 64 KB window and a 20 ms RTT, what is the throughput bound?
\( 65\,535 \cdot 8/0.02 \approx 26 \) Mbit/s.
Why is MQTT suitable for sensors?
Because it has minimal headers and a publish-subscribe model that decouples sensors from consumers.
08Further reading
- Andrew S. Tanenbaum, Nick Feamster and David Wetherall. Computer Networks. 6th ed., Pearson, 2021. The classic reference, layer by layer.
- James F. Kurose and Keith W. Ross. Computer Networking: A Top-Down Approach. 7th ed., Pearson, 2016. Spanish edition: “Redes de computadoras: un enfoque descendente”, Pearson, 2017. From the applications downward, with TCP and its congestion control in detail.
- Matthew Mathis, Jeffrey Semke, Jamshid Mahdavi and Teunis Ott. The Macroscopic Behavior of the TCP Congestion Avoidance Algorithm. ACM SIGCOMM Computer Communication Review, 27(3), 1997. The paper on the throughput bound with losses.