300 likes | 467 Views
Network Protocols: Design and Analysis. Polly Huang EE NTU http://cc.ee.ntu.edu.tw/~phuang phuang@cc.ee.ntu.edu.tw. TCP Overview. Connection establishment: Connectionless communication: Congestion avoidance: Differentiated services: Duplicate packet detection: Flow control: .
E N D
Network Protocols: Design and Analysis Polly Huang EE NTU http://cc.ee.ntu.edu.tw/~phuang phuang@cc.ee.ntu.edu.tw
Connection establishment: Connectionless communication: Congestion avoidance: Differentiated services: Duplicate packet detection: Flow control: loss recovery: message or record boundaries: ordered data delivery to the application: out-of-order data delivery to the application: quality-of-service: urgent data indication: What does TCP Provide?
Where and Why is TCP Used? • where: anywhere reliable communication is needed • file transfer/ftp, http, p2p; e-mail smpt; remote login/telnet; db transfer/dns; some real audio • why? • connection oriented—can be easier to manage (ex. firewall config) • has the right features (congestion ctl, etc.) • widely deployed => interoperability, understood, exhaustively studied, pretty good implementations • doing your own protocol is a lot of work
abstraction: reliable ordered point-to-point byte-stream mechanisms window-based flow control sequence numbers/ordering, 3-way handshake reliability (ACK, retx policies) congestion control RTT estimation TCP in a Nutshell
TCP Header Source port Destination port Sequence number Flags: SYN FIN RESET PUSH URG ACK Acknowledgement Advertised window Flags Hdr len 0 Checksum Urgent pointer Options (variable) Data
Agenda • connection setup and teardown • initial sequence number selection • passive/active open • time-wait • flow control • congestion control practice and theory • loss recovery • security • performance
A B SYN SYN+ACK-A ACK-B Three-Way Handshake • why? • passes buffer sizes • connection startup • set up initial seq number • options • is someone there?
Connection Setup States passive vs. active (and both active!) (error recovery is not on this figure)
Initial Sequence Number Selection • Why not just start at 0? • want to avoid accidental replay of old packets (tcp connection: src + dest ip address + port) • Approach: • randomly chosen • OR semi-sequentally
Tear-down Packet Exchange Sender Receiver FIN FIN-ACK Data write Data ack FIN FIN-ACK
Connection Tear-down • either side can close • or one side can close and the other stay open • one side must maintain state (TIME_WAIT) for 2 minutes, why? • suppress old packets
Agenda • connection setup and teardown • flow control • setting window sizes • Nagle’s algorithm • silly window syndrome • protection against wrap-around • congestion control practice and theory • loss recovery • security • performance
Flow Control • Window sizes are passed in every packet • beware: implementations often have separate TCP and socket buffers • effective window is the minimum of the two
Flow Control • Why? • avoid overrunning receiver • Solutions • TCP have a sliding window w/how much data can be outstanding • (OR could have a rate)
Window Flow Control: Sender effective window advertised window (from receiver) Sent but not acked Not yet sent Sequence numbers send buffer last byte ACKed last byte sent
Window Flow Control: Receiver Receive buffer (possible window) ACKed but not delivered to user recv’d but not ACKed Sequence numbers missing data advertised window
Window Advancement Issues • What if window is full? • sender sends full window, but ACK is lost • sender sends 1-byte probes (solicits new ACK) • Silly window syndrome (RFC-813) • receiver dribbles out small window advances • Silly Window Avoidance: delay ACKing (receiver) or sending small segments (sender) • Sender who dribbles out data (like telnet) • Nagle’s algorithm (RFC-896): send 1st partial packet, but not more until it’s ACKed or you have a full packet
Problem: Rapid Wrap-Around • Wraparound time vs. Link speed: • 1.5Mbps: 6.4 hours • 10Mbps: 57 minutes • 45Mbps: 13 minutes • 100Mbps: 6 minutes • 622Mbps: 55 seconds • 1.2Gbps: 28 seconds • Protection Against Wrapped Sequences (PAWS extension): Use timestamp to distinguish sequence number wraparound
Agenda • connection setup and teardown • flow control • congestion control theory • what and why • how • congestion control practice • loss recovery • security • performance
10 Mbps 1.5 Mbps 10 Mbps Congestion Collapse • If both sources send full speed, the router is completely overwhelmed • congestion collapse: senders lose data from congestion and they resend, causing more congestion (can be self-reinforcing) • has been observed many times
Congestion Control vs. Flow Control • What does flow control do? • avoids overrunning the receiver • What does congestion control do? • avoid overrunning router buffers; avoid saturating the network • What mechanism do they use? • both use windows: (flow control) wnd, (congestion control) cwnd: actual window used is the MIN of wnd and cwnd
Congestion Control Goals • control network buffer usage • avoid congestion collapse • want to fairly allocate network resources • make good use of network bandwidth: power
throughput delay (throughput) power := load load delay Power and Load knee • throughput and delay change due to load • want to optimize power (From [Ramakrishnan90a])
Fairness • Also want fairness • should treat all users equally • but it’s not so easy • what is a user? host, flow, person? • if n flows through a link, each should get n-1 of the bandwidth • R&J’s fairness index: (Sxi)2/n(Sxi2) • but what if flows have different needs? different RTTs?
Congestion Control Design • Avoidance or control? (R&J:) • avoidance keeps system at knee of curve • requires some congestion signal • control responds to loss after the fact • TCP • Which is TCP? • congestion control (according to R&J’s definition) • How does TCP do it? • slow start, congestion avoidance, exponential backoff
When to increase/decrease? A control theory problem observe network reduce window if congested increase window if not congested Constraints: efficency fairness stability (too much oscillation is bad) out-of-date info RTT is fundamental limit to how quickly you can react How to Adjust Window?
Linear Control Xi(t + 1) = ai(t,f) + bi(t,f) Xi(t) • Formulation allows for the feedback signal: • to change additively: ai(t) • to change multiplicatively: bi(t) • can consider feedback • What does TCP do and why? • AIMD: additive increase, multiplicative decrease • Types of feedback in Internet? • packet loss or ECN (explicit congestion notification) or in R&J “binary feedback” DECBit
Agenda • connection setup and teardown • flow control • congestion control theory • congestion control practice (in TCP) • loss recovery • security • performance => next sets of slides