Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TCP/IP 101

Buzzvil
March 14, 2018

TCP/IP 101

By Brice

Buzzvil

March 14, 2018
Tweet

More Decks by Buzzvil

Other Decks in Programming

Transcript

  1. Abstraction Layers • A way of hiding the implementation details

    of a particular set of functionality • Allows the separation of concerns to facilitate interoperability and platform independence IP Network Wired Communication Wireless Communication
  2. Encapsulation Protocol Data Unit (PDU) = Header + Service Data

    Unit (SDU) PDU of Layer N + 1 Header of Layer N SDU of Layer N
  3. Network Layers with Protocols Physical Layer: Ethernet 1000BASE-T, 802.11, USB,

    Bluetooth Network Access Layer: Ethernet, MAC, 802.11, L2TP, PPP, PPTP Internet Layer: IPv4, IPv6 Transport Layer: TCP, UDP Application Layer: HTTP
  4. Transport Layer • Transmission Control Protocol (TCP) • Connection-Oriented •

    Flow control • In-order-delivery • Error recovery • Congestion control • User Datagram Protocol (UDP) • None of the above
  5. Transmission Control Protocol (TCP) • TCP segment, sequence number, segment

    size, Acknowledgement (ACK), Round Trip Time (RTT) A B Acknowledgement (M+N) TCP Segment (seq: M, size: N) Round Trip Time (RTT)
  6. TCP Handshake – Connection Establishment A B SYN (K), ACK

    (J+1) SYN (J) ACK (K+1) connect() listen() accept() connect() returns accept() returns LISTEN SYN_SENT ESTABLISHED ESTABLISHED SYN_RECV Connection-Oriented
  7. TCP Handshake – Connection Termination A B ACK (M+1) FIN

    (M) FIN (N) ACK (N+1) ESTABLISHED ESTABLISHED CLOSE_WAIT FIN_WAIT_1 FIN_WAIT_2 TIME_WAIT LAST_ACK CLOSED close() close() CLOSED Connection-Oriented
  8. Buffer to Reorder Out-of-order Delivery A B Window SIze: 4

    1 2 4 3 Application Layer In-order Delivery
  9. Automatic Repeat reQuest (or Query) (ARQ) • Error control method

    that uses ACK and timeouts to achieve reliable data transmission over unreliable service A B Window SIze: 4 1 2 2 Retransmission TimeOut (RTO) 2 2 Error Recovery
  10. Types of ARQ • Stop-and-wait ARQ • Go-Back-N ARQ •

    Selective Repeat ARQ Error Recovery
  11. Selective Repeat ARQ Error Recovery • One timer per frame

    • Receiver keeps the out-of-order frames
  12. Congestion • Internet had its first congestion collapse event on

    October 1986. • 32 Kbps link à 40 bps • What is the problem? 1. A buffer is overflowed 2. New arrival packets are dropped 3. Retransmissions to recover packet losses 4. Drastic reduction of the traffic • How to detect a network congestion? • Packet loss Congestion Control
  13. Terminology • Congestion Window (CWND) • Limits the amount of

    data the TCP can send into network before receiving an ACK • Receiver Window (RWND) • Advertises the amount of data that the destination side can receive • Slow Start Threshold (ssthresh) • A threshold between slow-start mode and congestion avoidance mode • Rount Trip Time (RTT) • A time delay between sending a signal and receiving its ack Congestion Control
  14. Slow Start • Slow-start (cwnd <= ssthresh) • cwnd =

    1 MSS (Maximum segment size) • When ack is received: • cwnd += 1 MSS • It increase cwnd exponentially on each RTT • cwnd *= 2 (on each RTT) • Congestion Avoidance and Control, Van Jacobson, 1988 Congestion Control
  15. Congestion Avoidance • Congestion avoidance (cwnd > ssthresh) • Additive

    Increase, Multiplicative Decrease (AIMD) • When ack is received: • cwnd += MSS * MSS / cwnd • Else: • ssthresh = cwnd / 2 • cwnd = 1 MSS • It increase cwnd linearly on each RTT • cwnd += MSS • Congestion Avoidance and Control, Van Jacobson, 1988 Congestion Control
  16. Fast Retransmission • 3 duplicate ACK means a congestion is

    occurred • TCP Tahoe, 1988 Retransmission TimeOut (RTO) Congestion Control
  17. Fast Recovery • If 3 dup ack is received •

    ssthresh = cwnd / 2 • cwnd = ssthresh • move to congestion avoidance state • If ack times out • ssthresh = cwnd / 2 • cwnd = 1 MSS • move to slow start state • TCP Reno, 1990 Congestion Control
  18. TCP Variants Name By When New Features TCP Vint Cerf

    and Bob Kahn 1973 Ack Congestion Avoidance and Control Van Jacobson 1988 Congstion Window, Slow Start, Congestion Avoidance TCP Tahoe 4.3 BSD Tahoe 1988 Fast Retransmission TCP Reno 4.3 BSD Reno 1990 Fast Recovery TCP Vegas Lawrence Brakmo et al. 1994 Detect congestion based RTT TCP CUBIC Sangtae Ha et al. 2008 window size is cubic function TCP BBR Van Jacobson et al, Google 2016 Model-based Congestion Control
  19. Packet Loss is not Always Congestion • Shallow Queue •

    Overreact à Increase queue size to reduce packet loss • Deep Queue • Let the server know the packet loss late • Bufferbloat (2011) à Priority queue, threshold, track the time a packet stays in queue • All approaches: Increase the accuracy of packet loss as an indicator of congestion 2 Packet/s
  20. Review • Network Layers • Encapsulation and decapsulation • Internet

    Layer • IP • Transport Layer • TCP • Connection-oriented • Flow control • In-order delivery • Error recovery • Congestion control • Slow start / congestion avoidance / fast retransmission / fast recovery • Loss-based congestion control: TCP Tahoe, Reno, Vegas … • Model-based congestion control: TCP BBR
  21. References • Google • Wikipedia • CLOSE_WAIT & TIME_WAIT 최종

    분석 • Van Jacobson’s Congestion Avoidance and Control • TCP Flow Controls • BBR: Congestion-Based Congestion Control