ACN Unit - 4 Notes
ACN Unit - 4 Notes
4.1 User Datagram Protocol: User Datagram, UDP Services, UDP Applications.
4.2 Transmission Control Protocol: TCP Services, TCP features, Segment, A TCP Connection,
State Transition Diagram, Windows in TCP, Flow Control, Error Control, TCP Congestion
Control, TCP Timers, Options.
4.3 SCTP: SCTP Services, SCTP Features, Packet Format, An SCTP Association, Flow Control,
Error Control.
TRANSPORT LAYER
• The transport layer is a 4th layer from the top.
• The main role of the transport layer is to provide the communication services directly to the application
processes running on different hosts.
• The transport layer provides a logical communication between application processes running on
different hosts. Although the application processes on different hosts are not physically connected,
application processes use the logical communication provided by the transport layer to send the messages
to each other.
• The transport layer protocols are implemented in the end systems but not in the network routers.
• A computer network provides more than one protocol to the network applications. For example, TCP
and UDP are two transport layer protocols that provide a different set of services to the network layer.
• All transport layer protocols provide multiplexing/demultiplexing service. It also provides other services
such as reliable data transfer, bandwidth guarantees, and delay guarantees. • Each of the applications in
the application layer has the ability to send a message by using TCP or UDP.
• This type of protocol is used when reliability and security are less important than speed and size.
• UDP is an end-to-end transport level protocol that adds transport-level addresses, checksum error
control, and length information to the data from the upper layer.
• UDP packets, called user data grams, have a fixed-size header of 8 bytes. Figure shows the format of a
user datagram
• This is the port number used by the process running on the source host.
• It is 16 bits long, which means that the port number can range from 0 to 65,535.
• If the source host is the client (a client sending a request) and if the source host is the server (a server
sending a response).
• The port number used by the process running on the destination host.
• It is also 16 bits long.
• If the destination host is the server (a client sending a request), the port number, in most cases, is a well-
known port number.
• If the destination host is the client (a server sending a response), the port number, in most cases, is an
ephemeral port number.
Length
• This is a 16-bit field that defines the total length of the user datagram, header plus data.
Checksum.
• This field is used to detect errors over the entire user datagram (header plus data).
• No flow and error control application using UDP services are responsible for providing them.
UDP application
• It is a connection-oriented protocol means the connection established between both the ends of the
transmission. For creating the connection, TCP generates a virtual circuit between sender and receiver for
the duration of a transmission.
Stream data transfer: TCP protocol transfers the data in the form of contiguous stream of bytes.
TCP group the bytes in the form of TCP segments and then passed it to the IP layer for
transmission to the destination. TCP itself segments the data and forward to the IP.
Reliability: TCP assigns a sequence number to each byte transmitted and expects a positive
acknowledgement from the receiving TCP. If ACK is not received within a timeout interval, then
the data is retransmitted to the destination. The receiving TCP uses the sequence number to
reassemble the segments if they arrive out of order or to eliminate the duplicate segments.
Flow Control: When receiving TCP sends an acknowledgement back to the sender indicating the
number the bytes it can receive without overflowing its internal buffer. The number of bytes is
sent in ACK in the form of the highest sequence number that it can receive without any problem.
This mechanism is also referred to as a window mechanism.
Multiplexing: Multiplexing is a process of accepting the data from different applications and
forwarding to the different applications on different computers. At the receiving end, the data is
forwarded to the correct application. This process is known as demultiplexing. TCP transmits the
packet to the correct application by using the logical channels known as ports.
Logical Connections: The combination of sockets, sequence numbers, and window sizes, is
called a logical connection. Each connection is identified by the pair of sockets used by sending
and receiving processes.
Full Duplex: TCP provides Full Duplex service, i.e., the data flow in both the directions at the
same time. To achieve Full Duplex service, each TCP should have sending and receiving buffers
so that the segments can flow in both the directions. TCP is a connection-oriented protocol.
Suppose the process A wants to send and receive the data from process B.
Where,
Source port address: It is used to define the address of the application program in a source
computer. It is a 16-bit field.
Destination port address: It is used to define the address of the application program in a
destination computer. It is a 16-bit field.
Sequence number: A stream of data is divided into two or more TCP segments. The 32-bit
sequence number field represents the position of the data in an original data stream.
Header Length (HLEN): It specifies the size of the TCP header in 32-bit words. The minimum
size of the header is 5 words, and the maximum size of the header is 15 words. Therefore, the
maximum size of the TCP header is 60 bytes, and the minimum size of the TCP header is 20
bytes. Reserved: It is a six-bit field which is reserved for future use.
Control bits: Each bit of a control field functions individually and independently. A control bit
defines the use of a segment or serves as a validity check for other fields. There are total six types
of flags in control field:
URG: The URG field indicates that the data in a segment is urgent.
ACK: When ACK field is set, then it validates the acknowledgement number.
PSH: The PSH field is used to inform the sender that higher throughput is needed so if possible,
data must be pushed with higher throughput.
RST: The reset bit is used to reset the TCP connection when there is any confusion occurs in the
sequence numbers.
SYN: The SYN field is used to synchronize the sequence numbers in three types of segments:
connection request, connection confirmation ( with the ACK bit set ), and confirmation
acknowledgement.
FIN: The FIN field is used to inform the receiving TCP module that the sender has finished
sending data. It is used in connection termination in three types of segments: termination request,
termination confirmation, and acknowledgement of termination confirmation.
Window Size: The window is a 16-bit field that defines the size of the window. Checksum: The
checksum is a 16-bit field used in error detection.
Urgent pointer: If URG flag is set to 1, then this 16-bit field is an offset from the sequence
number indicating that it is a last urgent data byte.
Options and padding: It defines the optional fields t hat convey the additional information to the
receiver.
Features of TCP
2) Reliable
3) Congestion Control
4) Full Duplex
6) Flow Control
TCP Flow Control is a protocol designed to manage the data flow between the user and the server. It
ensures that there is a specific bandwidth for sending and receiving data so the data can be processed
without facing any major issues. In order to achieve this, the TCP protocol uses a mechanism called the
sliding window protocol
Error control in TCP is mainly done through the use of three simple techniques :
1. Checksum – Every segment contains a checksum field which is used to find corrupted segments. If the
segment is corrupted, then that segment is discarded by the destination TCP and is considered lost.
2. Acknowledgement – TCP has another mechanism called acknowledgement to affirm that the data
segments have been delivered. Control segments that contain no data but have sequence numbers will be
acknowledged as well but ACK segments are not acknowledged.
• Retransmission after RTO: TCP always preserves one retransmission time-out (RTO) timer for all sent
but not acknowledged segments. When the timer runs out of time, the earliest segment is retransmitted.
Here no timer is set for acknowledgement. In TCP, the RTO value is dynamic in nature and it is updated
using the round trip time (RTT) of segments. RTT is the time duration needed for a segment to reach the
receiver and an acknowledgement to be received by the sender.
• Retransmission after Three duplicate ACK segments: RTO method works well when the value of RTO is
small. If it is large, more time is needed to get confirmation about whether a segment has been delivered
or not. Sometimes one segment is lost and the receiver receives so many out-of-order segments that they
cannot be saved. In order to solve this situation, three duplicate acknowledgement method is used and
missing segment is retransmitted immediately instead of retransmitting already delivered segment. This is
a fast retransmission because it makes it possible to quickly retransmit lost segments instead of waiting
for timer to end.
Connection Establishment TCP uses a Three way handshaking mechanism to establish a connection
between client and server machines. The three steps in three way handshaking mechanism are as follows.
SYN: The client sends the first segment, a SYN segment, in which only the SYN flag is set. This segment
is for synchronization of sequence numbers.
SYN + ACK: The server sends the second segment, a SYN +ACK segment, with 2 flag bits set.
ACK : The client sends the third segment. This is just an ACK segment. It guarantees the completion of
three way handshaking.
If 2 host Simultaneously try to establish connection:
Simultaneous Open: It's possible for two applications to send a SYN to each other to start a TCP
connection, although the possibility is small, because both sides have to know which port on the other
side to send to. This process is called "Simultaneous Open", or "simultaneous active open on both sides".
In a simultaneous open, both applications issue active opens.
This is a rare situation in which there is no client or server; communication is between two peers that
know their local port numbers.
Both TCPs go through SYN-SENT and SYN-RCVD states before going to the ESTABLISHED state.
The two SYN+ACK segments acknowledge the SYN segments and open the connection.
OR
Simultaneous Close: It's permitted in TCP for both sides to do "active close", which is called
"Simultaneous Close". During "Simultaneous Close", 4 packets are exchanged, the same as in normal
situations.
Both TCPs go to the FIN-WAIT-1 state and send FIN segments that are in transit simultaneously
After receiving the FIN segment, each end goes to the CLOSING state and sends an ACK segment.
The CLOSING state takes the place of FIN-WAIT-2 or CLOSEWAIT in a common scenario.
The connection is established in TCP using the three-way handshake as discussed earlier to create a
connection. One side, say the server, passively stays for an incoming link by implementing the LISTEN
and ACCEPT primitives, either determining a particular other side or nobody in particular. The other side
performs a connect primitive specifying the I/O port to which it wants to join. The maximum TCP
segment size available, other options are optionally like some private data (example password). The
CONNECT primitive transmits a TCP segment with the SYN bit on and the ACK bit off and waits for a
response. The sequence of TCP segments sent in the typical case, as shown in the figure below
When the segment sent by Host-1 reaches the destination, i.e., host -2, the receiving server checks to see
if there is a process that has done a LISTEN on the port given in the destination port field. If not, it sends
a response with the RST bit on to refuse the connection. Otherwise, it governs the TCP segment to the
listing process, which can accept or decline (for example, if it does not look similar to the client) the
connection. Call Collision: If two hosts try to establish a connection simultaneously between the same
two sockets, then the events sequence is demonstrated in the figure under such circumstances. Only one
connection is established. It cannot select both the links because their endpoints identify connections.
Suppose the first set up results in a connection identified by (x, y) and the second connection are also
released up. In that case, only tail enter will be made, i.e., for (x, y) for the initial sequence number, a
clock-based scheme is used, with a clock pulse coming after every 4 microseconds. For ensuring
additional safety when a host crashes, it may not reboot for sec, which is the maximum packet lifetime.
This is to make sure that no packets from previous connections are roaming around.
To keep track of all the different events happening during connection establishment, connection
termination, and data transfer, TCP is specified as the Finite State Machine –
• Singled by the FIN bit in the packet header The figure shows the two FSMs used by the TCP client and
server combined in one diagram.
• The dotted black lines in the figure represent the transition that a server normally goes through.
• The solid black lines show the transitions that a client normally goes through.
Sometimes in some situations, a server transitions through a solid line or a client transition through a
dotted line
Difference between TCP and UDP
4.3 SCTP(Stream Control Transmission Protocol)
SCTP transmits data in the form of messages and each message contains one or more packets. The control
come before data chunks.
1. Source and Destination port number to enable multiplexing of different SCTP associations at the
same address.
2. A 32-bit verification tag that guards against the insertion of an out-of-date or false message into the
SCTP association.
3. A 32-bit checksum for error detection. The checksum can be either a 32-bit CRC checksum or Alder-
32 checksum.
i. Chunk Type: This field identifies the type of information contained in the Chunk data field. The
value of chunk field ranges from 0 to 254. the value 255 is reserved for future. SCTP consists of one
DATA chunk and 12 control chunks.
ii. Chunk Flag: The chunk field contains the flag, such as U(unordered bit), B(beginning bit), and
E(ending bit). Usage of this field depends on the chunk type specified in the chunk type field. iii. Chunk
Length: This field represents the size of the fields chunk type, chunk flag, chunk length, and chunk value,
in bytes.
5. SCTP DATA CHUNK: Data chunks are used to send actual data through the stream and have rather
complex headers in some ways, but not really worse than TCP headers in general.
SCTP Association Establishment Process:- SCTP association startup and shutdown guidelines are
described here. SCTP association is comprised of a four-way handshake that takes place in the following
order:
ii. On receipt of the INIT signal, the server sends an INIT-ACK response to the client. This INIT-ACK
signal contains a state cookie. This state cookie must contain a Message Authentication Code (MAC),
along with a time stamp corresponding to the creation of the cookie, the life span of the state cookie, and
the information necessary to establish the association. The MAC is computed by the server based on a
secret key only known to it.
iii. On receipt of this INIT-ACK signal, the client sends a COOKIE-ECHO response, which just echoes
the state cookie. iv. After verifying the authenticity of the state cookie using the secret key, the server then
allocates the resources for the association, sends a COOKIE-ACK response acknowledging the COOKIE-
ECHO signal, and moves the association to ESTABLISHED state.
SCTP supports also graceful close of an active association upon request from the SCTP user. The
following sequence of events occurs:
i. The client sends a SHUTDOWN signal to the server, which tells the server that the client is ready to
close the connection.
iii. The client then sends a SHUTDOWN-COMPLETE signal back to the server.
SCTP also supports abrupt close (ABORT signal) of an active association upon the request from the
SCTP client or due to an error in the SCTP stack. However, SCTP does not support half open connections.
Flow control under SCTP: Flow control in SCTP is similar to that in TCP. Like TCP, SCTP executes
flow control to prevent overwhelming the receiver. In SCTP, we need to handle two units of data, the byte
and the chunk. The values of rwnd and cwnd are expressed in bytes; the values of TSN and
acknowledgments are expressed in chunks. Current SCTP implementations still use a byte-oriented
window for flow control. 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,cum TSN. The second variable holds the available buffer size; winsize. The third
variable holds the last accumulative acknowledgment, last ACK. 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. 2. When the
process reads a chunk, it removes it from the queue and adds the size of the removed chunk to winSize
(recycling). 3. When the receiver decides to send a SACK, it checks the value of lastAck; if it is less than
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, as shown in the following figure. We assume each chunk is 100
bytes long. The buffer holds the chunks produced by the 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 not acknowledged; 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 not yet acknowledged. The following is the procedure used by the sender.
1. A chunk pointed to by curTSN can be sent if the size of the data is less than or equal to the quantity
rwnd – iNTransit. After sending the chunk, the value of curTSN is incremented by 1 and now points to the
next chunk to be sent. The value of inTransit is incremented by the size of the data in the transmitted
chunk.
2. 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 sender does 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
Error control in SCTP
SCTP, like TCP, is a reliable transport layer protocol. It uses a SACK chunk to report the state of the re-
ceiver buffer to the sender. Each implementation uses a different set of entities and timers for the receiver
and sender sites.
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 the receiv-
ing queue at a particular point in time.
The last acknowledgment sent was for data chunk 20. The available window size is 1000 bytes.
Chunks 21 to 23 have been received in order. The first out-of-order block contains chunks 26 to
28. The second out-of-order block contains chunks 31 to 34. A variable holds the value of
cumTSN. An array of variables keeps track of the beginning and the end of each block that is out
of order. An array of variables holds the duplicate chunks received. Note that there is no need for
storing duplicate chunks in the queue and they will be discarded.
The figure also shows the SACK chunk that will be sent to report the state of the receiver to the
sender. The TSN numbers for out-of-order chunks are relative (offsets) to the cumulative TSN.
Differentiation between SCTP, TCP and UDP based on some Services/ Features