Computer Networks: Application and Transport Layers
Domain Name System (DNS)
- Function & Purpose: Maps human-readable hostnames (e.g.,
cs.umass.edu) to 32-bit IPv4 or 128-bit IPv6 addresses used by network routers. - Architecture: Distributed, hierarchical database comprising:
- Root DNS Servers: 13 logical root servers managed by ICANN, replicated worldwide (~200 in the US).
- Top-Level Domain (TLD) Servers: Handle
.com, .org, .edu, and country-code domains (.cn, .uk). Maintained by registrars like Network Solutions (.com, .net) or Educause (.edu). - Authoritative DNS Servers: Host-to-IP mappings for an organization's specific named hosts.
- Local DNS Name Servers (Default Name Servers): Provided by ISPs or institutions; serve cached answers or act as proxies into the DNS hierarchy.

- DNS Zones vs Domains: A domain represents an entire naming subtree, while a zone is an administrative boundary grouping contiguous domains and subdomains for management delegation.
- Query Types:
- Iterated Query: Contacted server returns a referral to the next server ("I don't know, ask this server"); the requesting host performs the path traversal.
- Recursive Query: Contacted server assumes the burden of fully resolving the address on the client's behalf.
- Caching & TTL: Learnings are cached with a Time To Live (TTL) expiration to optimize performance. Update notifications follow IETF standard RFC 2136.
- DNS Records
(Name, Value, Type, TTL):- Type
A: Hostname → IPv4 address. - Type
AAAA: Hostname → IPv6 address. - Type
NS: Domain → authoritative name server hostname. - Type
CNAME: Alias hostname → canonical (real) hostname. - Type
MX: Domain → mail server canonical name (with priority). - Type
TXT: Free-text data used for domain verification, SPF, and DKIM anti-spam policies. - Type
SOA: Start of Authority information for a zone.
- DNS Message Format: Includes a 16-bit Identification, 16-bit Flags (Query/Reply, Authoritative, Recursion Desired, Recursion Available), Question count, Answer RRs, Authority RRs, and Additional RRs.
- DNSSEC: Adds digital signatures (
RRSIG) to provide authentication and message integrity chained from Root → TLD → Authoritative, preventing cache poisoning.
Peer-to-Peer (P2P) Architecture
- Concept: Direct communication between arbitrary end-systems (peers) without reliance on centralized servers.
- Key Characteristics:
- Self-Scalability: New peers bring new service demands as well as additional serving capacity.
- Intermittent Connectivity: Peers join, leave, and change IP addresses dynamically.
- Examples: BitTorrent (file sharing), Skype (VoIP), Spotify (streaming), Blockchain/cryptocurrencies.
Application Layer Protocols & Port Summary
- File Transfer Protocol (FTP): Uses TCP port 21 for control commands and TCP port 20 for data transmission.
- Simple Mail Transfer Protocol (SMTP): Uses TCP port 25 for pushing emails between mail servers, secured via SSL.
- Dynamic Host Configuration Protocol (DHCP): UDP protocol for dynamic IP allocation. Uses UDP port 67 for servers and UDP port 68 for clients. Functions via the DORA process (Discovery, Offer, Request, ACK).
- Simple Network Management Protocol (SNMP): Exforces management queries via UDP ports 161/162 between SNMP Managers, Managed Devices, SNMP Agents, and the Management Information Base (MIB).
- Remote Login Protocols: Telnet operates over TCP port 23 in unencrypted plaintext; Secure Shell (SSH) provides encrypted terminal access over TCP port 22.
- Network Time Protocol (NTP): Uses UDP port 123 for time synchronization.
- Lightweight Directory Authentication Protocol (LDAP): Operates on TCP/UDP port 389.
- Web Protocols: HTTP uses TCP port 80; HTTPS uses TCP port 443.

Transport Layer Multiplexing and Demultiplexing
- Multiplexing (Sender): Gathering data from multiple application sockets, encapsulating data with transport header fields, and passing segments to the network layer.
- Demultiplexing (Receiver): Using transport header fields to deliver incoming segments to the appropriate application socket.
- Connectionless Demultiplexing (UDP): Identified solely by the destination port number (0 to 65535; well-known ports are 0 to 1023). All datagrams bound for the same destination port are routed to the same socket regardless of source IP/port.
- Connection-Oriented Demultiplexing (TCP): Identified by a unique 4-tuple:
(Source IP, Source Port, Destination IP, Destination Port)
Receiving hosts route segments to distinct sockets based on all four fields.

