Live2D

【Updating】Note -「Comp. Networks」“飞鸟载着问询行远”

\[\mathscr{Lorain~wy~Lora~blea.} \newcommand{\DS}[0]{\displaystyle} % operators alias \newcommand{\opn}[1]{\operatorname{#1}} \newcommand{\card}[0]{\opn{card}} \newcommand{\lcm}[0]{\opn{lcm}} \newcommand{\char}[0]{\opn{char}} \newcommand{\Char}[0]{\opn{Char}} \newcommand{\Min}[0]{\opn{Min}} \newcommand{\rank}[0]{\opn{rank}} \newcommand{\Hom}[0]{\opn{Hom}} \newcommand{\End}[0]{\opn{End}} \newcommand{\im}[0]{\opn{im}} \newcommand{\tr}[0]{\opn{tr}} \newcommand{\diag}[0]{\opn{diag}} \newcommand{\coker}[0]{\opn{coker}} \newcommand{\id}[0]{\opn{id}} \newcommand{\sgn}[0]{\opn{sgn}} \newcommand{\Res}[0]{\opn{Res}} \newcommand{\Ad}[0]{\opn{Ad}} \newcommand{\ord}[0]{\opn{ord}} \newcommand{\Stab}[0]{\opn{Stab}} \newcommand{\conjeq}[0]{\sim_{\u{conj}}} \newcommand{\cent}[0]{\u{\degree C}} \newcommand{\Sym}[0]{\opn{Sym}} \newcommand{\Var}[0]{\opn{Var}} \newcommand{\wg}[0]{\wedge} \newcommand{\Wg}[0]{\bigwedge} \newcommand{\sq}[0]{\opn{\square}} % symbols alias \newcommand{\E}[0]{\exist} \newcommand{\A}[0]{\forall} \newcommand{\l}[0]{\left} \newcommand{\r}[0]{\right} \newcommand{\ox}[0]{\otimes} \newcommand{\lra}[0]{\leftrightarrow} \newcommand{\llra}[0]{\longleftrightarrow} \newcommand{\iso}[1]{\overset{\sim}{#1}} \newcommand{\eps}[0]{\varepsilon} \newcommand{\Ra}[0]{\Rightarrow} \newcommand{\eq}[0]{\leftrightarrow} \newcommand{\Eq}[0]{\Leftrightarrow} \newcommand{\d}[0]{\mathrm{d}} \newcommand{\e}[0]{\mathrm{e}} \newcommand{\i}[0]{\mathrm{i}} \newcommand{\j}[0]{\mathrm{j}} \newcommand{\k}[0]{\mathrm{k}} \newcommand{\Ex}[0]{\mathbb{E}} \newcommand{\D}[0]{\mathbb{D}} \newcommand{\oo}[0]{\infty} \newcommand{\tto}[0]{\rightrightarrows} \newcommand{\mmap}[0]{\hookrightarrow} \newcommand{\emap}[0]{\twoheadrightarrow} \newcommand{\actl}[0]{\curvearrowright} \newcommand{\actr}[0]{\curvearrowleft} \newcommand{\nsubg}[0]{\triangleleft} \newcommand{\nsupg}[0]{\triangleright} \newcommand{\lin}[0]{\lim_{n\to\oo}} \newcommand{\linf}[0]{\liminf_{n\to\oo}} \newcommand{\lsup}[0]{\limsup_{n\to\oo}} \newcommand{\ser}[0]{\sum_{n=1}^\oo} \newcommand{\serz}[0]{\sum_{n=0}^\oo} \newcommand{\isoto}[0]{\overset\sim\to} \newcommand{\F}[0]{\mathbb F} \newcommand{\x}[0]{\times} \newcommand{\M}[0]{\mathbf{M}} \newcommand{\T}[0]{\intercal} \newcommand{\Co}[0]{\complement} \newcommand{\alp}[0]{\alpha} \newcommand{\lmd}[0]{\lambda} \newcommand{\mmid}[0]{\parallel} \newcommand{\loop}[0]{{\circlearrowleft}} \newcommand{\go}[0]{\triangleright} % symbols with parameters \newcommand{\der}[1]{\frac{\d}{\d #1}} \newcommand{\ul}[1]{\underline{#1}} \newcommand{\ol}[1]{\overline{#1}} \newcommand{\wt}[1]{\widetilde{#1}} \newcommand{\br}[1]{\l(#1\r)} \newcommand{\bk}[1]{\l[#1\r]} \newcommand{\ev}[1]{\l.#1\r|} \newcommand{\wh}[1]{\widehat{#1}} \newcommand{\eval}[1]{\l[\!\l[#1\r]\!\r]} \newcommand{\abs}[1]{\l|#1\r|} \newcommand{\bs}[1]{\boldsymbol{#1}} \newcommand{\dat}[1]{\bs{\mathrm{#1}}} \newcommand{\env}[2]{\begin{#1}#2\end{#1}} \newcommand{\ALI}[1]{\env{aligned}{#1}} \newcommand{\CAS}[1]{\env{cases}{#1}} \newcommand{\pmat}[1]{\env{pmatrix}{#1}} \newcommand{\algo}[1]{\begin{array}{r|l}#1\end{array}} \newcommand{\dary}[2]{\l|\begin{array}{#1}#2\end{array}\r|} \newcommand{\pary}[2]{\l(\begin{array}{#1}#2\end{array}\r)} \newcommand{\pblk}[4]{\l(\begin{array}{c|c}{#1}&{#2}\\\hline{#3}&{#4}\end{array}\r)} \newcommand{\u}[1]{\mathrm{#1}} \newcommand{\t}[1]{\text{#1}} \newcommand{\ts}[1]{\textsf{#1}} \newcommand{\tb}[1]{\textbf{#1}} \newcommand{\os}[2]{\overset{#1}{#2}} \newcommand{\lix}[1]{\lim_{x\to #1}} \newcommand{\ops}[1]{#1\cdots #1} \newcommand{\seq}[3]{{#1}_{#2}\ops,{#1}_{#3}} \newcommand{\dedu}[2]{\u{(#1)}\Ra\u{(#2)}} \newcommand{\prv}[3]{\DS{{\DS #1} \over {\DS #2}}~(#3)} \]

Intro

  • Statistic Multiplexing: useful because users are mostly idle and their traffic is bursty.
  • Full/Half-duplex, Simplex; Broad/Uni/Multi/Any-cast.
  • Socket API:
    • Abstraction: the network service API used to write all Internet apps; part of OSes/languages.
    • Supports: stream (reliable) and datagram (unreliable).
  • Protocols and Layers:
    • What's "layering"?
      • Each instance talks to its peer virtually using the protocol.
      • Each instance uses only the services of the lower layer.
    • Encapsulation (or Multiplexing) & Demultiplexing: wrap and unwrap packages correctly.
    • Drawbacks: overhead and information hide.
  • OSI "7 layer" reference model:
    • Application: provides functions needed by users.
    • Presentation: converts different representations.
    • Session: manages task dialogs.
    • Transport: provides end-to-end data delivery.
    • Network: route packages.
    • Data Link: sends frames between neighboring elements.
    • Physical: sends bits as signals.
  • Internet Reference Model (IRM):
    • Application - Transport - Internet - Link.
    • IP as the narrow waist: supports many different links below and apps above.
    • Unit of data in layers: message (application), segment (transport), packet (network), frame (link), bit (physical).
    • Devices in the network: repeater/hub (physical - physical), switcher (link - link), router (network - network), proxy/middlebox/gateway (app - app).
  • Design Philosophy in Networked Systems - take-homes:
    • Forced checks in lower layers may become constraints for higher layers: end-to-end checks may be a better philosophy.

      • Benefit: Reduces redundancy, takes control, avoids confusion, and opens more flexibilities for application/user-centric design.
    • Design with tussles: Modularization & Design for choice. Let users or communities to choose their "value", instead of being "value-neutral" in vain.

      • Difference: Modular design concerns the design space constraining everyone, and ensures modules’ orthogonality from the global view, regardless of the need to assume what the final decision is; design for choice is about the decision does not need to be the same for every.

Physical Layer

  • Abstraction of "link":

    • Rate (or bandwidth, capacity, speed).
    • Delay.
    • \(\t{data in flight} = \t{bandwidth} \x \t{delay}\). (Bandwidth means data rate here.)
  • Latency:

    • Transmission delay: time to put \(M\)-bit message on the wire.
      • \(\t{T-delay}=M/R\) (\(R\) for rate).
    • Propagation delay: time for bits to propagate through the wire.
      • \(\t{P-delay}=\frac{3L}{2c}=:D\).
    • Latency: \(M/R+D\).
  • Signals: analog vs digital. For transmission:

    • Analog: transmitting without regard to their content. Can be amplified but not recovered from distortion or noise.
    • Digital (with knowledge that "original signals are 0/1"): can be recovered (regenerated along the path by demodulating and remodulating).
  • Bandwidth (from now on): width of frequency band (in \(\u{Hz}\)).

  • Decibels (dB): \(10\log_{10}(P_1/P_2)\).

    • Can be made absolute. \(\t{dBW}\), \(P_2=1\t W\); \(\t{dBm}\), \(P_2=1\t{mW}\).
  • Dilemma for the wireless:

    • Shared medium (who is talking to me?);
    • Unguided propagation and path loss (rapid energy loss);
    • Interference;
    • Shadowing & multipath fading (indoor complexity, or even Doppler shift).
  • Antenna:

    • RF signal \(\eq\) electrical signal by conductors (in both Tx and Rx).
    • Efficiency depends on its size and relative to the signal wave length. \(\frac{\lmd}{4}\) for max efficiency.
    • Usually work in half-duplex.
    • \(\t{antenna gain}=\t{power at particular point} / \t{power with isotropic}\) (usually in \(\t{dB}\), named \(\t{dBi}\)).
  • Fresnel Zones: sequence of ellipsoids centered around the LoS path between a Tx and Rx.

    • \(k\)-th Fresnel zone creates \(\frac{(2k-3)\pi}{2}\sim\frac{(2k-1)\pi}{2}\) phase difference. Specially, \(k=1\) creates \(0\sim\frac{\pi}{2}\).
    • If no phase shift after reflection, odd zones create constructive interference and even zones destructive.
  • Delay distortion: the channel introduces different delays for different frequencies.

  • Multipath Effect:

    • Delay spread \(\tau_\max\): maximum delay after which the received signal becomes negligible (often in nanoseconds).
    • Inter-symbol interference (ISI).
  • Frequency-selective fading: as the nearby environment moves, the path changes are relevant to wavelength.

  • Doppler shift.

  • Signal-to-noise ratio (SNR): \(\t{SNR}:=10\log_{10}\frac{\t{signal power}}{\t{noise power}}~(\t{dB})\), giving the upper bound on achievable data rate. Defined on a particular point (usually at a receiver).

  • Large-scale fading:

    • Path loss: \(L(d)=L_0+10n\log\frac{d_0}{d}\). \(n=2\) for free space, \(3\) for office, etc.
    • ... with shadow effect: \(L(d)=L_0+10n\log\frac{d_0}{d}+X_\sigma\), where \(X_\sigma\sim\mathcal N(0,\sigma^2)\).
  • Wireless Channel Model. \(y(f)=H(f)x(f)+n(f)\), which is a convolution in time.

  • Bandwidth \(\uparrow\), cost \(\uparrow\). Bandwidth \(\downarrow\), distortion \(\uparrow\) (because modulation becomes limited).

  • Bit error rate: rate at which errors occur.

  • Noise:

    • Thermal/white noise. Noise power spectral density \(N_0=k_BT\). Noise power \(N_0\x B\) for bandwidth \(B\).
    • Receiver noise: amplifiers and mixers add noise.
    • Crosstalk: picking up signals from other source-destination pairs.
    • Impulse noise: irregular pulses of high amplitude and short duration. (Should be dealt with at protocol level.)
  • Nyquist Capacity:

    • A noiseless channel of bandwidth \(B\) can at most transmit a binary signal at capacity \(2B\).
      • Why \(2B\)? For any duration \(T\), the distinguishable frequency gap can be estimated as \(\frac{1}{T}\), so there are \(2BT\) degrees of freedom for this wave, which gives its capacity is (at most) \(\frac{2BT}{T}=2B\).
    • More aggressive encoding (for \(M\) levels): \(C=2B\log_2M\).
  • Shannon Capacity:

    • \(C=B\log_2\br{1+\frac{S}{N}}\), where \(S\) is the average power of the signal, and \(N\) the noise (recall that \(N=N_0B\) for white noise).
    • For wires and fibers: \(B\) and \(S/N\) are fixed, so data rate can be fixed.
    • For the wireless: \(B\) is fixed, but \(S/N\) varies greatly, so does data rate.
  • Transmitter: source encoder + channel encoder + digital modulator.

    • Source encoder: do data compression.
    • Channel encoder: do error control coding.
    • Digital modulator: do line/transmission coding (encodes digital data into electrical pulses); and more.
  • Line/transmission coding (baseband modulation):

    • NRZ, problem: receiver needs frequent signal transitions to decode bits.
    • Manchester coding: things like "low to high" for \(1\).
    • \(4\t B/5\t B\) coding: map \(4\) data bits into \(5\) code bits to avoid long runs of \(0\) (at most \(000\)).
    • Miller coding: at most \(11\) or \(0000\).
  • Passband/carrier modulation:

    • Why? Baseband modulated signals propagate poorly on fiber/wireless. Need to send higher frequencies.
    • Can modulate the carrier by changing amplitude, frequency and phase.
    • Amplitude-Shift Keying (ASK): signal goes \(0\) for bit \(0\), normal for \(1\).
      • \(M\)-ASK: more amplitude level.
    • Frequency-Shift Keying (FSK): one frequency for \(0\), another for \(1\).
      • \(M\)-FSK: more selectable frequencies (requiring higher bandwidth).
    • Phase-Shift Keying (PSK): \(\pi\) phase shift for \(0\) (Binary PSK, BPSK).
      • Quadrature PSK: \(\cos(2\pi f_ct+\phi)\), where \(\phi=\frac{(2k+1)\pi}{4}\) for \(00,\dots,11\).
      • Quadrature Amplitude Modulation (QAM): \(A\cos(2\pi f_ct+\phi)\). \((A\cos\phi,A\sin\phi)\) forms a constellation point in the plane spanned by \(\cos(2\pi f_ct)\) and \(\i\sin(2\pi f_ct)\).
  • Multiplexing: MUX and DEMUX.

  • Diversity techniques:

    • Why? The quality of the channel varies among time, space and frequency. Don't put all eggs into one bucket.
    • Space diversity:
      • Receiver diversity: maximal ratio combining (MRC): sum the phase-aligned signals with weight the inversed mean square noise level.
      • Transmitter diversity: pre-align each component and weight them for known channels, or try to figure out the channels based on channel reciprocity.
    • Time diversity: spread data out over time.
    • Frequency diversity: spread signal over multiple frequencies (against frequency selective fading).
  • Synchronous Time Division Multiplexing (TDM): pre-assigned time slot sequences for channels.

  • Multiple-input-multiple-output (MIMO) Antenna Architecture:

    • \(N\x M\) subchannels that can be used for simultaneous reception or transmission of multiple streams.
    • Very effect if there is no direct line of sight (subchannels becomes more independent).
    • MIMO is used in 802.11n/ac.
    • Can be "spatial diversity", if bit error rate is too high;
    • Can be "spatial multiplexing", if the channel condition is favorable.
  • Frequency Division Multiplexing (FDM): possible when the useful bandwidth of the medium exceeds the required one.

  • Orthogonal Frequency Division Multiplexing (OFDM): distribute bits over \(N\) subcarriers that use different frequencies in the band.

    • Why no simple FDM? That needs guard bands.
  • Overview:

    • Scope: how to transfer messages over one or more connected links (unit of message: frames).
    • Logic Link Control (LLC): Interfaces for higher layers (hiding MAC); error control and flow control.
    • Media Access Control (MAC): encapsulate frames; acquire data from received frames; control the access on media.
    • Protocol: 802.3 (Ethernet), 802.11 (e.g. WLAN), ...
    • Implementation: combination of hardware, software and firmware.
      • Low MAC: in hardware like network interface cards (NICs); SIFS, DIFS, ACK, CRC.
      • High MAC: in software like MAC layer driver; retransmission, beacon.
  • Framing:

    • Byte count: difficult to resynchronize.

    • Byte stuffing: FLAG for frame boundaries, ESC for escape flags in data.

      | FLAG | Header | Payload | Trailer | FLAG |

    • Bit stuffing: a bit level byte stuffing. Bit pattern "preamble" at the beginning of a frame.

    • Typical structure of a "wired" frame:

      | Preamble | Dst Addr | Src Addr | Type | Length | Data | CRC |

    • 802.11 long/short preamble.

  • Error Code:

    • Code rate: \(D/(D+R)\).
    • Hamming distance: the minimal distance between two different valid \((D,R)\) pairs. With up to \(d\) errors, code of
      • \(d+1\) distance can detect the error.
      • \(2d+1\) distance can correct the error by mapping the pair to the nearest valid one.
    • Internet Checksum: the ring is \(\Z/(2^R-1)\Z\) instead of \(\Z/2^R\Z\)., the final sum is negated (\(0\to 2^R-1\) specially).
    • Cyclic Redundancy Check (CRC): for generator \(C\in\F_2[X]\) of degree \(k\), calculate \(R=x^kD\bmod C\). Therefore \(x^kD+R\equiv 2R\equiv 0\pmod C\).
      • Hamming distance \(d=\min_{c\neq 0}\opn{wt}(c)\); \(d=4\) for common designs.
    • Hamming code: \(2^k-1\ge n+k\) if we want to correct single error.
      • Put check bit at \(2^t\) positions, counting the parity of all positions with the \(t\)-th bit on.
  • Automatic Repeat reQuest (ARQ): common and must-be-corrected errors. (WiFi, TCP, ...)

    • ACK with one bit sequence number for correctness.
    • Sliding window trick to avoid naive stop-and-wait overhead.
  • ALOHA: frames of same length, traffic load \(G\), Tx distribution \(P\sim\t{Poisson}(G)\).

    • Throughput: \(S=G\x P_{\t{success}}\).
    • Unslotted: need a \(2\)-frame clear time to Tx. \(S=G\x\e^{-2G}\le\frac{1}{2\e}\).
    • Slotted: only need a \(1\)-frame clear time to Tx. \(S=G\x\e^{-G}\le\frac{1}{\e}\).
    • Expected re-Tx time is \(\e^G\) for slotted ALOHA, still not efficient under high load.
  • Carrier Sense Multiple Access (CSMA):

    • Tx only if the channel senses idle, but collision can still happen.
    • CSMA w/ Collision Detection: sending jam signal the rest of the frame time.
    • Requirement: Tx can't finish before collision is heard by Tx, so minimal frame size should be \(2D\).
      • Ethernet: \(64\t B\).
    • \(P\)-persistent scheme: Tx with probability \(P\) when the channel senses idle, or delay by \(t_{\t{prop}}\).
    • Non-persistent scheme: reschedule based on a delay distribution. (e.g. Binary Exponential Backoff.)
    • BEB: after collision detection and jamming, NIC waits for \(512\x K\) bit-time where \(K\sim\t{Unif}[0:2^{\min\{m,10\}}-1]\) for the \(m\)-th collision.
  • Turn-Take Multiple Access:

    • E.g. token ring scheme.
    • Fixed overhead, regular chance to send, predictable service.
    • But more things can go wrong (what if the token is lost?), Higher overhead and latency under low load, unfriendly to mobility.
  • Classic Ethernet (IEEE 802.3):

    • \(1\)-persistent CSMA/CD with BEB.
    • CRC-\(32\) for error detection, no ACKs or retransmission.
    • Start of frame identifies with physical layer preamble, followed by destination and source addresses.

  • Wireless Complications:
    • Two hidden Tx can collide at one Rx.
    • Two exposed Tx can send concurrently to different Rx.
    • Distance and signal power make competition unfair.
    • Collision is hard to detect in radio environment.
  • Multiple Access Collision Avoidance:
    • The sender transmits RTS (Require-To-Send) with frame length, the receiver replies with CTS (Clear-To-Send) with frame length.
    • The sender transmits the frame. Any other node heard the CTS should stay silent.

  • 802.11
    • Last mile multi-access, high throughput, highly reliable data delivery, continuous network connection.
    • Defines MAC sublayer and MAC management protocols and services, and some physical layer techniques.
      • Wi-Fi (Wireless Fidelity) is a trademark.
    • Infrastructure and ad hoc mode.
  • 802.11 MAC: Distributed Coordination Function (DCF) technique. CSMA/CA.
    • \(\t{DIFS}=\t{SIFS}+2\x\t{slot time}\).
    • Also ARQ, BEB.
  • Many details about 802.11 are ignored.

Network Layer

  • Network service models:
    • Datagrams (connectionless service; IP here) & virtual circuits (connection-oriented service).
    • Concerned QoS guarantees: Bandwidth? Loss? Order? Timing?
  • Router workflow: store-and-forward packet switching:
    • Input port (may queue);
    • Switching fabrics (switching rate is desired to be \(N\) times line rate; statistical multiplexing);
    • Output port (may queue).
  • Queuing:
    • Input port queuing (when switching is slower than input rate). Blocking happens when (1) there is another packet in front of the current one in the same queue (Head-of-the-Line blocking, HOL); (2) there is another packet switching to the same output port as the current one.
    • Output port queuing: buffering, scheduling, and dropping.
  • Routing in Datagram Model:
    • Packets tell their destination;
    • Routers decide the next hop with their forwarding table of \(\{\t{destination}\mapsto\t{line}\}\)..
  • Routing in Virtual Circuit Model:
    • Packets tell their desired short circuit ID (unique for a link);
    • Routers decide the next hop with there forwarding table of \(\{\t{(source,id)}\mapsto\t{(line,new id)}\}\).
    • Circuit: set up when connection is established, used then transferring data, deleted when connection is teardown.
  • Multi-Protocol Label Switching (MPLS):
    • ISP sets up circuits inside there backbone ahead of time.
    • ISP adds MPLS label to IP packet at ingress, undoes at egress.
  • Routing Algos: Static or dynamic, global ("link state" algos) or decentralized ("distance vector" algos).
  • Distance Vector Routing:
    • Briefly: distributed "Bellman-Ford"-like relaxation.
    • \(k\)-th exchange maintains all \(\le k\)-hop info.
    • Partitions (connectivity broken) leads to "count-to-infinity" scenario.
    • Good news travels quickly, bad news slowly.
    • To address: heuristics like "split horizon, poison reverse".
    • (Anyway, more resource-efficient than better algos.)
  • Routing Information Protocol (RIP):
    • DV routing with hop count as metric, \(16\) as \(+\oo\), "split horizon, poison reverse".
    • Routers send vectors every 30 secs, runs on top of UDP, 180 secs time-out.
  • Flooding: decentralized broadcast.
    • Remember message to stop flood using source and sequence number.
    • Use ARQ to make flooding reliable.
  • Link-State Algorithm:
    • Topology Dissemination: nodes flood topology in the form of link state packets.
    • Route Computation.
  • Link-State Complications:
    • Sequence number reaches max or is corrupted.
    • Node crashes and losses sequence number.
    • Network partitions then heals.
    • Solution: include age on LSPs and forget old info that is not refreshed.
    • Improve scalability: features like "areas".
  • IS-IS (Intermediate System to I.S.), OSPF (Open Shortest Path First): widely used in large enterprise and ISP networks.
  • Hierarchical Routing: route to a region instead of a single host.
  • Routing Policies:
    • Capture goals of different parties. (e.g. Internet2: non-commercial traffic only.)
    • Transit service: from/to ISP customer to/from the Internet. Customers pay ISP.
    • Peer service: accept traffic from each other for their own customer. Don't pay each other.
  • Border Gateway Protocol: inter-domain routing protocol.
    • Path vector, a kind of distance vector.
    • eBGP: obtain Anonymous System (AS) reachability info from neighboring ones.
    • iBGP: propagate reachability info to all AS-internal routers.
    • Determine "good" routes to other networks

  • IP(v4) Address:
    • E.g. 18.31.0.0/24: prefix length \(L=24\), contains \(2^{32-L}\) addresses.
    • Private IP addresses: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
    • Allocating: IANA to regional bodies (RIRs) to companies to customers.
  • Forwarding: longest matching prefix.
    • Nodes have table listing (prefix, next hop) pairs.
    • Adopt the inner-most intersection containing the target IP.
    • Other features: TTL decrement (against loops), header checksum check (reliability), fragmentation (split to fit), congestion signals (warn hosts of congestion), generate error messages, handle various options.
  • Maximum Transmission Unit (MTU): fragmentation & discovery.
  • Fragmentation:
    • Split by routers, reassemble by hosts.
    • Copy IP header, adjust length, set offset, set MF (more fragments) on all pieces except the last one.
    • Path MTU discovery: send large packet with DF (don't fragment) bit on to get feedback messages.
  • Internet Control Message Protocol: network-layer "above" IP (capsulated in IP header).
    • Used by routers and hosts to communicate network-level info.
    • Error reporting, echo request/reply (e.g. ping).
  • Traceroute: send with increasing TTL field to receive ICMP errors hop by hop.
  • Dynamic Host Configuration Protocol.
    • Get client's own IP address (with network prefix, address of local server, DNS server, etc.).
    • A client-server protocol with UDP on ports 67, 68.
    • (DHCP Discover \(\to\) DHCP Offer) \(\to\) DHCP Request \(\to\) DHCP Ack.
  • Address Resolution Protocol: sits right on top of link layer.

  • Network Address Translation (NAT) Box:
    • Connects an internal network to an external one with address translation.
    • Motivated by IP scarcity.
    • Keep mappings 1 to 1 with ports.
    • Adv. relieves IP address pressure; easy to deploy; useful functionality (firewall).
    • Dis. connectivity broken (bad for peer-to-peer apps); don't work so well when no connections (UDP apps); break apps that expose their IP addresses (e.g. FTP).
  • IPv6 v.s. IPv4:
    • No checksums; no fragmentation/reassembly; no options (yet available with next-layer protocol).
    • Transition with tunneling: encapsulate IPv6 datagram into a IPv4 one.

Transport Layer

  • Socket API:

    • The "network" API used to write all Internet apps; part of all major OSes and languages.
    • Sockets let apps attach to the local network at different ports.
    • Same API used for streams (TCP) and datagrams (UDP).
  • User Datagram Protocol:

    • A shim layer on packets.
    • Header: source port, destination port, UDP length, UDP checksum (\(16\t B\x4\)).
    • Message-oriented ("Just wanna request/reply"), avoid unnecessary connection setup overhead.
    • E.g. Remote Procedure Call (RPC); Real-time Transport Protocol (RTP, an APP layer protocol based on UDP).
  • Transmission Control Protocol: reliable, connection based, sliding window, flow & congestion control.

    • Reliable bytestream: reliable, ordered, bidirectional data transfer.
    • Header: source/destination ports, SEQ/ACK, SYN/FIN/RST/... flags, window size, ...
  • TCP connection establishment & release: imagine that state machine yourself.

  • Sliding Window: allow \(W\) packets to be outstanding. \(W=2BD\) to fill network path ideally.

    • Sender buffer up to \(W\) segments until they are ACKed.
    • Send while \(\t{LFS}-\t{LAR}< W\).
    • Go-Back-N: receiver keeps a single packet buffer; discards the received one when \(\t{LAS}\) mismatches; resend ACK of \(\t{LAS}\) to hint retransmission. Need sequence numbers at least \(W+1\).
    • Selective Repeat: receiver passes data that are in order to app; buffers out-of-order segment to reduce retransmission. Need sequence numbers at least \(2W\) (packets & early ACKs).
  • TCP sliding window:

    • Cumulative ACK; selective ACK giving hints for receiver buffer state.
    • "Three duplicated ACKs" treated as loss.
  • Flow Control:

    • Sender uses flow control window \(\t{WIN}\) as the effective window size.
    • \(\t{SEQ}+\t{length}< \t{ACK}+\t{WIN}\).
  • Adaptive time-out:

    • Estimate \(\t{SRTT}_{N+1}=0.9\t{SRTT}_N+0.1\t{RTT}_{N+1}\); \(\t{Svar}_{N+1}=0.9\t{Svar}_{N}+0.1|\t{RTT}_{N+1}-\t{SRTT}_{N+1}|\).
    • TCP \(\t{Timeout}_N=\t{SRTT}_N+4\t{Svar}_N\).

  • Congestion: witnessed by network layer, caused by transport layer. Fairness and efficiency matter.
  • Fairness of bandwidth allocation:
    • "Equal per flow" strategy.
    • "Max-min fairness": increase all increasable flows evenly until a new bottleneck is reached.
  • Additive Increase Multiplicative Decrease (AIMD):
    • Converges to an allocation that is efficient and fair.
    • Requires only binary feedback from the network.
    • (Feedback signals: packet loss, packet delay, router indication, etc.)
  • TCP ACK Clocking:
    • Slow ACKs preserve slow link timing at sender.
    • Called congestion window cwnd in TCP.
  • TCP Tahoe: Slow-start solution:
    • Start by doubling cwnd every RTT.
    • When loss timeout tells cwnd is too large, switch to additive increasement.
    • Use threshold cwnd_C/2 to switch to AI, where cwnd_C = 2BD + queue.
    • Set threshold to cwnd/2 after loss.
    • Do slow-start when timeout.
  • Fast retransmit & recovery.
    • Third duplicate ACK (4 in total) as a hint.
    • MD cwnd, and then pretend further duplicate ACKs are expected ones.
  • Explicit Congestion Notification:
    • Router mark the congestion-affected packets in their IP headers.
    • Congestion is detected early, but routers and hosts must be upgraded.
  • Modern TCP:
    • CUBIC: Cubic (based on the elapsed time from last congestion).
    • BBR (Bottleneck Bandwidth and Round-trip propagation time).

Application Layer

  • In OSI view:

    • Session: a series of related network interactions in support of one app task.
    • Presentation: help to identify the type of content, and encode it for transfer.
  • Domain Name Service:

    • A naming service to map between host names and IP addresses.
    • Hierarchical, staring from . (usually omitted).
  • Query ways in DNS resolution:

    • Recursive query: nameserver completes resolution and returns the final answer.
    • Iterative query: nameserver returns the answer or who to contact next.
    • Relieve client's burden & cache for better performance, v.s. easy to build high load servers.
  • Local nameservers:

    • Typically run by IT (enterprise, ISP).
    • Clients contact them via configured DHCP.
  • Root nameservers:

    • Served by 13 server names [a-m].root-servers.net.
    • Root IP addresses are configured.
    • IP anycast to reach the servers (both IPv4 and IPv6 are OK).
  • DNS protocol: same format for query and reply; can ask or answer several questions in one go.

  • DNS security: DDoS attacks, Spoofing attacks.

  • SMTP: "client" to send mails, "server" to receive mails.

    • Use TCP.
    • Three phase: handshaking, transfer of message, closure.
  • IMAP: Internet Mail Access Protocol.

    • Provides retrieval, deletion, folders of stored messages on server.
  • HTTP: text-based commands, headers.

    • GET, HEAD (read page's header only), POST (append), PUT (store), DELETE, TRACE (echo), CONNECT (through a proxy), OPTIONS;
    • 1xx info, 2xx success, 3xx redirection, 4xx client error, 5xx server error.
  • Page Load Time (PLT):

    • Key measure of web performance.
    • Depends on structure of page, HTTP (and TCP) protocol, network RTT and bandwidth, etc.
    • HTTP/1.0's flaw: one TCP connection per web resource. (Multiple TCP connection to the same server, multiple TCP slow-start phases, etc.).
    • Ways to decrease: reduce content size, foster HTTP, caching and proxies, move content closer to client (CDNs).
  • Parallel connections: browser runs multiple HTTP instances in parallel.

  • Persistent connections: make 1 TCP connection to 1 server, used for multiple HTTP requests. (Plus pipelining.)

  • Caching & proxies:

    • Reusing local copy of web pages helps.
    • Validity of local copies are determined locally (with expiry info, heuristic, etc.).
    • Proxy: intermediary between pool of clients and external web servers. Larger cache, security checking, organizational access.
  • Content Delivery Network (CDN): (origin server) + CDN node + CDN DNS server.

    • Higher speed, lower load, better security (against spammers, DDoS), ...
    • Yet need dedicated infrastructure; centralized control/oversight.
  • Peer-to-Peer (P2P):

    • Delivery without dedicated infrastructure or centralized control.

    • Yet no servers to rely on, peer's capability is limited, need active participation, and way to find content.

    • Enabling decentralization by Distributed Hash Trees (DHTs).

posted @ 2026-11-03 12:54  Rainybunny  阅读(41)  评论(1)    收藏  举报