Transport Layer Protocols Overview
Transport Layer Protocols Overview
UDP
UDP is an unreliable connectionless transport-layer protocol used for its simplicity
andefficiency in applications where error control can be provided by the
application-layerprocess.
TCP
TCP is a reliable connection-oriented protocol that can be used in any
applicationwhere reliability is important.
SCTP
SCTP is a new transport-layer protocol that combines the features of UDP and
TCP.
Port Numbers
1. A transport-layer protocol creates a process-to-process communication.
2. These protocols use port numbers to accomplish this.
3. Port numbers provide end- to-end addresses at the transport layer and allow
multiplexing and demultiplexing at this layer.
UDP Services
1. Process-to-Process Communication
2. Connectionless Services
3. Flow Control
4. Error Control
5. Congestion Control
6. Encapsulation and Decapsulation
7. Queuing
8. Multiplexing and Demultiplexing
1. Process-to-Process Communication
UDP provides process-to-process communication using socket addresses.
2. Connectionless Services
• UDP provides a connectionless service.
• Eachuser datagram sent by UDP is an independent datagram.
• The user datagrams are not numbered.
• There is no connection establishment and no connection termination.
• Each user datagram can travel on a different path.
• One of the ramifications of being connectionless is that the process that uses
• Only those processes sending short messages, messages less than65,507
bytes (65,535 minus 8 bytes for the UDP header and minus 20 bytes for the
IP header), can use UDP.
3. Flow Control
• There is no flow control, and hence no window mechanism.
• The receiver may overflow with incoming messages.
4. Error Control
• There is no error control mechanism in UDP except for the checksum.
• Sender does not know if a message has been lost or duplicated.
• When the receiverdetects an error through the checksum, the user datagram
is silently discarded.
Checksum
o UDP checksum calculationincludes three sections:
7. Queuing
• InUDP, queues are associated with ports.
• At the client site, when a process starts, it requests a port number from the
operatingsystem.
• Some implementations create both an incoming and an outgoing
queueassociated with each process. Other implementations create only an
incoming queueassociated with each process.
UDP Applications
1. UDP is suitable for a process that requires simple request-response
communication.
Note: It is not usually used for a processsuch as FTP that needs to send bulk
data .
2. UDP is suitable for a process with internal flow- and error-control
mechanisms.
For example, the Trivial File Transfer Protocol (TFTP) process includes
flow anderror control.
3. UDP is a suitable transport protocol for multicasting. Multicasting capability
isembedded in the UDP software but not in the TCP software.
4. UDP is used for management processes such as SNMP(Simple Network
Management Protocol)
5. UDP is used for some route updating protocols such as Routing Information
Protocol(RIP)
6. UDP is normally used for interactive real-time applications that cannot
tolerateuneven delay between sections of a received message.
TRANSMISSION CONTROL PROTOCOL(TCP)
• Transmission Control Protocol (TCP) is a connection-oriented, reliable
protocol.
• It defines connection establishment, data transfer, and connection
teardownphases to provide a connection-oriented service.
• TCP uses a combination ofGBN and SR protocols to provide reliability.
• TCP is the most commontransport-layer protocol in the Internet.
TCP Services 1. Process-to-Process Communication
As with UDP, TCP provides process-to-process communication using
port numbers.
2. Stream Delivery Service
• TCPis a stream-oriented protocol.
• TCPallows the sending process to deliver data as a stream ofbytes and
allows the receiving process to obtain data as a stream of bytes.
• The sending process produces (writes to) the stream and thereceiving
process consumes (reads from) it.
Segments
Segment Format
1. Source port address -This is a 16-bit field that defines the port number of
theapplication program in the host that is sending the segment.
2. Destination port address - This is a 16-bit field that defines the port
number of theapplication program in the host that is receiving the segment.
3. Sequence number- This 32-bit field defines the number assigned to the first
byte ofdata contained in this segment.
4. Acknowledgment number- This 32-bit field defines the byte number that
thereceiver of the segment is expecting to receive from the other party.
5. Header length - This 4-bit field indicates the number of 4-byte words in the
TCPheader. The length of the header can be between 20 and 60 bytes.
6. Control - This field defines 6 different control bits or [Link] bits enable
flow control, connectionestablishment and termination, connection abortion,
and the mode of datatransfer in TCP.
7. Window size - This field defines the window size of the sending TCP in
bytes. Maximum size of thewindow is 65,535 bytes.
8. Checksum - This 16-bit field contains the checksum.
9. Urgent pointer - This 16-bit field, which is valid only if the urgent flag is
set, isused when the segment contains urgent data.
10. Options- There can be up to 40 bytes of optional information in the TCP
header.
Error Control
• TCP is a reliable transport-layer protocol. This means that an application
program thatdelivers a stream of data to TCP relies on TCP to deliver the
entire stream to the applicationprogram on the other end in order, without
error, and without any part lost orduplicated.
• TCP provides reliability using error control.
• Error control includes mechanisms fordetecting and resending corrupted
segments, resending lost segments, storing out-ofordersegments until
missing segments arrive, and detecting and discarding duplicatedsegments.
• Error control in TCP is achieved through the use of three simple tools:
1. Checksum
2. Acknowledgment
3. time-out.
Checksum
• Each segment includes a checksum field, which is used to check for a
corrupted segment.
• If a segment is corrupted, as detected by an invalid checksum, the segment is
discardedby the destination TCP and is considered as lost.
• TCP uses a 16-bit checksumthat is mandatory in every segment.
Acknowledgment
• TCP uses acknowledgments to confirm the receipt of data segments.
• Control segmentsthat carry no data, but consume a sequence number, are
also acknowledged.
• ACK segmentsare never acknowledged.
• Acknowledgment Type
1. Cumulative Acknowledgment (ACK) - TCP acknowledges receipt of
segments cumulatively. The receiver advertises the next byte it
expects toreceive, ignoring all segments received and stored out of
order.
• Selective Acknowledgment (SACK) - A SACKreports a block of bytes that
is out of order, and also a block of bytes that is duplicated,
Generating Acknowledgments
1. When end A sends a data segment to end B, it must include (piggyback) an
acknowledgment that gives the next sequence number it expects to receive.
2. The receiver needs to delay sending an ACK segment if there is only
oneoutstandingin-order segment.
3. When a segment arrives with a sequence number that is expected by the
receiver,and the previous in-order segment has not been acknowledged, the
receiver immediatelysends an ACK segment.
4. When a segment arrives with an out-of-order sequence number that is
higher thanexpected, the receiver immediately sends an ACK segment
announcing thesequence number of the next expected segment.
5. When a missing segment arrives, the receiver sends an ACK segment to
announcethe next sequence number expected.
6. If a duplicate segment arrives, the receiver discards the segment, but
immediatelysends an acknowledgment indicating the next in-order segment
expected.
• The idea of TCP congestion control is for each source to determine how
much capacity is available in the network, so that it knows how many
packets it can safely have in transit.
• Once a given source has this many packets in transit, it uses the arrival of
an ACK as a signal that one of its packets has left the network, and that it
is therefore safe to insert a new packet into the network without adding to
the level of congestion.
• By using ACKs to pace the transmission of packets, TCP is said to be
self-clocking.
How does the source determine that the network is congested and that it
should decrease the congestion window?
• TCP interprets timeouts as a sign of congestion and reduces the rate at which
it is transmitting.
• Specifically, each time a timeout occurs, the source sets CongestionWindow
to half of its previous value.
• This halving of the CongestionWindow for each timeout corresponds to the
―multiplicative decreaseǁ part of AIMD.
• Although CongestionWindow is defined in terms of bytes, it is easiest to
understand multiplicative decrease if we think in terms of whole packets.
• For example, suppose the CongestionWindow is currently set to 16 packets.
If a loss is detected, CongestionWindow is set to 8.
• Additional losses cause CongestionWindow to be reduced to 4, then 2, and
finally to 1 packet.
• CongestionWindow is not allowed to fall below the size of a single packet,
or in TCP terminology, the maximum segment size (MSS).
• We also need to be able to increase the congestion window to take advantage
of newly available capacity in the network.
• This is the ―additive increaseǁ part of AIMD, and it works as follows.
• Every time the source successfully sends a CongestionWindow’s worth of
packets—that is, each packet sent out during the last RTT has been
ACKed—it adds the equivalent of one packet to CongestionWindow.
• This linear increase is illustrated in Figure .
• Specifically, the congestion window is incremented as follows each time an
ACK arrives:
Increment = MSS × (MSS/CongestionWindow)
CongestionWindow + = Increment
Packets in transit during additive increase, with one packet being
added each RTT.
[Type here]
2. Slow Start
• If the source sends as many packets as the advertised window allows, the
routers may not be able to consume this burst of packets.
• It all depends on how much buffer space is available at the routers.
• Slow start was therefore designed to space packets out so that this burst
does not occur.
• Thus slow start is much ―slowerǁ than sending an entire advertised
window’s worth of data all at once.
• From the above graph, Congestion Window flattens out at about 34 KB.
• The reason why the congestion window flattens is that there are no ACKs
arriving,
• due to the fact that several packets were lost.
• When a timeout eventually happens, the congestion window is divided
by 2 (i.e., cut from approximately 34 KB to around 17 KB) and
Congestion Threshold is set to this value.
• Congestion Window is reset to one packet and slow start is used till
Congestion Window reaches Congestion Threshold, after which
Congestion Window increases linearly.
• For example, fast recovery avoids the slow start and instead simply cuts the
congestion window in half and resumes additive increase.
• In other words, slow start is only used at the beginning of a connection.
• At all other times, the congestion window is following a pure additive
increase/multiplicative decrease pattern.
TCP Timers
To perform their operations smoothly, most TCP implementations use at
least four timers:
1. Retransmission
2. Persistence
3. Keepalive
4. TIME-WAIT.
Retransmission Timer
To retransmit lost segments, TCP employs one retransmission timer (for the
whole connection period) that handles the retransmission time-out (RTO),
the waiting time for an acknowledgment of a segment.
1. When TCP sends the segment in front of the sending queue, it starts the
timer.
2. When the timer expires, TCP resends the first segment in front of the
queue, andrestarts the timer.
3. When a segment or segments are cumulatively acknowledged, the
segment or segmentsare purged from the queue.
4. If the queue is empty, TCP stops the timer; otherwise, TCP restarts the
timer.
Persistence Timer
• To deal with a zero-window-size advertisement, TCP needs another timer.
• If the receiving TCP announces a window size of zero, the sending TCP
stops transmitting segments until the receiving TCP sends an ACK segment
announcing a nonzero window size.
• This ACK segment can be lost.
• If this acknowledgment is lost, the receiving TCP thinks that it has done its
job and waits for the sending TCP to send more segments.
• There is no retransmission timer for a segment containing only an
acknowledgment.
• The sending TCP has not received an acknowledgment and waits for the
other TCP to send an acknowledgment advertising the size of the window.
• Both TCP’s might continue to wait for each other forever (a deadlock).
• To correct this deadlock, TCP uses a persistence timer for each connection.
• When the sending TCP receives an acknowledgment with a window size of
zero, it starts a persistence timer.
• When the persistence timer goes off, the sending TCP sends a special
segment called a probe.
• The probe causes the receiving TCP to resend the acknowledgment.
• The value of the persistence timer is set to the value of the retransmission
time.
• However, if a response is not received from the receiver, another probe
segment is sentand the value of the persistence timer is doubled and reset.
[Type here]
• The sender continues sendingthe probe segments and doubling and resetting
the value of the persistence timeruntil the value reaches a threshold (usually
60 s).
• After that the sender sends one probesegment every 60 seconds until the
window is reopened.
Keepalive Timer
A keepalive timer is used to prevent a long idle connection between two
TCPs.
Example:Suppose that a client opens a TCP connection to a server,
transferssome data, and has crashed. In this case, the connection remains
open forever. The server has a keepalive timer. Each time the server hears
from a client, it resets this timer. The time-out is usually 2 hours. If the
server does not hear from the client after 2 hours, it sends a probe segment.
If there is no response after 10 probes, each of which is 75 seconds apart, it
assumes that the client is down and terminates the connection.
TIME-WAIT Timer
• The TIME-WAIT (2MSL) timer is used during connection termination.
• The maximum segment lifetime (MSL) is the amount of time any segment
can exist in a network before being discarded.
• Common values for MSL are 30 seconds, 1 minute, or even 2 minutes.
• The 2MSL timer is used when TCP performs an active close and sends the
final ACK.
• The connection must stay open for 2 MSL amount of time to allow TCP to
resend the final ACK in case the ACK is lost.
4. Full-Duplex Communication
• SCTP offers full-duplex service, where data can flow in both directions at
the same time.
• Each SCTP then has a sending and receiving buffer and packets are sentin
both directions.
5. Connection-Oriented Service
SCTP is a connection-oriented protocol.
6. Reliable Service
• SCTP is a reliable transport protocol.
• It uses an acknowledgment mechanism to check the arrival of data.
SCTP Features
1. Transmission Sequence Number (TSN)
The unit of data in SCTP is a data chunk.
• Data transfer in SCTP is controlled by numbering the data chunks.
• SCTP uses a transmission sequence number (TSN) to number the data
chunks.
[Type here]
• TSNs are 32 bits long and randomly initialized between 0 and 232 − 1.
Each data chunkmust carry the corresponding TSN in its header.
2. Stream Identifier (SI)
• There may be several streams in each association.
• Each stream in SCTP needsto be identified using a stream identifier (SI).
• Each data chunk must carry the SI in itsheader so that when it arrives at the
destination, it can be properly placed in its stream.
• The SI is a 16-bit number starting from 0.
3. Stream Sequence Number (SSN)
• When a data chunk arrives at the destination SCTP, it is delivered to the
appropriatestream and in the proper order.
• This means that, in addition to an SI, SCTP defines eachdata chunk in each
stream with a stream sequence number (SSN).
4. Packets
• Data are carried as data chunks, control information as controlchunks.
• Several control chunks and data chunks can be packed together in a packet.
• Apacket in SCTP plays the same role as a segment in TCP.
5. Acknowledgment Number
• SCTP acknowledgment numbers are chunk-oriented.
• In SCTP, the control information is carried by control chunks, which do
notneed a TSN.
• These control chunks are acknowledged by another control chunk of the
appropriate type (some need no acknowledgment).
Packet Format
General Header
• The sender has one buffer (queue) and three variables: curTSN, rwnd, and
inTransit,
[Type here]
• The receiver stores all chunks that have arrived in its queue includingthe out-of-
order ones.
• The last acknowledgment sent was for data chunk 20.
• The available window size is1000 bytes.
• Chunks 21 to 23 have been received in order.
• The first out-of-order blockcontains chunks 26 to 28.
• The second out-of-order block contains chunks 31 to 34.
• Avariable holds the value of cumTSN.
• An array of variables keeps track of the beginningand the end of each block that
is out of order.
• An array of variables holds the duplicatechunks received.
Sender Site
• At the sender site, our design demands two buffers (queues): a sending queue
and aretransmission queue.
• We also use three variables: rwnd, inTransit, and curTSN.
• The sending queue holds chunks 23 to 40.
• The chunks 23 to 36 have alreadybeen sent, but not acknowledged; they are
outstanding chunks.
• The curTSN points tothe next chunk to be sent (37).
• We assume that each chunk is 100 bytes, which meansthat 1400 bytes of data
(chunks 23 to 36) are in transit.
• The sender at this moment hasa retransmission queue.
• When a packet is sent, a retransmission timer starts for thatpacket.
• When theretransmission timer for a packet expires, or three SACKs arrive that
declares a packetas missing, the chunks in that packet aremoved to
theretransmission queue to be resent.
• These chunks are considered lost,rather than outstanding.
• The chunks in the retransmission queue have priority.
• Inother words, the next time the sender sends a chunk, it would be chunk 21
from theretransmission queue.