User Datagram Protocol (UDP) & Checksum Calculation
- Protocol Characteristics (RFC 768): "No-frills," connectionless transport over IP providing lightweight, best-effort, out-of-order delivery without handshaking, congestion control, or flow control.
- Header Structure: Fixed 8-byte overhead containing four 16-bit fields:
- Source Port
- Destination Port
- Segment Length (header plus data in bytes)
- Checksum

- Checksum Calculation Steps:
- Treat the entire segment (header, payload, pseudo-header) as a sequence of 16-bit binary integers.
- Compute the 1's complement sum of these 16-bit words.
- Add any wraparound carry-outs from the most significant bit back to the least significant bit.
- Invert all bits (take the 1's complement) to obtain the final checksum.
- Receiver Verification: Sum all received words including the checksum. If all bits are
1, no errors were detected; otherwise, an error occurred.
- Error Detection Limits: Catches all single-bit flips and burst errors under 16 bits; fails to detect multi-bit errors across different words that cancel each other out in the sum.
Reliable Data Transfer (RDT) Principles
- RDT Protocol Progression:
- RDT 1.0: Assumes a perfectly reliable underlying channel.
- RDT 2.0: Handles bit errors using Checksums, Positive ACKs, and Negative ACKs (NAKs).
- RDT 2.1: Adds 1-bit sequence numbers (0, 1) to detect and handle duplicate packets resulting from corrupted ACKs/NAKs.
- RDT 2.2: NAK-free design utilizing duplicate ACKs to signal packet loss or corruption.
- RDT 3.0 (Alternating-Bit Protocol): Handles both bit errors and packet loss using countdown timers and retransmission on timeout.
- Stop-and-Wait vs Pipelining:
- Stop-and-Wait Utilization: Sender is idle during round-trip transmission:
Usender=RTT+L/RL/R
- Pipelining: Allows multiple in-flight, unacknowledged packets to dramatically scale link utilization.

- Pipelined Protocol Mechanisms:
- Go-Back-N (GBN): Uses cumulative ACKs (
ACK(n) acknowledges all bytes up to n) and a single timer for the oldest unACKed packet. On timeout, retransmits packet n and all subsequent packets in the current window. Receiver discards out-of-order packets. - Selective Repeat (SR): Individually acknowledges all correctly received packets and uses per-packet timers. Receiver buffers out-of-order packets. Requires window size N≤21Sequence Number Space to prevent duplicate sequence number confusion.
Transmission Control Protocol (TCP) Architecture
- Key Properties: Point-to-point, reliable in-order byte-stream transport using full-duplex communication with Maximum Segment Size (MSS), flow control, and congestion control.
- RTT Estimation & Timeout Formulas:
- Exponential Weighted Moving Average (EWMA) of Sample RTT (typical α=0.125):
EstimatedRTT=(1−α)×EstimatedRTT+α×SampleRTT
- RTT Deviation estimation (typical β=0.25):
DevRTT=(1−β)×DevRTT+β×∣SampleRTT−EstimatedRTT∣
- Dynamic Timeout Interval calculation:
TimeoutInterval=EstimatedRTT+4×DevRTT
- TCP Fast Retransmit: If the sender receives 3 duplicate ACKs (4 identical ACKs total), it retransmits the missing segment immediately without waiting for the timer to expire.
- Flow Control: Prevents sender from overflowing receiver buffers via advertised Receive Window (rwnd):
LastByteRcvd−LastByteRead≤RcvBufferrwnd=RcvBuffer−(LastByteRcvd−LastByteRead)
- TCP Connection Handshake (3-Way):
- Client sends
SYN=1, Seq=x (State: SYN_SENT). - Server responds with
SYN=1, ACK=1, Seq=y, AckNum=x+1 (State: SYN_RCVD). - Client sends
ACK=1, AckNum=y+1 (State: ESTABLISHED).
- TCP Connection Teardown:
- Host sends
FIN=1, Seq=x (State: FIN_WAIT_1). - Peer returns
ACK=1, AckNum=x+1 (State: CLOSE_WAIT). - Peer sends
FIN=1, Seq=y (State: LAST_ACK). - Host sends
ACK=1, AckNum=y+1 and enters TIME_WAIT (waits 2×Max Segment Lifetime) before closing.