1. Network Layer
Network Layer Functions
- Transports data from sending to receiving host
- Encapsulates data into datagrams on sending side; delivers to transport layer on receiving side
- Network layer protocols exist in every host and router
- Additional Insight: The network layer is responsible for logical addressing (IP addresses) and path determination across multiple networks
Two Key Functions
- Forwarding: Moves datagrams from router’s input to appropriate output (local action)
- Routing: Determines route taken by datagrams using routing algorithms (RIP, OSPF, BGP) - global action
- Practical Example: Think of forwarding as driving through each intersection (router), while routing is like planning your entire trip using GPS navigation
Forwarding Tables & Longest Prefix Matching
- Routers forward packets by examining header and consulting forwarding table
- Longest prefix matching: When multiple prefixes match, use the longest (most specific) one
- Example: If table has entries for
192.168.1.0/24and192.168.1.128/25, and packet destination is192.168.1.130, the/25route is chosen
Network Service Models
- Internet (Best Effort): No bandwidth, loss, order, or timing guarantees
- ATM CBR: Constant rate, guarantees loss/order/timing
- ATM VBR/ABR/UBR: Various levels of bandwidth and delivery guarantees
- Modern Context: Most Internet applications are designed around best-effort service, implementing reliability at higher layers when needed
2. Virtual Circuits vs Datagrams
| Feature | Virtual Circuits | Datagrams |
|---|---|---|
| Connection Setup | Required | Not required |
| Addressing | VC identifier | Destination IP address |
| State Maintenance | Per-connection state | No connection state |
| Resource Allocation | Possible | Not allocated |
| Reliability | Built-in | Provided by higher layers |
| Examples | ATM, MPLS, X.25 | Internet IP |
Key Insight: The Internet chose datagrams for robustness and simplicity, while telephone networks preferred virtual circuits for predictable service quality.
3. Router Architecture
Components
- Control Plane: Runs routing algorithms (software) - “the brain”
- Data Plane: Input ports, switch fabric, output ports (hardware) - “the muscle”
Switching Techniques
- Bus: Simple but limited by bus bandwidth
- Memory: Flexible but speed limited by memory bandwidth
- Crossbar: High performance but complex and expensive
- Modern Evolution: Many routers now use network processors and programmable ASICs for better performance and flexibility
Software-Defined Networking (SDN)
- Separates control plane from data plane
- Enables centralized network management and programmability
- Real-world Impact: Cloud providers like Google and Amazon use SDN to manage their massive networks efficiently
4. IP Protocol
IPv4 Datagram Format
- Minimum 20-byte header, maximum 60 bytes with options
- Critical fields: TTL (prevents infinite loops), Protocol (identifies upper layer), Flags & Fragment Offset (for fragmentation)
- Header Checksum: Provides error detection only for the header, not data
IPv4 Fragmentation & Reassembly
- Fragmentation can occur at any router when packet exceeds MTU
- Reassembly occurs only at final destination
- MTU Discovery: Modern systems often use Path MTU Discovery to avoid fragmentation
IP Addressing & Subnets
- Classful Addressing: Obsolete system (Class A, B, C)
- CIDR: Modern flexible addressing
a.b.c.d/x - Private Ranges:
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 - Special Addresses:
127.0.0.1(loopback),255.255.255.255(broadcast)
DHCP (Dynamic Host Configuration Protocol)
- Four-step process: Discover → Offer → Request → ACK
- DORA Process: Discover, Offer, Request, Acknowledge
- Lease Time: Addresses are allocated for limited time, then renewed
- Relay Agents: Enable DHCP across multiple subnets
NAT (Network Address Translation)
- Basic NAT: One-to-one IP mapping
- NAPT (Network Address Port Translation): Most common, maps multiple private IPs to one public IP using ports
- NAT Traversal: Techniques like STUN, TURN, ICE help P2P applications work through NAT
- Controversy: NAT breaks the end-to-end principle but enabled Internet scaling
5. IPv6
Key Features
- 128-bit addresses (3.4×10³⁸ addresses vs IPv4’s 4.3×10⁹)
- Address Notation:
2001:0db8:85a3:0000:0000:8a2e:0370:7334or compressed2001:db8:85a3::8a2e:370:7334 - Stateless Address Autoconfiguration (SLAAC): Devices can self-configure addresses
- Built-in IPsec: Mandatory support for security
IPv6 vs IPv4 Comparison
| Aspect | IPv4 | IPv6 |
|---|---|---|
| Address Size | 32 bits | 128 bits |
| Header Size | 20-60 bytes | Fixed 40 bytes |
| Fragmentation | Routers can fragment | Only by source |
| Checksum | Header checksum | No checksum |
| Configuration | Manual/DHCP | SLAAC/DHCPv6 |
Transition Mechanisms
- Dual Stack: Devices run both IPv4 and IPv6
- Tunneling: IPv6 packets encapsulated in IPv4
- Translation: NAT64, 6to4, Teredo
- Current Status: ~45% of Google users access via IPv6 (as of 2024)
6. Transport Layer
Services & Protocols
- TCP: Reliable, connection-oriented, flow and congestion controlled
- UDP: Unreliable, connectionless, minimal overhead
- SCTP: Reliable, message-oriented, multi-homing support
Socket Programming
1 | # Basic TCP client example |
Port Categories
- Well-known: 0-1023 (HTTP:80, HTTPS:443, SSH:22)
- Registered: 1024-49151
- Dynamic/Private: 49152-65535
7. UDP (User Datagram Protocol)
Header Structure
1 | 0 7 8 15 16 23 24 31 |
Common UDP Applications
- DNS: Domain name resolution
- DHCP: Dynamic host configuration
- SNMP: Network management
- RTP: Real-time media transport
- QUIC: Modern transport protocol
UDP Advantages in Real-time Applications
- No retransmission delays
- No congestion control (can transmit at constant rate)
- Lower header overhead (8 bytes vs TCP’s 20+ bytes)
8. Reliable Data Transfer (RDT)
Protocol Evolution Summary
| Version | Channel Model | Key Mechanisms |
|---|---|---|
| Rdt1.0 | Perfect | None needed |
| Rdt2.0 | Bit errors | Checksums, ACK/NAK |
| Rdt2.1 | Corrupted ACK/NAK | Sequence numbers |
| Rdt2.2 | NAK-free | ACK with sequence numbers |
| Rdt3.0 | Lossy channel | Timers, retransmission |
Performance Analysis
- Stop-and-Wait Efficiency: ( U = \frac{L/R}{RTT + L/R} )
- Pipelining Improvement: With window size N, efficiency improves by factor of N
- Example: 1Gbps link, 1500-byte packets, 30ms RTT → Stop-and-wait efficiency ≈ 0.04%
9. TCP (Transmission Control Protocol)
TCP Header Deep Dive
1 | 0 1 2 3 |
TCP Congestion Control States
1 | Slow Start → Congestion Avoidance → Fast Recovery |
Advanced TCP Features
- Selective Acknowledgments (SACK): Acknowledge non-contiguous blocks
- Window Scaling: Support for windows larger than 64KB
- Timestamps: Better RTT estimation and protection against wrapped sequences
- Nagle’s Algorithm: Reduces small packets by buffering data
10. Application Layer
HTTP Protocol Evolution Timeline
1 | HTTP/0.9 (1991) → HTTP/1.0 (1996) → HTTP/1.1 (1997) → HTTP/2 (2015) → HTTP/3 (2022) |
HTTP/2 Key Features
- Binary Framing: Replaces text-based protocol
- Multiplexing: Multiple requests/responses interleaved
- Header Compression: HPACK reduces overhead
- Server Push: Proactive resource sending
- Stream Prioritization: Better resource loading order
HTTP/3 and QUIC
- Transport: UDP instead of TCP
- Encryption: TLS 1.3 built-in
- Connection Migration: Seamless IP address changes
- Independent Streams: No head-of-line blocking
DNS Record Types
- A: IPv4 address
- AAAA: IPv6 address
- CNAME: Canonical name (alias)
- MX: Mail exchange
- NS: Name server
- TXT: Text records
- SRV: Service location
CDN Architecture Types
- Push CDNs: Content proactively distributed to edges
- Pull CDNs: Content fetched from origin on demand
- Hybrid: Combination of both approaches
11. Queuing Theory
Key Performance Metrics
- Queue Length ((N_q)): Average number waiting
- System Length ((N)): Average total in system
- Waiting Time ((W)): Average time in queue
- System Time ((T)): Average total time
- Utilization ((ρ)): Server busy probability
M/M/1 Queue Formulas
- Stability Condition: ( ρ = λ/μ < 1 )
- Probability of n jobs: ( P_n = (1-ρ)ρ^n )
- Average jobs in system: ( N = ρ/(1-ρ) )
- Average response time: ( T = 1/(μ-λ) )
Real-world Applications
- Web Servers: Request processing queues
- Routers: Packet buffering
- Call Centers: Customer waiting times
- Manufacturing: Production line optimization
Advanced Queue Models
- M/M/c: Multiple servers
- M/G/1: General service distribution
- G/G/1: General arrival and service
- Priority Queues: Different customer classes
12. Emerging Trends & Future Directions
Network Programmability
- P4: Programming Protocol-independent Packet Processors
- eBPF: Extended Berkeley Packet Filter for kernel networking
- Intent-Based Networking: Declarative network configuration
Security Evolution
- Zero Trust Architecture: “Never trust, always verify”
- Encrypted DNS: DoH (DNS over HTTPS), DoT (DNS over TLS)
- Post-Quantum Cryptography: Preparing for quantum computing threats
Performance Innovations
- Multipath TCP: Using multiple paths simultaneously
- BBR Congestion Control: Model-based instead of loss-based
- Time-Sensitive Networking: Deterministic performance for critical applications
说些什么吧!