Title: EE 122: Lecture 89
 1EE 122 Lecture 8/9
- Ion Stoica 
 - September 20/25, 2001
 
  2Overview
- TCP/IP architecture 
 - TCP 
 - IP and TCP headers 
 - Connection establishment 
 - Flow control 
 - RTT estimation 
 
  3Before Internet
- Different packet-switching networks (e.g., 
ARPANET, ARPA packet radio)  - only nodes on the same network could communicate
 
  4Goal and Challenges
- Share resources of different packet switching 
networks ? interconnect existing networks  -  but, packet switching networks differ widely 
 - Different services 
 - E.g., degree of reliability 
 - Different interfaces 
 - E.g., length of the packet that can be 
transmitted, address format  - Different protocols 
 - E.g., routing protocols 
 
  5Possible solutions
- Reengineer and develop one global packet 
switching network standard  - Not economically feasible 
 - Have every host implement the protocols of any 
network it wants to communicate with  - Too complex, very high engineering cost
 
  6Solution
- Add an extra layer internetworking layer, also 
called Internet Protocol (IP)  - Hosts implement one higher-level protocol 
 - Networks interconnected by nodes that run the 
same protocol  - Provide the interface between the new protocol 
and every network  
  7Solution
Gateways (routers) 
 8Challenge 1 Different Address Formats
- Provide one common format ? map lower level 
addresses to a common format  - IPv4 address format 32 bit length, hierarchical 
organization  
24
7
Class A
Network
Host
0
16
14
Network
Class B
Host
1
0
8
21
Network
Host
1
1
0
Class C
28
1
1
1
Class D
0
Multicast address
27
1
1
1
Class E
1
Unused
0 
 9Challenge 2 Different Packet Sizes
- Define a maximum packet size over all networks. 
Why not?  - Implement fragmentation/re-assembly 
 - who is doing fragmentation? 
 - who is doing re-assembly? 
 
  10Other Challenges
- Errors ? require end-to-end reliability 
 - Add a transport layer on top of IP 
 - Different (routing) protocols ? coordinate these 
protocols  
  11Transport Layer TCP and UDP
- TCP (Transmission Control Protocol) 
 - Unbounded but finite length messages 
 - Byte streaming 
 - Reliable and in-sequence delivery 
 - Full duplex 
 - Application example file transfer, telnet 
 - UDP (User Datagram Protocol) 
 - Unreliable datagram delivery 
 - Adds multiplexing/demultiplexing to IP 
 - Application example video/audio streaming 
 - Note The need for UDP was the main reason behind 
splitting TCP and IP (at the beginning there were 
only one TCP/IP layer)  
TCP/UDP
Transport Layer
Networking Layer
IP
Link Layer
Physical Layer 
 12Overview
- TCP/IP architecture 
 - TCP 
 - IP and TCP headers 
 - Connection establishment 
 - Flow control 
 - RTT estimation 
 
  13Headers
- IP header ? used for IP routing, fragmentation, 
error detection  - UDP header ? used for multiplexing/demultiplexing,
 data error correction  - TCP header ? used for multiplexing/demultiplexing,
 flow and congestion control  
Receiver
Sender
Application
Application
data
data
TCP UDP
TCP UDP
data
TCP/UDP
data
TCP/UDP
IP
IP
data
TCP/UDP
IP
data
TCP/UDP
IP 
 14IP Header
0
4
8
16
19
31
Version
HLen
TOS
Length
Identification
Flags
Fragment offset
20 bytes
TTL
Protocol
Header checksum
Source address
Destination address
Options (variable)
- Comments 
 - HLen  header length only in 32-bit words (5 lt 
HLen lt 15)  - TOS (Type of Service) now split in 
 - Differentiated Service Field (6 bits) 
 - remaining two bits used by ECN (Early Congestion 
Notification)  - Length  the length of the entire 
datagram/segment header  data  - Flags Dont Fragment (DF) and More Fragments 
(MF)  - Fragment offset  all fragments excepting last 
one contain multiples of 8 bytes  - Header checksum - uses 1s complement 
 
  15TCP Header
