Ch.4 Transport Layer Protocol 18m
Ch.4 Transport Layer Protocol 18m
4.2 TCP
Q.5Explain the TCP connection establishment using a three way handshake mechanism.
4M W19
Q.6 Explain how TCP connections are established using the 3 way handshake. What
happens when 2 hosts simultaneously try to establish a connection? 6M W 19
Q.12 Explain how TCP connections are established using 3 way handshake. 6M W23
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.
Q.13 Demonstrate with suitable example of call collision in TCP connection. 6M W23
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.
Q.7 Explain TCP connection management with the help of TCP connection management
finite state machine. 6M W19
(Note: Any other explanation of the concept shall be considered).
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 –FSM
TCP State Machine:
TCP uses a three way handshake to close connection
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.
Ovals/rectangle represents states.
Transition from one state to another is shown using directed lines.
Each line has two strings separated by a slash.
The first string is the input, what TCP receives.
The second is the output, what TCP sends.
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 transitions
through a dotted line.
The header of TCP segment can range from 20-60 bytes.40 bytes are for option. if there are no
options, header is of 20 bytes else it can be of upmost 60 bytes.
2) Destination port address: - This is a 16-bit field that defines the port number of the application
program in the host that is receiving the segment. This serves the same purpose as the destination
port address in the UDP header.
3) Sequence Number: - This 32-bit field defines the number assigned to the first byte of data
contained in this segment. As we said before, TCP is a stream transport protocol. To ensure
connectivity, each byte to be transmitted is numbered. The sequence number tells the destination
which byte in this sequence comprises the first byte in the segment. During connection
establishment, each party uses a random number generator to create an initial sequence number
(ISN), which is usually different in each direction.
4) Acknowledgment Number: - This 32-bit field defines the byte number that the receiver of the
segment is expecting to receive from the other party. If the receiver of the segment has successfully
received byte number x from the other party, it defines x + 1 as the acknowledgment number.
Acknowledgment and data can be piggybacked together.
5) Header length: - This 4-bit field indicates the number of 4-byte words in the TCP header. The
length of the header can be between 20 and 60 bytes. Therefore, the value of this field can be
between 5 (5 x 4 = 20) and 15 (15 x 4 = 60).
7) Control Field:- This field defines 6 different control bits or flags. These are 6, 1 bit control bits
that controls connection establishment, connection termination, connection abortion, flow control,
mode of transfer etc.
8) Window Size: This field tells the window size of the sending TCP in bytes.
9) Checksum: This field holds the checksum for error control. It is mandatory in TCP as opposed
to UDP.
10) Urgent Pointer: This field (valid only if the URG control flag is set) used to point to data that
is urgently required that needs to reach the receiving process at the earliest. The value of this field
is added to the sequence number to get the byte number of the last urgent byte.
11) Options: There can be up to 40 bytes of optional information in the TCP header.
OR
1) Retransmission Timer: To retransmit lost segments, TCP uses Retransmission Time Out
(RTO).
When TCP sends a segment the timer starts and stops when the acknowledgment is received.
If the timer expires timeout occurs and the segment is retransmitted. RTO (retransmission
timeout is for 1 RTT) to calculate retransmission timeout we first need to calculate the RTT.
After a TCP connection is closed, it is possible for datagrams that are still making their way
through the network to attempt to access the closed port.
The quiet timer is intended to prevent the just closed port from reopening again quickly and
receiving these last datagrams. The quiet timer is usually set to twice the maximum segment
lifetime (the same value as the Time- To-Live field in an IP header), ensuring that all segments still
heading for the port have been discarded.
Sequence Control The 32-bit sequence number field defines the number assigned to the first byte
of data contained in this segment.
During connection establishment, each party uses a Random number generator to create an initial
sequence number (ISN), which is usually different in each direction. We know that a TCP sequence
number is 32 bit. So it has finite (from 0 to (232-1) = 4 Giga sequence numbers) and it means we
will be able to send only 4GB of data with a unique sequence number not more than that.
It helps with the allocation of a sequence number that does not conflict with other data bytes
transmitted over a TCP connection. An ISN is unique to each connection and separated by each
device.
Error Control Error Control mechanisms are useful to ensure reliability service of TCP.
To provide reliable service TCP detects and corrects errors.
Error control mechanisms are useful for detecting corrupted segments, lost segments, out-of-order
segments, and duplicated segments.
Error detection and correction in TCP is achieved through the use of three simple tools: checksum,
acknowledgment, and time-out.
Flow Control Flow control make it possible for sender to send the amount of data bytes that can be
sent without worrying an acknowledgment and is one of the most important duties of the data link
layer.
In most protocols, flow control is a set of procedures that tells the sender how much data it can
transmit before it must wait for an acknowledgment from the receiver.
The flow Control procedures not allowed to overwhelm the receiver.
Any receiving device has a limited speed at which it can process incoming data and a limited
amount of memory in which to store incoming data, if sender sends data in a much speed data loss
may occur to overcome this problem flow control procedures are needful.
4.3 SCTP
Q.15 Describe flow control under SCTP. 4M W22
(Any other relevant explanation or example can be considered)
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,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.
1. 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.