Title: Network Protocols: Design and Analysis
1Network Protocols Design and Analysis
- Polly Huang
- EE NTU
- http//cc.ee.ntu.edu.tw/phuang
- phuang_at_cc.ee.ntu.edu.tw
2TCP Overview
3What does TCP Provide?
- 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
4Where 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 orientedcan be easier to manage (ex.
firewall config) - has the right features (congestion ctl, etc.)
- widely deployed gt interoperability, understood,
exhaustively studied, pretty good implementations - doing your own protocol is a lot of work
5TCP in a Nutshell
- 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
6TCP Header
Source port
Destination port
Sequence number
Flags
SYN FIN RESET PUSH URG ACK
Acknowledgement
Advertised window
Hdr len
Flags
0
Checksum
Urgent pointer
Options (variable)
Data
7Agenda
- connection setup and teardown
- initial sequence number selection
- passive/active open
- time-wait
- flow control
- congestion control practice and theory
- loss recovery
- security
- performance
8Three-Way Handshake
- why?
- passes buffer sizes
- connection startup
- set up initial seq number
- options
- is someone there?
9Connection Setup States
passive vs. active (and both active!)
(error recovery is not on this figure)
10Initial 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
11Tear-down Packet Exchange
Sender
Receiver
FIN
FIN-ACK
Data write
Data ack
FIN
FIN-ACK
12Connection Tear-down
13Connection 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
14Agenda
- connection setup and teardown
- flow control
- setting window sizes
- Nagles algorithm
- silly window syndrome
- protection against wrap-around
- congestion control practice and theory
- loss recovery
- security
- performance
15Flow 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
16Flow Control
- Why?
- avoid overrunning receiver
- Solutions
- TCP have a sliding window w/how much data can be
outstanding - (OR could have a rate)
17Window Flow Control Sender
effective window
advertised window (from receiver)
Sent but not acked
Not yet sent
Sequence numbers
send buffer
last byte sent
last byte ACKed
18Window Flow Control Receiver
Receive buffer (possible window)
ACKed but not delivered to user
recvd but not ACKed
Sequence numbers
missing data
advertised window
19Window 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)
- Nagles algorithm (RFC-896) send 1st partial
packet, but not more until its ACKed or you have
a full packet
20Problem 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
21Agenda
- connection setup and teardown
- flow control
- congestion control theory
- what and why
- how
- congestion control practice
- loss recovery
- security
- performance
22Congestion 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
23Congestion 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
24Congestion Control Goals
- control network buffer usage
- avoid congestion collapse
- want to fairly allocate network resources
- make good use of network bandwidth power
25Power and Load
knee
- throughput and delay change due to load
- want to optimize power
(From Ramakrishnan90a)
26Fairness
- Also want fairness
- should treat all users equally
- but its not so easy
- what is a user? host, flow, person?
- if n flows through a link, each should get n-1
of the bandwidth - RJs fairness index (Sxi)2/n(Sxi2)
- but what if flows have different needs?
different RTTs?
27Congestion Control Design
- Avoidance or control? (RJ)
- 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 RJs
definition) - How does TCP do it?
- slow start, congestion avoidance, exponential
backoff
28How to Adjust Window?
- 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
29Linear 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 RJ binary feedback DECBit
30Agenda
- connection setup and teardown
- flow control
- congestion control theory
- congestion control practice (in TCP)
- loss recovery
- security
- performance
- gt next sets of slides