Basics of Computer Networks
Curated learning notes on computer science topics (3/4).
- Layering of the TCP/IP reference model:
- Application layer.
- Transport layer (L4).
- Network layer (L3).
- Data-link layer (L2).
- Physical layer (L1). - Each layer uses the services provided by its lower layer and provides services for its upper layer. A lower-layer protocol encapsulates messages of an upper-layer protocol into its own payloads.
- The Domain Name Services (DNS) is a globally-distributed hierarchical lookup table that maps domain names to IP addresses.
- The Dynamic Host Configuration Protocol (DHCP) is used to assign IP addresses to hosts.
- HTTP/1.1 offers:
- Persistent connections, which reduces the overhead of TCP connection setup.
- Request pipelining, which reduces the aggregate transfer latency. - Limitations of request pipelining:
- Responses need to be sent in the same order as the requests, so head-of-line blocking remains.
- Requests need to be idempotent and retriable since an HTTP connection may close at any time. - HTTP/2.0 offers parallel streams over the same TCP connection to eliminate head-of-line blocking.
- WebSocket offers bi-directional full-duplex communications over a persistent TCP connection.
- HTTPS inserts a cryptographic encryption layer (called TLS or SSL) between HTTP and TCP.
- TLS uses computationally expensive asymmetric encryption to send the session key at first, and then switches to symmetric encryption.
- Transmission Control Protocol (TCP):
- Multiplexing and demultiplexing.
- Connection management (state machine).
- Reliable data transfer (sliding window). - TCP reliable data transfer includes:
- Error control (exactly-once and in-order delivery).
- Flow control (within recipient’s capacity).
- Congestion control (within network capacity). - Some features of TCP congestion control:
- Slow start, which is not slow at all.
- AIMD congestion avoidance.
- Fast retransmit and recovery. - Key difference between TCP congestion control and Google’s BBR:
- TCP considers packet loss as the only signal of network congestion and limits the amount of data in flight according to ACKs received.
- BBR strives to get an optimal operating point by estimating bottleneck bandwidth (BtlBw) and round-trip propagation time (RTProp). - The Use Datagram Protocol (UDP) only supports multiplexing/demultiplexing and checksum-based error detection.
- TCP-based (connection-oriented) protocols:
- HTTP (port 80).
- HTTPS (port 443).
- FTP (port 20, 21).
- SMTP (port 25).
- POP3 (port 110).
- IMAP (port 993). - UDP-based (connectionless) protocols:
- DNS (port 53).
- DHCP (port 67, 68).
- NTP (port 123). - The end-to-end argument: a function should be placed at the end points of a communication system if it can be completely and correctly implemented only with the help of the application (“dumb network with smart end hosts”).
- Compared with virtual circuit switching, packet switching has better resiliency and higher utilization of network links.
- Functions of a router:
- Routing, which updates the routing table following routing protocols.
- Forwarding, which consults the routing table to forward packets. - A router consists of multiple network interfaces, and each network interface has a globally-unique MAC address and an IP address (either public or private).
- A router maintains an ARP cache, which maps IP addresses to MAC addresses. Upon a cache miss, an ARP request will be broadcast to the network connected to the corresponding network interface, and meanwhile the router caches all the IP packets blocked on that IP address.
- Routers forward both IP packets and ARP packets. They have different L3 header formats and correspond to different ethernet types when encapsulated by ethernet frames.
- As with ethernet frame headers, an IP header contains the information about its payload type (e.g. TCP, UDP, ICMP, etc).
- The Internet Control Message Protocol (ICMP) lies between the network layer and the transport layer. It supports PING and exchanges L3 error messages (e.g. destination unreachable, time limited exceeded), but is carried by IP packets.
- Routing algorithms in use:
- Distance vector (Bellman-Ford algorithm, used in RIP).
- Link state (Dijkstra’s algorithm, used in OSPF).
- Path vector (with custom policies, used in BGP). - Solutions to scalability problems with classful addressing:
- Classless Inter-Domain Routing (CIDR).
- Route aggregation. - The Internet is a global infrastructure run by different competitive and cooperative commercial entities. Each entity is an autonomous system (AS) that can be categorized into different tiers according to its scope of services.
- What calls for the Border Gateway Protocol (BGP)?
- Better scalability than interior gateway protocols (IGPs).
- Different policies according to relationships (peering or provider-customer transit) between ASes. - BGP specifies three things in a router:
- Import filtering.
- Route selection.
- Export filtering. - BGP sessions, which are run on top of TCP connections, can be categorized as:
- eBGP sessions, which are between border routers from different ASes.
- iBGP sessions, which are within an AS. - The data-link layer assembles bits into frames and takes charge of end-to-end reliable data transfer across a link.
- A switch connects network devices into a network, while a router connects switches and their networks into a more extensive network. Similar to a router, a switch does switching (analogous to forward) and adaptive learning (analogous to routing).