0
4
10
16
31
Destination port
Source port
Sequence number
Acknowledgement
Advertised window
Flags
HdrLen
Checksum
Urgent pointer
Options (variable)
- Sequence number, acknowledgement, and advertised 
window  used by sliding-window based flow 
control  - Flags 
 - SYN, FIN  establishing/terminating a TCP 
connection  - ACK  set when Acknowledgement field is valid 
 - URG  urgent data Urgent Pointer says where 
non-urgent data starts  - PUSH  dont wait to fill segment 
 - RESET  abort connection 
 
  16TCP Header (Cont)
- Checksum  1s complement and is computed over 
 - TCP header 
 - TCP data 
 - Pseudo-header (from IP header) 
 - Note breaks the layering! 
 
Source address
Destination address
TCP Segment length
0
Protocol (TCP) 
 17Overview
- TCP/IP architecture 
 - TCP 
 - IP and TCP headers 
 - Connection establishment 
 - Flow control 
 - RTT estimation 
 
  18TCP Connection Establishment
- Three-way handshake 
 - Goal agree on a set of parameters the start 
sequence number for each side  - Staring sequence numbers are random. Why?
 
Server
Client (initiator) 
 19Overview
- TCP/IP architecture 
 - TCP 
 - IP and TCP headers 
 - Connection establishment 
 - Flow control 
 - RTT estimation 
 
  20Basic Problem
- How much traffic do you send? 
 - Two components 
 - Flow control 
 - Make sure that the receiver can receive as fast 
as you send  - Congestion control (see Lecture 10) 
 - Make sure that the network delivers the packets 
to the receiver 
  21TCP Flow Control vs. Link Layer Flow Control
- Flow control runs end-to-end, instead of on the 
same link  - RTT can vary widely 
 - Receivers maximum window size can vary 
 - Because resources allocated to a connection 
varies  - Senders maximum window size varies 
 - Because it is used to throttle back the sender 
where there is congestion (see Lecture 10)  - Others 
 - Sequence numbers counts bytes not packets 
 - Packets usually called segments 
 
  22Flow control Window Size and Throughput
wnd  3
- Sliding-window based flow control 
 - Higher window ? higher throughput 
 - Throughput  wnd/RTT 
 - Need to worry about sequence number wrapping 
 - Remember window size control throughput
 
  23TCP Flow Control
- Receiver window (MaxRcvBuf  maximum buffer size 
at receiver)  - Sender window (MaxSendBuf  maximum buffer size 
at sender)  
AdvertisedWindow  MaxRcvBuffer  (LastByteRcvd  
LastByteRead)
EffectiveWindow  AdvertisedWindow  
(LastByteSent  LastByteAcked)
MaxSendBuffer gt LastByteWritten - LastByteAcked
Sending Application
Receiving Application
LastByteWritten
LastByteRead
LastByteAcked
LastByteSent
NextByteExpected
LastByteRcvd
sequence number increases
sequence number increases 
 24Overview
- TCP/IP architecture 
 - TCP 
 - IP and TCP headers 
 - Connection establishment 
 - Flow control 
 - RTT estimation 
 
  25RTT Estimation
- Use exponential averaging
 
SampleRTT
EstimatedRTT
Time 
 26Problem
- How to differentiate between the real ACK, and 
ACK of the retransmitted packet 
Sender
Receiver
Sender
Receiver
Original Transmission
Original Transmission
SampleRTT
ACK
SampleRTT
Retransmission
Retransmission
ACK 
 27Karn/Partridge Algorithm
- Measure SampleRTT only for original transmissions 
 - Exponential backoff ? for each retransmission, 
double EstimatedRTT 
  28Jacobson/Karels Algorithm
- Problem take into account the variance 
 
  29Summary
- TCP/IP architecture 
 - Add a layer (i.e., the IP layer) to interconnect 
existing networks  - Add a layer (i.e., transport layer) to provide 
multiplexing/demultiplexing, reliability, and 
in-order delivery  - TCP 
 - Connection establishment ? three way handshake 
 - Flow control ? based on sliding window protocol 
 - Congestion control ? next lecture