CS3591-CN Unit 2 Notes
CS3591-CN Unit 2 Notes
INTRODUCTION
The transport layer is the fourth layer of the OSI model and is the
core of the Internetmodel.
It responds to service requests from the session layer and issues
service requests tothe network Layer.
The transport layer provides transparent transfer of data between hosts.
It provides end-to-end control and information transfer with the
quality of serviceneeded by the application program.
It is the first true end-to-end layer, implemented in all End Systems (ES).
Error Control
Error control at the transport layer is responsible for
1. Detecting and discarding corrupted packets.
2. Keeping track of lost and discarded packets and resending them.
3. Recognizing duplicate packets and discarding them.
4. Buffering out-of-order packets until the missing packets arrive.
Error Control involves Error Detection and Error Correction
Congestion Control
Congestion in a network may occur if the load on the network (the
number of packets sent to the network) is greater than the capacity
of the network (the numberof packets a network can handle).
Congestion control refers to the mechanisms and
techniques that control thecongestion and keep the load
below the capacity.
Congestion Control refers to techniques and mechanisms that
can either preventcongestion, before it happens, or remove
congestion, after it has happened
Congestion control mechanisms are divided into two categories,
1. Open loop - prevent the congestion before it happens.
2. Closed loop - remove the congestion after it happens.
2. PORT NUMBERS
A transport-layer protocol usually has several responsibilities.
One is to create a process-to-process communication.
Processes are programs that run on hosts. It could be either server or
client.
A process on the local host, called a client, needs services from
a process usuallyon the remote host, called a server.
Processes are assigned a unique 16-bit port number on that host.
Port numbers provide end-to-end addresses at the transport layer
They also provide multiplexing and demultiplexing at this layer.
The port numbers are integers between 0 and 65,535 .
WELL-KNOWN PORTS
These are permanent port numbers used by the servers.
They range between 0 to 1023.
This port number cannot be chosen randomly.
These port numbers are universal port numbers for servers.
Every client process knows the well-known port number of the
corresponding serverprocess.
For example, while the daytime client process, a well-known
client program, canuse an ephemeral (temporary) port number,
52,000, to identify itself, the daytimeserver process must use the
well-known (permanent) port number 13.
REGISTERED PORTS
The ports ranging from 1024 to 49,151 are not assigned or controlled.
3. TRANSPORT LAYER PROTOCOLS
UDP PORTS
Processes (server/client) are identified by an abstract locator known as
port.
Server accepts message at well known port.
Some well-known UDP ports are 7–Echo, 53–DNS, 111–RPC, 161–
SNMP, etc.
< port, host > pair is used as key for demultiplexing.
Ports are implemented as a message queue.
When a message arrives, UDP appends it to end of the queue.
When queue is full, the message is discarded.
When a message is read, it is removed from the queue.
When an application process wants to receive a message, one is
removed from thefront of the queue.
If the queue is empty, the process blocks until a message becomes
available.
Length
This field denotes the total length of the UDP Packet (Header plus
data)
The total length of any UDP datagram can be from 0 to 65,535 bytes.
Checksum
UDP computes its checksum over the UDP header, the contents
of the messagebody, and something called the pseudoheader.
The pseudoheader consists of three fields from the IP header—
protocol number,source IP address, destination IP address plus
the UDP length field.
Data
Data field defines tha actual payload to be transmitted.
Its size is variable.
UDP SERVICES
Process-to-Process Communication
UDP provides process-to-process communication using
socket addresses, acombination of IP addresses and port numbers.
Connectionless Services
UDP provides a connectionless service.
There is no connection establishment and no connection termination .
Each user datagram sent by UDP is an independent datagram.
There is no relationship between the different user datagrams even if they
are
coming from the same source process and going to the same destination
program.
The user datagrams are not numbered.
Each user datagram can travel on a different path.
Flow Control
UDP is a very simple protocol.
There is no flow control, and hence no window mechanism.
The receiver may overflow with incoming messages.
The lack of flow control means that the process using UDP
should provide for thisservice, if needed.
Error Control
There is no error control mechanism in UDP except for the checksum.
This means that the sender does not know if a message has been lost or
duplicated.
When the receiver detects an error through the checksum, the user datagram is
The lack of error control means that the process using UDP should
provide for thisservice, if needed.
Checksum
UDP checksum calculation includes three sections: a pseudoheader,
the UDP header,and the data coming from the application layer.
The pseudoheader is the part of the header in which the user
datagram is to beencapsulated with some fields filled with 0s.
Optional Inclusion of Checksum
The sender of a UDP packet can choose not to calculate the
checksum.
In this case, the checksum field is filled with all 0s before being sent.
In the situation where the sender decides to calculate
the checksum, but it happens that the result is all 0s,
the checksum is changed to all 1sbefore the packet is
sent.
In other words, the sender complements the sum two times.
Congestion Control
Since UDP is a connectionless protocol, it does not provide congestion
control.
UDP assumes that the packets sent are small and
sporadic(occasionally or at irregularintervals) and cannot create
congestion in the network.
This assumption may or may not be true, when UDP is used for
interactive real-timetransfer of audio and video.
Queuing
In UDP, 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
queue associatedwith each process.
Other implementations create only an incoming queue associated with
each process.
Multiplexing and Demultiplexing
In a host running a transport protocol suite, there is only one
UDP but possiblyseveral processes that may want to use the
services of UDP.
To handle this situation, UDP multiplexes and demultiplexes.
APPLICATIONS OF UDP
UDP is used for management processes such as SNMP.
UDP is used for route updating protocols such as RIP.
UDP is a suitable transport protocol for multicasting.
Multicasting capability isembedded in the UDP software
UDP is suitable for a process with internal flow and error control
mechanisms suchas Trivial File Transfer Protocol (TFTP).
UDP is suitable for a process that requires simple request-response
communicationwith little concern for flow and error control.
UDP is normally used for interactive real-time applications
that cannot tolerateuneven delay between sections of a
received message.
TCP SERVICES
Process-to-Process Communication
TCP provides process-to-process communication using port numbers.
Stream Delivery Service
TCP is a stream-oriented protocol.
TCP allows the sending process to deliver data as a stream of
bytes and allows thereceiving process to obtain data as a stream of
bytes.
TCP creates an environment in which the two processes seem to be
connected by animaginary “tube” that carries their bytes across the
Internet.
The sending process produces (writes to) the stream and the
receiving processconsumes (reads from) it.
Full-Duplex Communication
TCP offers full-duplex service, where data can flow in both
directions at the sametime.
Each TCP endpoint then has its own sending and receiving
buffer, and segments move in both directions.
Connection-Oriented Service
TCP is a connection-oriented protocol.
A connection needs to be established for each pair of processes.
When a process at site A wants to send to and receive
data from anotherprocess at site B, the following three
phases occur:
1. The two TCP’s establish a logical connection between them.
2. Data are exchanged in both directions.
3. The connection is terminated.
Reliable Service
TCP is a reliable transport protocol.
It uses an acknowledgment mechanism to check the safe and sound
arrival of data.
TCP SEGMENT
A packet in TCP is called a segment.
Data unit exchanged between TCP peers are called segments.
A TCP segment encapsulates the data received from the application
layer.
The TCP segment is encapsulated in an IP datagram, which in turn
is encapsulated ina frame at the data-link layer.
Connection Establishment
While opening a TCP connection the two nodes(client and server)
want to agree on aset of parameters.
The parameters are the starting sequence numbers that is to be
used for theirrespective byte streams.
Connection establishment in TCP is a three-way handshaking.
1. Client sends a SYN segment to the server containing its initial sequence
number (Flags
= SYN, SequenceNum = x)
2. Server responds with a segment that acknowledges client’s segment
and specifies itsinitial sequence number (Flags = SYN + ACK, ACK =
x + 1 SequenceNum = y).
3. Finally, client responds with a segment that acknowledges server’s
sequence number
(Flags = ACK, ACK = y + 1).
The reason that each side acknowledges a sequence number that
is one larger than the one sent is that the Acknowledgment field
actually identifies the “next sequence number expected,”
A timer is scheduled for each of the first two segments, and if the
expected response is not received, the segment is retransmitted.
Data Transfer
After connection is established, bidirectional data transfer can take
place.
The client and server can send data and acknowledgments in both
directions.
The data traveling in the same direction as an acknowledgment
are carried on thesame segment.
The acknowledgment is piggybacked with the data.
Connection Termination
Connection termination or teardown can be done in two ways :
Three-way Close and Half-Close
Send Buffer
Sending TCP maintains send buffer which contains 3 segments
(1) acknowledged data
(2) unacknowledged data
(3) data to be transmitted.
Send buffer maintains three pointers
(1) LastByteAcked, (2) LastByteSent, and (3)
LastByteWrittensuch that:
LastByteAcked ≤ LastByteSent ≤ LastByteWritten
A byte can be sent only after being written and only a sent
byte can be
acknowledged.
Bytes to the left of LastByteAcked are not kept as it had been
acknowledged.
Receive Buffer
Receiving TCP maintains receive buffer to hold data even if it arrives
out-of-order.
Receive buffer maintains three pointers namely
(1) LastByteRead, (2) NextByteExpected, and
(3) LastByteRcvdsuch that:
LastByteRead ≤ NextByteExpected ≤ LastByteRcvd + 1
A byte cannot be read until that byte and all preceding bytes have been
received.
If data is received in order, then NextByteExpected = LastByteRcvd +
1
Bytes to the left of LastByteRead are not buffered, since it is read by the
application.
TCP TRANSMISSION
TCP has three mechanism to trigger the transmission of a segment.
They are
o Maximum Segment Size (MSS) - Silly Window Syndrome
o Timeout - Nagle’s Algorithm
For example, when ACK arrives for 1 packet, 2 packets are sent.
When ACK for bothpackets arrive, 3 packets are sent and so on.
CongestionWindow increases and decreases throughout lifetime of the
connection.
When CongestionWindow is plotted as a function of time, a saw-
tooth patternresults.
Slow Start
Slow start is used to increase CongestionWindow exponentially from a
cold start.
Source TCP initializes CongestionWindow to one packet.
TCP doubles the number of packets sent every RTT on successful
transmission.
When ACK arrives for first packet TCP adds 1 packet to
CongestionWindow andsends two packets.
When two ACKs arrive, TCP increments CongestionWindow by 2
packets and sendsfour packets and so on.
Instead of sending entire permissible packets at once (bursty traffic),
packets are sentin a phased manner, i.e., slow start.
Initially TCP has no idea about congestion,
henceforth it increasesCongestionWindow rapidly until
there is a timeout. On timeout:
CongestionThreshold =
CongestionWindow/ 2
CongestionWindow = 1
For example, packets 1 and 2 are received whereas packet 3 gets lost.
o Receiver sends a duplicate ACK for packet 2 when packet 4 arrives.
o Sender receives 3 duplicate ACKs after sending packet 6
retransmits packet 3.
o When packet 3 is received, receiver sends cumulative ACK up to
packet 6.
The congestion window trace will look like
The destination host then copies this congestion bit into the ACK it
sends back to thesource.
The Source checks how many ACK has DEC bit set for previous window
packets.
If less than 50% of ACK have DEC bit set, then source increases
its congestionwindow by 1 packet
Using a queue length of 1 as the trigger for setting the congestion bit.
A router sets this bit in a packet if its average queue length is greater
than or equal to1 at the time the packet arrives.
Average queue length is measured over a time interval that includes the
last busy + last idle cycle + current busy cycle.
It calculates the average queue length by dividing the curve area with time
interval.
Each router is programmed to monitor its own queue length, and when
it detects thatthere is congestion, it notifies the source to adjust its
congestion window.
RED differs from the DEC bit scheme by two ways:
a. In DECbit, explicit notification about congestion is sent to
source, whereas RED implicitly notifies the source by dropping
a few packets.
RED has two queue length thresholds that trigger certain activity:
MinThreshold andMaxThreshold
When a packet arrives at a gateway it compares Avglen with these two values
according to the following
Stream Control Transmission Protocol (SCTP) is a reliable,
message-orientedtransport layer protocol.
SCTP has mixed features of TCP and UDP.
SCTP maintains the message boundaries and detects the lost data,
duplicate data aswell as out-of-order data.
SCTP provides the Congestion control as well as Flow control.
SCTP is especially designed for internet applications as
well as multimediacommunication.
SCTP SERVICES
Process-to-Process Communication
SCTP provides process-to-process communication.
Multiple Streams
SCTP allows multistream service in each connection, which is
called association inSCTP terminology.
If one of the streams is blocked, the other streams can still deliver their
data.
Multihoming
Connection-Oriented Service
SCTP is a connection-oriented protocol.
In SCTP, a connection is called an association.
If a client wants to send and receive message from server , the steps are :
Step1: The two SCTPs establish the connection with each other.
Step2: Once the connection is established, the data gets
exchanged in both thedirections.
Step3: Finally, the association is terminated.
Reliable Service
SCTP is a reliable transport protocol.
It uses an acknowledgment mechanism to check the safe and sound
arrival of data.
An SCTP packet has a mandatory general header and a set of blocks called
chunks.
General Header
The general header (packet header) defines the end points of
each association towhich the packet belongs
It guarantees that the packet belongs to a particular association
It also preserves the integrity of the contents of the packet including the
header itself.
There are four fields in the general header.
Source port
This field identifies the sending port.
Destination port
This field identifies the receiving port that hosts use to route
the packet to theappropriate endpoint/application.
Verification tag
A 32-bit random value created during initialization to
distinguish stale packetsfrom a previous connection.
Checksum
The next field is a checksum. The size of the checksum is 32
bits. SCTP usesCRC-32 Checksum.
Chunks
Control information or user data are carried in chunks.
Chunks have a common layout.
The first three fields are common to all chunks; the information
field depends on thetype of chunk.
The type field can define up to 256 types of chunks. Only a few have
been defined sofar; the rest are reserved for future use.
The flag field defines special flags that a particular chunk may need.
The length field defines the total size of the chunk, in bytes,
including the type, flag,and length fields.
Types of Chunks
An SCTP association may send many packets, a packet may contain
several chunks,and chunks may belong to different streams.
SCTP defines two types of chunks - Control chunks and Data chunks.
A control chunk controls and maintains the association.
A data chunk carries user data.
SCTP ASSOCIATION
SCTP is a connection-oriented protocol.
A connection in SCTP is called an association to emphasize
multihoming.
SCTP Associations consists of three phases:
Association Establishment
Data Transfer
Association Termination
Association Establishment
Association establishment in SCTP requires a four-way handshake.
In this procedure, a client process wants to establish an
association with a serverprocess using SCTP as the transport-layer
protocol.
The SCTP server needs to be prepared to receive any association (passive
open).
Association establishment, however, is initiated by the client (active
open).
The client sends the first packet, which contains an INIT chunk.
The server sends the second packet, which contains an INIT ACK
chunk. The INIT ACK also sends a cookie that defines the state of the
server at this moment.
The client sends the third packet, which includes a COOKIE ECHO
chunk. This is a very simple chunk that echoes, without change, the
cookie sent by the server. SCTP allows the inclusion of data chunks
in this packet.
The server sends the fourth packet, which includes the COOKIE ACK
chunk that acknowledges the receipt of the COOKIE ECHO chunk.
SCTP allows the inclusion of data chunks with this packet.
Data Transfer
The whole purpose of an association is to transfer data between two ends.
After the association is established, bidirectional data transfer can take
place.
The client and the server can both send data.
SCTP supports piggybacking.
Association Termination
In SCTP,either of the two parties involved in exchanging data
(client or server) canclose the connection.
SCTP does not allow a “half closed” association. If one end closes
the association,the other end must stop sending new data.
If any data are left over in the queue of the recipient of the
termination request, theyare sent and the association is closed.
Association termination uses three packets.
Receiver Site
The receiver has one buffer (queue) and three variables.
The queue holds the received data chunks that have not yet been read by
the process.
The first variable holds the last TSN received, cumTSN.
The second variable holds the available buffer size; winsize.
The third variable holds the last accumulative acknowledgment,
lastACK.
The following figure shows the queue and variables at the receiver site.
When the site receives a data chunk, it stores it at the end of the buffer
(queue) and subtracts the size of the chunk from winSize.
The TSN number of the chunk is stored in the cumTSN variable.
When the process reads a chunk, it removes it from the queue and adds
the size of theremoved chunk to winSize (recycling).
When the receiver decides to send a SACK, it checks the value of
lastAck; if it is lessthan cumTSN, it sends a SACK with a cumulative
TSN number equal to the cumTSN.
It also includes the value of winSize as the advertised window size.
Sender Site
The sender has one buffer (queue) and three variables: curTSN, rwnd,
and inTransit.
We assume each chunk is 100 bytes long. The buffer holds the
chunks produced bythe process that either have been sent or are
ready to be sent.
The first variable, curTSN, refers to the next chunk to be sent.
All chunks in the queue with a TSN less than this value have
been sent, but notacknowledged; they are outstanding.
The second variable, rwnd, holds the last value advertised by the receiver
(in bytes).
The third variable, inTransit, holds the number of bytes in transit,
bytes sent but notyet acknowledged.
The following figure shows the queue and variables at the sender site.
A chunk pointed to by curTSN can be sent if the size of the data is
less than or equalto the quantity rwnd - inTransit.
After sending the chunk, the value of curTSN is incremented by 1
and now points tothe next chunk to be sent.
The value of inTransit is incremented by the size of the data in the
transmitted chunk.
When a SACK is received, the chunks with a TSN less than or equal
to the cumulative TSN in the SACK are removed from the queue and
discarded. The senderdoes not have to worry about them anymore.
The value of inTransit is reduced by the total size of the discarded chunks.
The value of rwnd is updated with the value of the advertised window in
the SACK.
Receiver Site
The receiver stores all chunks that have arrived in its queue
including the out-of-order ones. However, it leaves spaces for any
missing chunks.
It discards duplicate messages, but keeps track of them for reports to the
sender.
The following figure shows a typical design for the receiver site
and the state of thereceiving queue at a particular point in time.
Sender Site
At the sender site, it needs two buffers (queues): a sending
queue and aretransmission queue.
Three variables were used - rwnd, inTransit, and curTSN as
described in the previoussection.
The following figure shows a typical design.
The sending queue holds chunks 23 to 40.
The chunks 23 to 36 have already been sent, but not acknowledged;
they areoutstanding chunks.
The curTSN points to the next chunk to be sent (37).
We assume that each chunk is 100 bytes, which means that
1400 bytes of data(chunks 23 to 36) is in transit.
The sender at this moment has a retransmission queue.
When a packet is sent, a retransmission timer starts for that packet
(all data chunks inthat packet).
Some implementations use one single timer for the entire
association, but otherimplementations use one timer for each
packet.