0% found this document useful (0 votes)
21 views74 pages

Transport Layer

The document covers the Transport Layer protocols, specifically UDP and TCP, highlighting their characteristics, segment formats, and functionalities. It explains the connectionless nature of UDP and the connection-oriented features of TCP, including sequence numbers, acknowledgments, and flow control mechanisms. Additionally, it details the TCP connection establishment and termination processes through a three-way handshake, along with checksum calculations and header structures.

Uploaded by

gurbakshishs30
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views74 pages

Transport Layer

The document covers the Transport Layer protocols, specifically UDP and TCP, highlighting their characteristics, segment formats, and functionalities. It explains the connectionless nature of UDP and the connection-oriented features of TCP, including sequence numbers, acknowledgments, and flow control mechanisms. Additionally, it details the TCP connection establishment and termination processes through a three-way handshake, along with checksum calculations and header structures.

Uploaded by

gurbakshishs30
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 74

Computer Networks & IOT

(18B11CS311)

Even Semester_2021

1
Transport Layer

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Inversion of source and destination
port numbers
19
20
21
22
23
2 clients using the same port (80) –
web server application
UDP
User Datagram Protocol
UDP: User Datagram Protocol
❒ “best effort” service, UDP
segments may be: Why is there a UDP?
lost
❒ no connection
delivered out of order
to app establishment (which can
❒ connectionless: add delay)
❒ simple: no connection state
no handshaking between at sender, receiver
UDP sender, receiver ❒ small segment header
each UDP segment ❒ no congestion control: UDP
handled independently can blast away as fast as
of others desired
27
UDP segment format
Checksum Concept

Receiver
Section 1 n bits
Section 2 n bits
..............
Checksum n bits
..............k n bits
Section
n bits
Checksum
Sum n bits
Packet
Complement If the result is 0, keep;
n bits otherwise, discard.
Result
30
Checksum calculation at sender
side for 7 bytes of data
Checksum calculation at receiver side
Sender sends the UDP segment Receiver receives the UDP segment
along with checksum filled correctly
Questions..
TCP
38
Stream delivery
Numbering System:

❑ Byte Number
❑Sequence number
❑Acknowledgement
number
The bytes of data being transferred in
each connection are numbered by TCP.
The numbering starts with an
arbitrarily generated number.
44
Example
Suppose a TCP connection is transferring a file of 5,000 bytes.
The first byte is numbered 10,001. What are the sequence
numbers for each segment if data are sent in five segments,
each carrying 1,000 bytes?
Solution
The following shows the sequence number for each segment:
SEGMENT

Before discussing TCP in more detail, let us discuss the TCP packets
themselves. A packet in TCP is called a segment.

MSS: Maximum Segment size

•The MSS value counts only data octets


•The maximum segment size to avoid fragmentation is equal to the largest
datagram size that any host is required to be able to reassemble minus the IP
header size and TCP header sizes.

IPv4 hosts are required to be able to handle an MSS of 536 octets (= 576- 20 - 20)

IPv6 hosts are required to be able to handle an MSS of 1220 octets (= 1280 - 40 -
20).
TCP segment structure
32 bits
URG: urgent data counting
(generally not used) source port # dest port #
by bytes
sequence number of data
ACK: ACK #
(not segments!)
valid
acknowledgement number
head not
PSH: push data now UAP RSF Receive window
len used # bytes
(generally not used) checksum Urg data pnter
rcvr willing
RST, SYN, FIN: Options (variable length) to accept
connection estab
(setup, teardown
commands) application
Internet
data
checksum
(variable
(as in
UDP) length)
Figure 15.5 TCP segment format
Sequence Number:

❒ Sequence number is 32 bits long.


❒ So the range of SeqNo is
0 <= SeqNo <= 232-1 » 4.3 Gbyte
❒ Each sequence number identifies a byte in the byte stream.
❒ Initial Sequence Number (ISN) of a connection is set during
connection establishment

• If the SYN flag is set (1), then this is the initial sequence number. The
sequence number of the actual first data byte and the acknowledged
number
in the corresponding ACK are then this sequence number plus 1.
• If the SYN flag is clear (0), then this is the accumulated sequence
number of the first data byte of this segment for the current session.
Acknowledgement Number :
❒ Acknowledgements are piggybacked, i.e. a segment from
A ->B can contain an acknowledgement for a data sent in the
B ->A direction

❒A hosts uses the AckNo field to send acknowledgements. (If


a
host sends an AckNo in a segment it sets the “ACK flag”)
Header Length ( 4bits):

❒ Length of header in 32-bit words


❒ It indicates the number of 4-byte words.
❒ The minimum size header is 5 words and the maximum is 15 words
thus giving the minimum size of 20 bytes and maximum of 60 bytes
❒ Q. Why minimum is 20 and maximum is 60.?
❒ Reserve bits are stored for future use.

Note that TCP header has variable length (with minimum 20 bytes and
maximum 60 bytes.)
Control field
Window Size:
❒ Each side of the connection advertises the window size
❒ Window size (the size of the receive window)is the maximum number of
bytes that a receiver can accept.
❒ Maximum window size is = 65535 bytes
TCP windows
The throughput of a communication is limited by two windows:
1. congestion window (for congestion control)
2. receive window (for flow control)

Each TCP segment contains the current value of the receive window.
For example a sender receives an ack which acknowledges byte 4000 and
specifies a receive window of 10000 (bytes), the sender will not send packets
after byte 14000, even if the congestion window allows it.
TCP Checksum:
❒ TCP checksum covers over both TCP header and
TCP data (also covers some parts of the IP header)

Urgent Pointer:
Only valid if URG flag is set
Used when segment contains some urgent data.

Options:
Additional information in header.
Pseudoheader added to the TCP segment

Note: The use of the checksum in TCP is mandatory.


Encapsulation

TCP Application-layer data


header

IP
heade
r

Frame
header

TCP payload
IP payload
Data-link layer payload
Question:. The following is a dump of a TCP header in
hexadecimal
format.
05320017 00000001 00000000 500207FF 00000000

a. What is the source port number?


b. What is the destination port number?
c. What the sequence number?
d. What is the acknowledgment number?
e. What is the length of the header?
f. What is the type of the segment?
g. What is the window size?
a.1330
b. 23
c. 1
d. 0
e. 5===5*4=20 bytes
f. 2===SYN
g. 2047
A TCP CONNECTION
TCP is connection-oriented. It establishes a virtual
path between the source and destination. All of the
segments belonging to a message are then sent over
this virtual path. You may wonder how TCP, which
uses the services of IP, a connectionless protocol,
can be connection-oriented. The point is that a TCP
connection is virtual, not physical. TCP operates at a
higher level. TCP uses the services of IP to deliver
individual segments to the receiver, but it controls the
Window Size

r The Window size is considered to be


one of the most important flags within
the TCP header. This field is used by
the receiver to indicate to the sender
the amount of data that it is able to
accept. The Window size field is the
key to efficient data transfers and flow
control. Used in bytes.

60
61
Connection establishment using three-way handshake

Means “no data” !


seq: 8001 if piggybacking
Note
A SYN segment cannot carry data, but
it consumes one sequence number.
A SYN + ACK segment cannot carry
data, but does consume one sequence
number.
An ACK segment, if carrying no data,
consumes no sequence number.
Data Transfer

Connection Termination
Connection termination using three-way handshake
The FIN segment consumes one
sequence number if it does
not carry data.
The FIN + ACK segment consumes one
sequence number if it does
not carry data.
Half-Close
68
Solution
(a) 2171
(b) 2172
(c) 3172
73
Question:
TCP opens a connection using initial sequence number (ISN) of 14,534. The
other party opens the connection with an ISN 21732. Show the three TCP
segments during the connection establishment.

You might also like