Professional Documents
Culture Documents
Networks
Dr. Mohamed Saad
Department of Computer Engineering
University of Sharjah
msaad@sharjah.ac.ae
• Addressing, flow control and congestion control are also similar in the
network and transport layers.
• Answer:
– The transport layer protocols run entirely on the users’ (hosts’)
machines, while network layer protocols run on the routers (core
of the network operated by the carrier).
– Users have no control over the network layer, they cannot improve
their service by using better routers or putting more error handling
in the data link layer. The only possibility is to improve the QoS
by performing end-to-end congestion control, flow control and error
control at the transport layer.
Application Application
(or session) Application/transport (or session)
layer interface layer
Transport
address
TPDU
Transport Transport
entity Transport entity
protocol
Network
address Transport/network
Network layer interface Network layer
• Transport entity: hardware and/or software within the transport layer that does the
work.
• Transport protocol data unit (TPDU): messages sent from transport entity to transport
entity.
TPDU payload
Packet payload
Frame payload
Physical
communication channel Host
(a) (b)
At the data link layer, two routers communicate directly via a direct (point-to-point)
physical channel. At the transport layer, this physical channel is replaced by the entire
subnet.
Addressing
• In the Internet, end points are usually called ports, and transport address
of an end point is called port number.
• We will use the generic term Transport Service Access Point . Similarly,
end points in the network layer are called Network Service Access Points.
Addressing (contd.)
Host 1 Host 2
Server 1 Server 2
Application TSAP 1208 Application
process layer
Transport
Transport layer TSAP 1522 TSAP1836
connection
NSAP Network
layer NSAP
Data link
layer
Physical
layer
• The purpose of having a TSAP is that, in some networks, each computer has a single
NSAP, so some way is needed to distinguish between multiple transport end points that
share that NSAP.
Connection Establishment
Three-Way Handshake
Host 1 Host 2 Host 1 Host 2
Old duplicate
CR (
s eq = CR (s
x) eq = x
)
= x) = x)
CK CK
Time
A A
= y, = y,
(s eq (seq
ACK ACK
DAT
A (seq REJEC
= x, T (AC
ACK K = y)
= y)
(a) (b)
Host 1 Host 2
CR (
seq
= x)
Old duplicate
)
=x
CK
y, A
q=
K (se
AC
DAT
A (s
ACK eq = x,
= z)
Old duplicate
REJ
ECT
(ACK
= y)
(c)
Connection Release
• Asymmetric release: when one party hangs up, the connection is broken.
Host 1 Host 2
CR
ACK
Time DATA
DATA
DR
No data are
delivered after
a disconnect
request
Send DR Send DR
+ start timer
DR DR + start timer
Release Release
connection connection
(a) (b)
(c) (d)
• Second DR lost (c): Host 1 times out and sends DR all over again.
• The sending and receiving transport entities exchange information in form segments ⇒
in the context of TCP the TPDU is called segment.
• A TCP segment consists of a fixed 20-byte header (plus an optional part), followed by
zero or more data bytes.
• Two limits restrict the segment size:
– the TCP segment must fit in the 65,515-byte IP payload; and
– it must fit in the network’s maximum transfer unit (MTU). In practice the MTU is
1500 bytes.
• In what follows we will describe:
– The TCP segment header.
– The TCP transmission policy (sliding window protocol).
– TCP congestion control (mostly next lecture).
Sequence number
Acknowledgement number
TCP U A P R S F
header R C S S Y I Window size
length G K H T N N
Data (optional)
• Every segment begins with a 20-bytes header. The fixed header may be followed by
header options. After the options, if any, 65,535-20-20 data bytes may follow (why?)
• The source port and the destination port identify the local end points of a connection.
– Some port numbers are well-known and are reserved for standard services. For
example:
• The Sequence number specifies the the first byte in the current segment.
• The Acknowledgment number specifies the sequence number of the next byte expected.
• The TCP header length specifies how many 32-byte words are contained in the TCP
header. (Why do we need this field?)
• URG = 1 → if the Urgent pointer is in use. The Urgent pointer indicates a byte offset
from the current sequence number at which urgent data are to be found.
• ACK = 1 → indicates that the Acknowledgment number is valid. If ACK = 0, the
segment does not contain an acknowledgement.
• PSH = 1 → indicates PUSHed data. The receiver is kindly requested to deliver the
data to the application upon arrival and not buffer it until a full buffer has been received
(which it might otherwise do.....why?).
• RST = 1 → used to reset a connection that has become confused due to a host crash
or some other reason. It is also used to reject an invalid segment, or refuse an attempt
to open a connection.
• The Window size indicates the number of bytes the sender is allowed
to transmit before an ACK is received. In other words, the Window
size indicates the number of outstanding unacknowledged bytes in
transmission.
• The receiver announces also a variable window size with every ACK.
(Note that dynamically changing the window size provides some sort of
flow control).
Window Management
2K
ACK = 2048 WIN = 2048
Application
does a 2K
write 2K SEQ = 2048
Full
Sender is Application
IN = 0
blocked 4096 W reads 2K
ACK =
= 2048
40 96 WIN
ACK =
2K
Sender may
send up to 2K
1K
SEQ =
4096
1K 2K
• When the receiver window = 0, the sender may not normally send
segments. There are two exceptions:
– urgent data, e.g., disconnection request;
– the sender may send a 1-byte segment to make the receiver announce
the next byte and window size. The TCP standard explicitly provides
this option to prevent deadlock if a window announcement ever gets
lost.
Nagle’s Algorithm
1 Byte
Receiver's buffer is full
Clark’s Solution
• Nagle’s algorithm and Clark’s solution to the silly window syndrome are
complementary.
– Nagle was trying to prevent senders from sending 1 byte at a time, Clark was trying
to solve the problem resulting from the receiver reading data 1 byte at a time.
Retransmission Timer
0.3 T 0.3 T1 T2
0.2 0.2
Probability
Probability
0.1 0.1
0 0
0 10 20 30 40 50 0 10 20 30 40 50
Round-trip time (msec) Round-trip time (msec)
(a) (b)
• For every segment sent, TCP records the (instantaneous) time needed for ACK come
in, say RT T .
• RT T (the estimated average round-trip time) is updated according to
RT T = αRT T + (1 − α)RT T,
where α is a smoothing factor that determines how much weight is given to old value.
Typically, α = 7/8.
• When the ACK comes in, the difference between the average and instantaneous RTTs,
D = |RT T − RT T |, is computed. A smoothed value of this difference, D, is
maintained by the update formula: D = αD + (1 − α)D.
Note that D is a cheap estimator of the standard deviation of RT T . Then
Timeout = RT T + 4 × D.
Persistence Timer
Congestion Control
• Congestion control is to dynamically adjust the sender transmission rate as to avoid
congesting the network links.
• Flow control vs. congestion control:
Transmission
rate adjustment
Transmission
network Internal
congestion
Small-capacity Large-capacity
receiver receiver
(a) (b)
Transmission
rate adjustment
Transmission
network Internal
congestion
Small-capacity Large-capacity
receiver receiver
(a) (b)
• Example:
– If the receiver says “send 8 KB” but the sender knows that bursts of more than 4
KB will congest the network, it sends only 4 KB.
– If the receiver says “send 8 KB” and the sender knows that bursts of up to 32 KB
will not congest the network, it sends the full 8 KB.
• The sender initializes the congestion window to the size of one maximum segment in
use on the connection. The sender then sends one segment.
• Additive increase:
– If this segment is acknowledged before timeout, the sender adds one segment’s
worth of bytes to the congestion window to make it 2 segments.
– If these 2 segments are acknowledged before timeout, the congestion window is
increased to 3 segments, . . . etc.
– The congestion window is increased by one maximum segment every round-trip time,
i.e., the congestion window increases linearly.
• Multiplicative decrease:
– If a segment is lost (detected by timeout or NAK), the congestion window is reduced
by half.
• AIMD leads to the TCP ”sawtooth”!
Slow Start
• The sender initializes the congestion window to the size of one maximum segment in
use on the connection.
• It then sends one maximum segment.
• If this segment is acknowledged before timeout, the sender adds one segment’s worth
of bytes to the congestion window to make it 2 segments.
• If these 2 segments are acknowledged before timeout, the congestion window is increased
to 4 segments, . . . etc.
⇒ The congestion window is increased by one maximum segment for every segment
acknowledged. In other words, the congestion window is doubled every round-trip time.
• The congestion window increases exponentially. This start is, thus, not slow at all!
• The name slow start comes from the fact that the congestion window is initialized to
only one segment.
TCP Tahoe
• Algorithm:
– When a timeout occurs, the threshold is set to half of the current congestion window,
and the congestion window is reset to one maximum segment.
– Slow start is then used to determine what the network can handle.
– The (slow start) exponential growth stops when congestion window = threshold.
From that point, the congestion window is increased (linearly) by one segment every
round-trip time.
Example
44
Timeout
40
36
Threshold
32
Congestion window (kilobytes)
28
24 Threshold
20
16
12
0
0 2 4 6 8 10 12 14 16 18 20 22 24
Transmission number
Example (contd.)
• TCP Vegas attempts to maintain the right amount of extra data in the
networks (i.e., the node buffers).
– When there is too much data in the queues/buffers, then the delay will increase,
and congestion may happen.
– When there is no data in the queues/buffers, then there is a risk that the available
BW is not fully utilized.
• Definitions:
– CW : current congestion window.
– BaseRT T : minimum (“congestion-free”) round-trip time. In practice, TCP Vegas
sets BaseRT T to the smallest RT T measured so far; it is commonly the RT T
of the first packet sent by the connection, before the router queues increase due to
traffic generated by this flow.
– RT T : actual (“with congestion”) round-trip time.
– ExpectedRate = CW/BaseRT T : data rate achieved when there is no
congestion, i.e., when there is no segments waiting in the intermediate queues.
– ActualRate = CW/RT T : actual data rate, with congestion.
– Dif f = ExpectedRate − ActualRate, i.e.,
• Note also that if there is congestion (i.e., too many packets in the queues),
RT T becomes too large (and Dif f becomes too large accordingly).
Therefore, CW needs to decreased. This is triggered by the β-threshold.
• This graph is taken from L.L. Peterson and B.S. Davie. “Computer Networks: A
Systems Approach”, Morgan Kaufmann, 2003.
• Top figure: change of congestion window with time.
• Bottom figure: ExpectedRate (colored line), ActualRate (black line). The shaded
area is the region between the α and β thresholds.
• Recent literature indicates that TCP Vegas is optimal in the sense that it maximzies
the total “satisfaction” of all connections (under some conditions).
• Interested in learning more about this (advanced topic):
– S.H. Low, L.L. Peterson and L. Wang, “Understanding Vegas: A Duality Model”,
Journal of the ACM, vol. 49, no. 2, pp. 2072–235, March 2002.
– Or, do a masters at UOS, and take my course “0403544 – Computer Networks
Design and Performance”.
UDP Header
32 Bits
• The UDP header specifies the source port and destination port.
• When a UDP segment arrives, its payload is handed to the application process attached
to the destination port.
• The source port is needed if a reply must be sent back to the sender.
• In fact, the main value of having UDP over just using raw IP is the addition of the
source and destination ports. Otherwise, the receiving transport layer would not know
to which application to hand the packet.
• UDP length field specifies the length of the UDP segment (header and data).
• UDP Checksum field is optional.
• Flow control
• Error control
Applications of UDP
UDP
OS
IP UDP payload
Kernel
Ethernet IP payload
Ethernet payload
(a) (b)
RTP (contd.)
Thanks