Xodo
Xodo
Transport Layer
Multiplexing and Demultiplexing
• Let us consider two messaging apps that are widely used nowadays viz. Telegram and
WhatsApp. Suppose A is the sender and B is the receiver. Both sender and receiver
have these applications installed in their system (say smartphone). Suppose A wants
to send messages to B in WhatsApp and telegram both. In order to do so, A must
mention the IP address of B and destination port number of the WhatsApp while
sending the message through the WhatsApp application. Similarly, for the latter case,
A must mention the IP address of B and the destination port number of the Telegram
while sending the message.
• Now the messages from both the apps will be wrapped up along with
appropriate headers(viz. source IP address, destination IP address, source port
no, destination port number) and sent as a single message to the receiver. This
process is called multiplexing. At the destination, the received message is
unwrapped and constituent messages (viz messages from a Telegram and
WhatsApp application) are sent to the appropriate application by looking to the
destination the port number. This process is called demultiplexing. Similarly, B
can also transfer the messages to A.
Telegram
Telegram
Transmission Control Protocol (TCP)
• Transmission Control Protocol (TCP) is a connection-oriented protocol for
communications that helps in the exchange of messages between different
devices over a network.
• TCP establishes a reliable connection between sender and receiver using the
three-way handshake (SYN, SYN-ACK, ACK) and it uses a four-step handshake
(FIN, ACK, FIN, ACK) to close connections properly.
TCP 3-way handshake process
• It involves three steps: SYN
(Synchronize), SYN-ACK
(Synchronize- Acknowledge),
and ACK (Acknowledge).
• Step 1 (SYN): In the first step, the client wants to establish a connection with a
server, so it sends a segment with SYN(Synchronize Sequence Number) which
informs the server that the client is likely to start communication and with what
sequence number it starts segments with
• Step 2 (SYN + ACK): Server responds to the client request with SYN-ACK signal
bits set. Acknowledgement(ACK) signifies the response of the segment it
received and SYN signifies with what sequence number it is likely to start the
segments with
• Step 3 (ACK): In the final part client acknowledges the response of the server
and they both establish a reliable connection with which they will start the
actual data transfer
TCP Header
Header Fields
• Source Port Address – A 16-bit field that holds the port address of the application that is
sending the data segment.
• Destination Port Address – A 16-bit field that holds the port address of the application in
the host that is receiving the data segment.
• Sequence Number – A 32-bit field that holds the sequence number, i.e, the byte number of
the first byte that is sent in that particular segment. It is used to reassemble the message at
the receiving end of the segments that are received out of order.
• Acknowledgement Number – A 32-bit field that holds the acknowledgement number, i.e,
the byte number that the receiver expects to receive next. It is an acknowledgement for the
previous bytes being received successfully.
• Header Length (HLEN) – This is a 4-bit field that indicates the length of the TCP header by a
number of 4-byte words in the header, i.e if the header is 20 bytes(min length of TCP
header), then this field will hold 5 (because 5 x 4 = 20) and the maximum length: 60 bytes,
then it’ll hold the value 15(because 15 x 4 = 60). Hence, the value of this field is always
between 5 and 15.
• Control flags – These are 6 1-bit control bits that control connection establishment,
connection termination, connection abortion, flow control, mode of transfer etc. Their
function is:
• URG: Urgent pointer is valid
• ACK: Acknowledgement number is valid( used in case of cumulative acknowledgement)
• PSH: Request for push
• RST: Reset the connection
• SYN: Synchronize sequence numbers
• FIN: Terminate the connection
• Window size – This field tells the window size of the sending TCP in bytes.
• Checksum – This field holds the checksum for error control. It is mandatory in
TCP as opposed to UDP.
• Urgent pointer – This field (valid only if the URG control flag is set) is 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.
Q. The following is the dump of TCP header in hexa deciaml format: 05320017
00000001 00000000 500207FF 00000000.
Find: i) what is the sequence number?
ii) what is the destination port number?
iii) What is the acknowledgement number?
iv) What is the window size?
00000001 = 1 (decimal)
00000000 = 0 (decimal)
• Data Offset + Reserved + Flags (2 bytes)
• given: 5002
• Split into:
• Data Offset (4 bits) = 5 (means 5 * 4 = 20 bytes TCP header length)
• Reserved (6 bits) = 000000
• Flags (6 bits) = 000010→ Only the SYN flag is set.
• Checksum (2 bytes)
0000 = 0000 (normally computed during transmission)
Field Value
Source Port 1330
Destination Port 23 (Telnet)
Sequence Number 1
Acknowledgment Number 0
Header Length 20 bytes
Flags SYN
Window Size 2047
Checksum 0
Urgent Pointer 0
User Datagram Protocol (UDP)
• It is an unreliable and connectionless protocol.
Q. TCP vs UDP?
Connection Management
• Includes:
• Connection establishment
• Data transfer
• Connection termination
• Connection establishment:
• Client → Server: Sends SYN (synchronize sequence numbers)
• Connection Termination
• Client → Server: Sends FIN (finish)
• The receiver tells the sender how much data it can accept (called the window
size, in bytes).
• The sender can send only that much data without waiting for an
acknowledgment.
• Example:
• Receiver sends: Window Size = 5000
• Sender can send 5000 bytes of data before it must stop and wait for an ACK.
Window management
• There are three TCP windows used in a TCP connection:
• Receive Window (RWIN)
• Homework
Quality of Services
• Quality of Service (QoS) refers to the performance level of a service,
especially in terms of data transmission between applications over a
network.
• Timely
• In order
Parameter Description