Pipelining design question: when to stop?


Question: What happens if network layer delivers data faster than application layer removes data from socket?

TCP Flow Control

Idea: receiver controls sender so sender won’t overflow receiver’s buffer by transmitting too much and too fast.

  • Receiver “advertises” free buffer space in rwnd field in TCP header.
  • Sender limits amount of unACKed packets based on received rwnd.
  • This guarantees receiver buffer will not overflow.

Flow Control Algorithm1: Go-Back-N

  • Receiver sends acks only for correctly received packets.
  • Receiver discards out-of-order packets.
  • Sender maintains only one timer for the earliest unACKed packet and sends whole N packets for retransmission on timeout.

Go-Back-N Implementation

Flow Control Algorithm2: Selective Repeat

  • Receiver individually acks all received packets.
  • Receiver buffers packets as needed for in-order delivery to upper layer.
  • Sender maintains timers for each unACKed packet.

Selective Repeat Implementation

Transmission Control Procol (TCP)

  • point-to-point
    • one sender and one receiver
  • reliable and in-order byte-stream
  • full duplex data
    • bi-directional data flow in the same conenction
  • cumulative ACKs
  • pipelining
    • TCP congestion control and flow control set window size
  • connection-oriented
    • handshaking initializes sender and receiver state before data exchange
  • flow controlled
    • sender will not overwhelm receiver

TCP Format

  • sequence number
    • byte stream number of first byte in segment’s data
      • Current seuqnce number is 10 and the segment size is 20
      • Then, next sequence number is 31
  • acknowledgement
    • sequence number of next byte is expected from other side
    • cumulative ACK

TCP Sequence Numbers and ACK

  • Bi-directional data flow between host A and B.
  • Host A wants segment with sequence number = 79 from B, thus sending ACK=79.
  • Host B receives segement with sequence number = 42, so it sends ack number = 43 to request Host A for next segment.

TCP Retransmission Scenarios

  1. Lost ACK scenario

  2. Premature timeout scenario

  3. Cumulative ACK covers for earlier lost ACK: