|
|
|
Magda El Zarki |
|
Professor, ICS |
|
UC, Irvine |
|
|
|
|
Ch 1: Introduction |
|
Ch 2:Bridges |
|
Ch 3:Routers |
|
Ch 4: Transport Protocols |
|
|
|
|
|
Introduction |
|
Transport Layer Protocols: |
|
Transport Control Protocol (TCP) and |
|
User Datagram Protocol (UDP) |
|
|
|
|
|
|
|
|
There are two kinds of Transport Protocols used
in the Internet: |
|
UDP: User Datagram Protocol |
|
TCP: Transport Control Protocol |
|
They both operate over IP. |
|
They both use PORT numbers for connecting to
applications. |
|
|
|
|
|
The concatenation of IP address and Port Number
provides a unique identifier for transferring information between a source
and a destination. This is known as a socket, the door between an
application and the underlying transport system. |
|
Each application service is allocated a unique
port number: |
|
FTP - 21 |
|
Telnet - 23 |
|
Domain Name Server - 53, etc. |
|
|
|
|
There are 1023 port numbers available for
application services. |
|
Not all port numbers are well known, in that
case a request is sent to a catch all port number. The response packet
contains the correct port number. |
|
|
|
|
|
The tuple <Source Port, Destination Port>
is used in the addressing of the Transport Data Unit (TDU). |
|
Most applications that require a reliable
transport mechanism use TCP, otherwise UDP is used because it is simpler. |
|
UDP is the preferred choice for real-time
services as it does not incorporate
a lot of the overhead that is associated with TCP. |
|
|
|
|
|
Uses only 8 bytes of header: |
|
2 bytes for source port |
|
2 bytes for destination port |
|
2 bytes for length of data unit |
|
2 bytes for checksum (covers IP addresses and IP
length field included) |
|
|
|
|
Provides connectionless service - no sequencing,
no end to end error control (only error detection, includes data), no flow
control. |
|
NFS, some routing protocols (e.g., RIP), RTP
(Real-Time Protocol), TFTP, etc., use UDP as it is simple and fast if
reliability is not an issue. |
|
IP will do fragmentation if the UDP packet is
too large for the path (i.e., > path MTU). |
|
|
|
|
A UDP packet can be as large as the max. IP packet minus the headers.
Generally the application will limit the packet size. |
|
UDP leaves most of the work to the upper
(application) layer. This can slow things down, as ACKs, re-ordering, etc.,
has to be done by the application. |
|
|
|
|
|
20 byte header (without options) |
|
Header plus data referred to as a transport
segment |
|
Segment size chosen to accommodate the smallest
IP packet size on path to avoid fragmentation |
|
|
|
|
|
TCP goes through a 3 phase set-up: |
|
Connection set-up (3 way hand-shake): SYN, SYN
ACK, ACK |
|
Data transfer |
|
Connection tear down: FIN, ACK, FIN, ACK (two
way or one way) |
|
|
|
|
TCP is connection oriented - uses sequence
numbers (always increasing, numbers not consecutive, reflect the number of
bytes not segments!). For example: if TCP wants to send 2000 bytes and
sends them in two segments of 1000 bytes each, if first segment has
sequence no 102, then sequence number of second segment will be 102+1000=
1102. |
|
The ACKs on the other hand reflect the sequence
number of the next byte that the receiver is expecting. If the receiver
received segment with sequence number 102 of length 1000, then ACK will use
number: 102+ 1000 = 1102. |
|
|
|
|
The RFC does not specify what to do with out of
order packets. TCP will only acknowledge ordered transmissions, but the
question is: should it keep out of order packets in its buffer or just
discard them? The easiest implementation is to discard and wait for all
packets to arrive in order. |
|
An ACK is sent in response to an out of order
packet, it contains the “expected” sequence number. |
|
|
|
|
Group ACKs: TCP will use group ACKs, also
referred to as delayed ACKs. in otherwords, it will not ACK each received
segment, it will wait for a short while (differs on each system, 200msecs
for WANs, 20msec for LANs) and then ACK all segments (max. 2 segments) that
it has received so far. |
|
It does that so that: 1) it can do group ACKing
which is more efficient, and 2) it hopes to be able to piggyback an ACK on
data going in the reverse direction. If there is data in the buffer that
needs to be sent, it will not do a delayed ACK. Only uses delayed ACK if
send buffer is empty. |
|
|
|
|
Uses error detection and recovery - ACKs and
retransmissions. If an ACK is not received before a timer expires, the
segment is resent. |
|
The retransmission timer is not a static value.
It is calculated based upon current network status. The timer must be
greater than the roundtrip delay! |
|
|
|
|
Sliding window is used as the flow control
technique (matching of sender and receiver data rates): Each end system
will advertise the largest window it is willing to receive without ACKs,
i.e., packets that can be outstanding between source and destination. |
|
This value is dynamic, it changes based upon how
fast the receiver can read the arriving data. It is always advertised in
the messages sent from the destination to the source. Note however that the
TCP congestion control mechanism does kick in too and affects the amount of
data that can be sent. |
|
|
|
|
If an ACK packet comes back with a receiver
window size of “0”, that means that the destination wants the source to
hold off with transmission. In this case the sending host can only send
segments with 1 byte of data. This is to keep the connection alive between
the two ends, i.e., keep ACKs flowing from destination to source indicating
the window size. |
|
|
|
|
TCP has imbedded congestion control. When ACKs
come back with a delay (i.e. timers
expire) the window size is reduced by the sender. The sender will only send
data = min{congestion window, receiver (or sliding) window}. |
|
TCP also uses something called slow start: The
sender starts off with only sending 1 (in some cases 2) packet, then
doubles that if the ACK comes back before the retransmit timer expires. It
keeps on doubling until it reaches a threshold then goes into a linear
increase (i.e., adds one to the window size). If at anytime an ACK is
delayed, it sets the threshold to half the current congestion window size
and starts again with slow start. |
|
|
|
|
All applications that are concerned with
reliable transport use TCP |
|
SMTP (email), ftp, RIP, http, etc. use TCP. |
|
TCP hides the underlying network from the
application: it segments,it re-orders packets, does error control and
handles flow matching and congestion control. |
|