5.4 Computer Networks

Key Takeaways

  • The OSI model has 7 layers; the TCP/IP model collapses them into 4 (Link, Internet, Transport, Application).
  • TCP is connection-oriented and reliable using a three-way handshake and acknowledgments; UDP is connectionless and low-latency.
  • An IPv4 address is 32 bits; usable hosts per subnet = 2^(host bits) - 2, so a /24 gives 254 and a /27 gives 30.
  • Encapsulation wraps each layer's PDU in the header below: segment -> packet -> frame -> bits.
  • Routers forward packets at the network/IP layer (3); switches forward frames at the data-link/MAC layer (2).
Last updated: June 2026

Layered network models

Networks are designed in layers so each handles one concern and talks only to the layers directly above and below it. The FE references both the seven-layer OSI (Open Systems Interconnection) model and the practical four-layer TCP/IP model.

The value of layering is modularity: you can swap Wi-Fi for Ethernet at the link layer without touching the application, because each layer exposes a fixed interface. The single most common network question on the exam is identifying which layer a given protocol or device belongs to, so anchor that mapping first.

Data flows down the seven layers on the sending host, across the physical medium, and back up the seven layers on the receiving host. Each layer on the receiver communicates logically with its peer layer on the sender, even though the actual bits travel only over the layer-1 link. This peer-to-peer abstraction is why a layer can be redesigned independently as long as its interface to the layers above and below is unchanged.

OSI layers and their TCP/IP mapping

OSI Layer#FunctionExampleTCP/IP Layer
Application7User servicesHTTP, DNSApplication
Presentation6Encryption, formattingTLS, JPEGApplication
Session5Dialog controlRPCApplication
Transport4End-to-end deliveryTCP, UDPTransport
Network3Routing, IP addressingIP, ICMPInternet
Data Link2MAC framingEthernet, switchesLink
Physical1Bits on the mediumcables, hubsLink

A mnemonic for layers 1 to 7 is 'Please Do Not Throw Sausage Pizza Away.' The TCP/IP Application layer absorbs OSI layers 5-7, and its Link layer absorbs OSI layers 1-2.

TCP versus UDP

Both TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) ride on IP at the transport layer, but they make opposite trade-offs.

  • TCP is connection-oriented: it sets up a session with a three-way handshake (SYN, SYN-ACK, ACK), numbers bytes, acknowledges receipt, retransmits losses, and applies flow and congestion control. Reliable but higher overhead. Used by HTTP/HTTPS, email (SMTP), and file transfer.
  • UDP is connectionless: it fires datagrams with no handshake, acknowledgment, or retransmission. Lightweight and low-latency but unreliable. Used by DNS, streaming, VoIP, and online gaming, where speed beats guaranteed delivery.

The exam frames this as 'reliable vs fast': choose TCP when every byte must arrive in order, UDP when a late packet is useless and low latency wins. Applications are identified by port numbers (HTTP 80, HTTPS 443, DNS 53, SSH 22), and a socket is the pairing of an IP address with a port. TCP also provides flow control via a sliding window (the receiver advertises how much it can accept) and congestion control that throttles the sender when the network is loaded; UDP does neither, pushing any rate control up to the application.

IPv4 addressing and subnetting

An IPv4 address is 32 bits, written as four dotted-decimal octets such as 192.168.1.10. A subnet mask or CIDR prefix splits it into a network portion and a host portion; /24 means the first 24 bits identify the network, leaving 8 host bits. The number of addresses in a subnet is 2^(host bits); two are reserved - the all-zeros host is the network address and the all-ones host is the broadcast address - so usable hosts = 2^(host bits) - 2.

PrefixHost bitsTotalUsable
/248256254
/2666462
/2753230
/30242 (point-to-point)

Worked subnet: You must place 100 hosts on one subnet. Solve 2^h - 2 >= 100, so 2^h >= 102, giving h = 7 (2^7 - 2 = 126 usable; h=6 gives only 62). Network bits = 32 - 7 = 25, so the prefix is /25 with mask 255.255.255.128. IPv6, by contrast, uses 128-bit addresses written in hex. Private IPv4 ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) are not routable on the public Internet and rely on NAT to share one public address; the loopback 127.0.0.1 always refers to the local host. A handy check: each step of one in the prefix length halves the host count, so /25 has half the hosts of /24.

Test Your Knowledge

How many usable host addresses are available in a subnet with a /27 prefix?

A
B
C
D

Encapsulation, switching, and routing

As data moves down the sending stack, each layer adds its own header in a process called encapsulation; the receiver strips them in reverse (decapsulation). The unit of data, the protocol data unit (PDU), changes name at each layer:

  • Transport layer: segment (TCP) or datagram (UDP)
  • Network layer: packet - gains the IP header with source/destination IP addresses
  • Data link layer: frame - gains the MAC header and trailer (with a CRC)
  • Physical layer: bits on the wire

Devices map to layers: a hub repeats bits (layer 1), a switch forwards frames using MAC addresses within a LAN (layer 2), and a router forwards packets between networks using IP addresses (layer 3). Switching keeps traffic local using a MAC table; routing chooses a path between networks using a routing table and protocols such as OSPF or BGP.

Test Your Knowledge

Which protocol is most appropriate for real-time voice over IP that tolerates occasional lost packets but cannot tolerate delay?

A
B
C
D