Unit 1
Unit 1
Unit I 1
Syllabus - Unit I
IP Header UDP Datagram
IP Fragmentation Characteristics
ARP TCP Header
RARP TCP Connection Establishment Process
ICMP Error Control
Introduction Congestion Control
Messages Flow Control
Debugging Tools Multicasting & Multicast Routing Protocols
ICMP Package Stream Control Transmission Protocol
2
𝐈𝐏 𝐇𝐞𝐚𝐝𝐞𝐫 & 𝐈𝐏 𝐅𝐫𝐚𝐠𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧
3
𝐈𝐏 𝐇𝐞𝐚𝐝𝐞𝐫 & 𝐈𝐏 𝐅𝐫𝐚𝐠𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧
IP– An Introduction
The Internet Protocol (IP) is the transmission mechanism used by the TCP/IP protocols at the
network layer Operates at higher level
5
𝐈𝐏 𝐇𝐞𝐚𝐝𝐞𝐫 & 𝐈𝐏 𝐅𝐫𝐚𝐠𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧
IP– An Introduction
example
The post office does its best to deliver the mail but does not always succeed. If an
unregistered letter is lost, it is up to the sender or would-be recipient to discover the loss
and rectify the problem.
The post office itself does not keep track of every letter and cannot notify a sender of loss
or damage.
IP is also a connectionless protocol for a packet switching network that uses the datagram
approach
This means that each datagram is handled independently, and each datagram can follow a
different route to the destination. 6
𝐈𝐏 𝐇𝐞𝐚𝐝𝐞𝐫 & 𝐈𝐏 𝐅𝐫𝐚𝐠𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧
IP Datagram
Bit 0 Bit 31
Version Hdr Len
(4) (4) TOS (8) Total Length in bytes (16)
Identification (16 bits) Flags Fragment Offset (13)
Header
(3)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any)
Data
Bit 0
Bit 31
Version Hdr Len
(4) (4) TOS (8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any) 11
𝐈𝐏 𝐇𝐞𝐚𝐝𝐞𝐫 & 𝐈𝐏 𝐅𝐫𝐚𝐠𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧
IP Packet Header
Source IP Address
Destination IP Address
18
𝐈𝐏 𝐇𝐞𝐚𝐝𝐞𝐫 & 𝐈𝐏 𝐅𝐫𝐚𝐠𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧
IP Fragmentation & Reassembly
Divide the datagram to make it possible to pass through these networks called
fragmentation.
A fragmented datagram may itself be fragmented if it encounters a network with an even
smaller MTU.
A datagram can be fragmented by the source host or any router in the path
the reassembly of the datagram, however, is done only by the destination host
19
𝐈𝐏 𝐇𝐞𝐚𝐝𝐞𝐫 & 𝐈𝐏 𝐅𝐫𝐚𝐠𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧
Identification
• – All fragments of a single datagram have the same identification
number
• Bit 0 Bit 31
Version Hdr Len
(4) (4) TOS (8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any) 20
𝐈𝐏 𝐇𝐞𝐚𝐝𝐞𝐫 & 𝐈𝐏 𝐅𝐫𝐚𝐠𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧
Flags:
– 1st bit: reserved, must be zero
– 2nd bit: DF -- Do Not Fragment
– 3rd bit: MF -- More Fragments
Bit 0 Bit 31
Version Hdr Len
(4) (4) TOS (8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any) 21
𝐈𝐏 𝐇𝐞𝐚𝐝𝐞𝐫 & 𝐈𝐏 𝐅𝐫𝐚𝐠𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧
• Fragment Offset (in units of 8 bytes)
– Used for reassembly of packet
– 1st fragment has offset = 0
Bit 0 Bit 31
Version Hdr Len
(4) (4) TOS (8) Total Length in bytes (16)
Identification (16 bits) Flags (3) Fragment Offset (13)
Time to Live (8) Protocol (8) Header Checksum (16)
Source IP Address
Destination IP Address
Options (if any) 22
𝐈𝐏 𝐇𝐞𝐚𝐝𝐞𝐫 & 𝐈𝐏 𝐅𝐫𝐚𝐠𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧
IP Fragmentation Example
23
𝐈𝐏 𝐇𝐞𝐚𝐝𝐞𝐫 & 𝐈𝐏 𝐅𝐫𝐚𝐠𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧
IP Fragmentation Example
length ID MF offset
=4000 =x =0 =0
length ID MF offset
=1500 =x =1 =0
length ID MF offset
=1500 =x =1 =1480
length ID MF offset
=1040 =x =0 =2960 24
𝐈𝐏 𝐇𝐞𝐚𝐝𝐞𝐫 & 𝐈𝐏 𝐅𝐫𝐚𝐠𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧
Multiple Fragmenting Points
Detailed
fragmentation
example 26
𝐈𝐏 𝐇𝐞𝐚𝐝𝐞𝐫 & 𝐈𝐏 𝐅𝐫𝐚𝐠𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧
The figure shows what happens if a fragment itself is fragmented.
In this case the value of the offset field is always relative to the original datagram.
a. The first fragment has an offset field value of zero.
b. Divide the length of the first fragment by 8. The second fragment has an offset
value equal to that result.
c. Divide the total length of the first and second fragment by 8. The third fragment
has an offset value equal to that result.
d. Continue the process. The last fragment has a more bit value of 0.
27
ARP & RARP
28
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Logical Addresses
The hosts and routers are recognized at the network level by their logical
addresses
The logical addresses in the TCP/IP are called IP address and are 32 bits
long
29
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Physical Address
However, hosts/routers are recognized at the physical layer by their physical
address
A physical address is an local address
Called a physical address because it is usually implemented in hardware
Examples
48-bit MAC addresses in Ethernet
30
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Translation
We need both the physical address and the logical address for packet delivery.
Thus, we need to be able to map a logical address to its corresponding physical
address and vice versa
Solutions
Static mapping
Dynamic mapping
31
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Static Mapping
Create a table that associates a logical address with a physical address and store
in each machine
However, physical addresses may change A machine could change its NIC
resulting in a new physical address
In some LANs, such as Local Talk, the physical address changes every time the
computer is turned on.
A mobile station can move from one physical network to another, resulting in a
change in its physical address 32
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Dynamic Mapping
Use a protocol to find another address
ARP: Address Resolution Protocol
33
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
ARP and RARP
34
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Position of ARP and RARP in TCP/IP Protocol Suite
35
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
ARP Operation
To find the physical address of another host or router on its network
38
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
ARP Packet
39
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Packet Format
HTYPE (Hardware type)
Packet Format
THA (Target hardware address)
Type field indicates that the data carried by the frame is an ARP packet
45
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Operations
The message is passed to the data link layer to encapsulate in a data link frame
All machines’ ARP except the one targeted drop the packet
The target reply with an ARP reply message that contains its physical address and
is unicast
The sender receives the reply message and knows the target’s physical address
47
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Four Cases to Use ARP
Case 1: The sender is a host and wants to send a packet to another host on the same
network
Case 2: The sender is a host and wants to send a packet to another host on another network
Find the IP address of the next hop (router) for this destination
49
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Four Cases Using ARP: Case 2
50
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Four Cases to Use ARP
Case 3: the sender is a router and received a datagram destined for a host on
another network
Router check its routing table & find the IP address of the next router
Case 4: the sender is a router that has received a datagram destined for a host
in the same network
52
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Four Cases Using ARP: Case 4
53
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
54
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Example 1
A host with IP address 130.23.43.20 and physical address 0xB23455102210
Show the ARP request and reply packets encapsulated in Ethernet frames
55
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Example 1
56
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Example 1
57
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Proxy ARP
Used to create a subnetting effect
If it receives an ARP request message looking for the address of one of these host
Router sends an ARP reply announcing its own hardware (physical) address
After the router receives the actual IP packet, It sends the packet to the
appropriate host or router 58
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Example
Administrator need to create a subnet without changing the whole system
Add a router running a proxy ARP
59
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP– An Introduction
Proxy ARP
60
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP–Package
Five components in an ARP package
A cache table
Queues
An output module
An input module
A cache-control module
61
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP–Package
ARP COMPONENTS
62
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP–Package
CACHE TABLE
Inefficient to use ARP to each datagram destined for the same host or router
63
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP–Package
Content of a Cache Table Entry State:
FREE: the lime-to-live for this entry has expired
PENDING: a request for this entry has been sent, but the reply has not yet been received
RESOLVED: the entry is complete and valid
Hardware type
Protocol type
Hardware length
Protocol length
Above fields are all the same as in the ARP packet 64
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP–Package
Interface number
Queue number: ARP uses numbered queues to enqueuer the packet waiting for address
resolution
Attempts: the number of times an ARP request is sent out for this entry
Interface number
Queue number: ARP uses numbered queues to enqueuer the packet waiting for
address resolution
Attempts: the number of times an ARP request is sent out for this entry
ARP package maintains a set of queues to hold the IP packets while ARP tries to
resolve the hardware address
Packets for the same destination are usually enqueued in the same queue
The input module removes a packet from the queue and sends it, with the resolved
physical address, to data link layer for transmission
67
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP–Package
Output Module
Wait until an IP packet from the IP software
Check the cache table if receiving a IP packet
If found and state = RESOLVED
Passed to the data link layer for transmission
If found and state = PENDING
Send packet to this queue and wait
If not found
Create an entry with state = PENDING
Create a queue and enqueue this packet
Send an ARP request
68
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP–Package
Input Module
Wait until an ARP packet (request or reply) arrives and check the cache table
Dequeue the packets from the corresponding queue and set them to the data link
layer
69
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP–Package
Input Module (Conti…)
This is because the target hardware address could have been changed
If not found
Maintain the cache table by periodically check the cache table, entry by entry
If state is PENDING
Else
If state is RESOLVED
If (time-out <= 0)
If state is FREE
P 12 1 220.55.5.7
F
R 9 60 19.1.7.82 4573E3242ACA
P 18 3 188.11.8.71
73
The McGraw-Hill Companies, Inc., 2000
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP–Package
Example 2
The ARP output module receives an IP datagram from the IP layer with the
destination address 114.5.7.89
It checks the cache table and finds that an entry exists for this destination with the
RESOLVED state
It extracts the hardware address, which is 457342ACAE32, and sends the packet and
the address to the data link layer
74
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP–Package
Example 3
Twenty seconds later, the ARP output module receives an IP datagram from the IP
layer with the destination address 116.1.7.22.
It checks the cache table and does not find this destination in the table
The module adds an entry to the table with the state PENDING and the Attempt
value 1
It also creates a new queue for this destination and enqueues the packet
It then sends an ARP request to the data link layer for this destination
75
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
Cache table for Example 3
State Queue Attempt Time-out Protocol Addr. Hardware Addr.
R 5 900 180.3.6.1 ACAE32457342
P 2 2 129.34.4.8
P 14 5 201.11.56.7
R 8 450 114.5.7.89 457342ACAE32
P 12 1 220.55.5.7
P 23 1 116.1.7.22
R 9 60 19.1.7.82 4573E3242ACA
P 18 3 188.11.8.71 76
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP–Package
Example 4
Fifteen seconds later, the ARP input module receives an ARP packet with target
protocol (IP) address 188.11.8.71
The module checks the table and finds this address
It changes the state of the entry to RESOLVED and sets the time-out value to 900
The module then adds the target hardware address (E34573242ACA) to the entry
Now it accesses queue 18 and sends all the packets in this queue, one by one, to the
data link layer
77
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
Cache table for Example 4
State Queue Attempt Time-out Protocol Addr. Hardware Addr.
R 5 900 180.3.6.1 ACAE32457342
P 2 2 129.34.4.8
P 14 5 201.11.56.7
R 8 450 114.5.7.89 457342ACAE32
P 12 1 220.55.5.7
P 23 1 116.1.7.22
R 9 60 19.1.7.82 4573E3242ACA
P 18 3 188.11.8.71 78
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP–Package
Example 5
The time-out values for the first three resolved entries are decremented by 60
The state of the next-to-the last entry is changed to FREE because the time-out is zero
79
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
ARP–Package
Example 5 (Conti…)
For each of the three pending entries, the value of the attempts field is
incremented by one
Then, the attempts value for one entry (the one with IP protocol address
201.11.56.7) is more than the maximum
the state is changed to FREE, the queue is deleted
80
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
Cache table for Example 5
State Queue Attempt Time-out Protocol Addr. Hardware Addr.
R 5 840 180.3.6.1 ACAE32457342
P 2 3 129.34.4.8
F
R 8 390 114.5.7.89 457342ACAE32
P 12 2 220.55.5.7
P 23 2 116.1.7.22
F
R 18 875 188.11.8.71 E34573242ACA 81
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
RARP–Package
Obtain its logical address by the physical address using the RARP protocol
82
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
RARP–Package
F
RARP RARP Operation
83
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
RARP–Package
F
84
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
RARP–Package
Packet Format
The format of the RARP packet is the same as the ARP packet
85
F
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
RARP–Package RARP Packet
86
F
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
RARP–Package
87
𝒜𝑅𝒫 & 𝑅𝒜𝑅𝒫
RARP
Alternative Solutions to RARP
ICMP Encapsulation 92
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– Message
ICMP message is of Two categories:
Error-reporting Messages
This report problems that a router or a host may encounter when it
processes an IP packet.
The query messages
helps network manager get specific information from a router or another
host.
For example, nodes can discover their neighbors.
93
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– Message
ICMP Messages
94
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– Message format
8-byte header
variable-size data section.
The first field, ICMP type, defines the type of the
message.
The code specifies the reason for the particular message type.
The checksum field .
The rest of the header is specific for each message type.
The data section in error messages carries information for finding the original packet
that had the error 95
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– Message format
96
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
97
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
Error-
reporting
messages
Destination-unreachable format
99
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
Destination Unreachable
The code field for this type specifies the reason for discarding the datagram:
Code 0. The network is unreachable, possibly due to hardware failure
Code 1. The host is unreachable. This can also be due to hardware failure 100
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
Destination Unreachable
Code 2. The protocol is unreachable. An IP datagram can carry data belonging to
higher-level protocols such as UDP, TCP, and OSPF. If the destination host receives a
datagram that must be delivered, for example, to the TCP protocol, but the TCP
protocol is not running at the moment, a code 2 message is sent.
Code 3. The port is unreachable. The application program (process) that the datagram
is destined for is not running at the moment.
101
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
Destination Unreachable
Code 4. Fragmentation is required, but the DF (do not fragment) field of the datagram
has been set. In other words, the sender of the datagram has specified that the
datagram not be fragmented, but routing is impossible without fragmentation.
Code 5. Source routing cannot be accomplished. In other words, one or more routers
defined in the source routing option cannot be visited.
Code 6. The destination network is unknown. This is different from code 0. In code 0,
the router knows that the destination network exists, but it is unreachable at the
moment. For code 6, the router has no information about the destination network.102
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
Destination Unreachable
Code 7. The destination host is unknown. This is different from code 1. In code 1, the
router knows that the destination host exists, but it is unreachable at the moment. For
code 7, the router is unaware of the existence of the destination host.
Code 8. The source host is isolated.
Code 9. Communication with the destination network is administratively prohibited.
Code 10. Communication with the destination host is administratively prohibited.
103
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
Destination Unreachable
code 11. The network is unreachable for the specified type of service. This is different
from code 0. Here the router can route the datagram if the source had requested an
available type of service.
Code 12. The host is unreachable for the specified type of service. This is different
from code 1. Here the router can route the datagram if the source had requested an
available type of service.
Code 13. The host is unreachable because the administrator has put a filter on it.
104
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
Destination Unreachable
Code 14. The host is unreachable because the host precedence is violated. The
message is sent by a router to indicate that the requested precedence is not permitted
for the destination.
Code 15. The host is unreachable because its precedence was cut off. This message is
generated when the network operators have imposed a minimum level of precedence
for the operation of the network, but the datagram was sent with a precedence below
this level.
105
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
Source Quench
There is no flow-control or congestion-control mechanism in the IP protocol.
A source-quench message informs the source that a datagram has been discarded
due to congestion in a router or the destination host.
The source must slow down the sending of datagrams until the congestion is
relieved.
107
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
Time Exceeded
In a time-exceeded message, code 0 is used only by routers to show that the value of
the time-to-live field is zero. Code 1 is used only by the destination host to show that
not all of the fragments have arrived within a set time.
108
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
Parameter Problem
If a router or the destination host discovers an ambiguous or missing value in any field
of the datagram, it discards the datagram and sends a parameter-problem message
back to the source.
Code 0. There is an error or ambiguity in one of the header fields. In this case, the
value in the pointer field points to the byte with the problem. For example, if the value
is zero, then the first byte is not a valid field.
Code 1. The required part of an option is missing. In this case, the pointer is not used.
109
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
A host usually starts with a small routing table that is gradually augmented and
updated. One of the tools to accomplish this is the redirection message..
Code 0. Redirection for a network-specific route.
Code 1. Redirection for a host-specific route.
Code 2. Redirection for a network-specific route based on a specified type of service.
Code 3. Redirection for a host-specific route based on a specified type of service
An echo-request message can be sent by a host or router. An echo-reply message is
sent by the host or router that receives an echo-request message.
110
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
111
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
Echo Request And Reply
112
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
Timestamp Request and Reply
The timestamp-request and timestamp-reply messages to determine the round-
trip time needed for an IP datagram to travel between them
sending time = receive timestamp − original timestamp
receiving time = returned time − transmit timestamp
round-trip time = sending time + receiving time
114
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
Timestamp Request and Reply
original timestamp: 46 receive timestamp: 59
transmit timestamp: 60 return time: 67
sending time = 59 − 46 = 13 milliseconds
receiving time = 67 − 60 = 7 milliseconds
round-trip time = 13 + 7 = 20 milliseconds
Time difference = receive timestamp − (original timestamp field + one-way time
duration)
Time difference = 59 − (46 + 10) = 3
115
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
Checksum Calculation
The sender follows these steps using one’s complement arithmetic:
1. The checksum field is set to zero.
2. The sum of all the 16-bit words (header and data) is calculated.
3. The sum is complemented to get the checksum.
4. The checksum is stored in the checksum field.
116
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– MESSAGE FORMAT
Checksum Testing
The receiver follows these steps using one’s complement arithmetic:
1. The sum of all words (header and data) is calculated.
2. The sum is complemented.
3. If the result obtained in step 2 is 16 0s, the message is accepted; otherwise, it is
rejected.
117
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– DEBUGGING TOOL
ICMP_Input_module (ICMP_Packet)
{
If (the type is a request)
{
Create a reply
Send the reply
}
If (the type defines a redirection)
{
Modify the routing table
}
If (the type defines other error messages)
{
Inform the appropriate source protocol
}
Return
}
129
𝕴𝖓𝖙𝖊𝖗𝖓𝖊𝖙 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕸𝖊𝖘𝖘𝖆𝖌𝖊 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕴𝕮𝕸𝕻)
ICMP– Package
An ICMP message cannot be
Package cont.. created for four situations:
Output Module an IP packet carrying an ICMP
Responsible for creating request, error message.
solicitation, or error messages requested by a fragmented IP packet.
a higher level or the IP protocol. A multicast IP packet.
receives a demand from IP,UDP, or TCP to an IP packet having IP address
send one of the ICMP error messages. 0.0.0.0 or 127.X.Y. Z.
IP request is first allowed
130
Output Module Pseudo code
ICMP_Output_Module (demand)
{
If (the demand defines an error message)
{
If (demand comes from IP AND is forbidden)
{
Return
}
If (demand is a valid redirection message)
{
Return
}
Create an error message
If (demand defines a request)
{
Create a request message
}
Send the message
Return
} 131
132
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP – An Introduction
Connectionless service
Unreliable transport protocol.
No flow control / No Acknowledgement
Process to Process communication
Powerless
It uses minimum of over heads
No reliability is obtained using UDP
Less interaction between sender and receiver
133
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
USER DATAGRAM
135
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Datagram various fields
Length:
UDP length=IP length – IP headers Length
Length field specifies the entire length of UDP packet (including header).
It is 16-bits field and minimum value is 8-byte, i.e. the size of UDP header
itself.
A user datagram is encapsulated in an IP datagram.
Checksum:
• This field is used to detect errors over the entire user datagram (header
plus data) 136
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Services
Process to Process communication
UDP provides process-to-process communication using sockets, a combination of IP
addresses and port numbers. Several port numbers used by UDP.
137
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Services cont…
cannot send a stream of data to
Connectionless services: UDP, It will chop them into
Connectionless service. differentrelated user datagrams.
Flow control:
Each datagram is independent
No Flow Control and no window
even it comes from same source
mechanism.
and delivered in same destination.
The receiver may overflow with
The datagrams are not numbered.
incoming messages.
No connection establishments is
UDP should provide for this
done
service, if needed 138
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Services cont…
Error Control: Checksum
Three sections: a pseudo header, the
No Error control mechanism UDP header, and the data coming
except for checksum from the application layer.
Decapsulation:
At the destination host:
the physical layer decodes the
signals pass to data link layer.
The data link layer uses the
header (and the
trailer) to check the data.
If there is no error
the header and trailer are
dropped , datagram is passed to
IP.
Encapsulation and Decapsulation
142
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Services cont…
The header is dropped and the user datagram is passed to UDP with the sender
and receiver IP addresses.
Checksum is to check the entire user datagram.
the header is dropped and the application data along with the sender socket
address is passed to the process.
The sender socket address is passed to the process in case it needs to respond to
the message received.
143
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Services cont…
Queuing in UDP
144
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Services cont…
Queuing in UDP
At the client site, when a process starts, it requests a port number from the
operating system. Some implementations create both an incoming and an outgoing
queue associated with each process. Other implementations create only an
incoming queue associated with each process
process wants to communicate with multiple processes, it obtains only one port
number and eventually one outgoing and one incoming queue. The queues opened
by the client are, in most cases, identified by ephemeral port numbers. The queues
function as long as the process is running. When the process terminates, the queues
are destroyed.
The client process can send messages to the outgoing queue by using the source
port number specified in the request
145
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Services cont…
Queuing in UDP
The client process can send messages to the outgoing queue by using the source
port number specified in the request
UDP removes the messages one by one and, after adding the UDP header, delivers
them to IP. An outgoing queue can overflow
It happens the operating system can ask the client process to wait before sending
any more messages
146
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Services cont…
Applications of UDP:
Used for simple request response communication when size of data is less hence there
is lesser concern about flow and error control.
It is suitable protocol for multicasting as UDP supports packet switching.
Following implementations uses UDP as a transport layer protocol:
NTP (Network Time Protocol)
DNS (Domain Name Service)
BOOTP, DHCP.
NNP (Network News Protocol)
Quote of the day protocol
TFTP, RTSP, RIP, OSPF.
UDP is null protocol if you remove checksum field. 147
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Services cont…
148
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Package
UDP design
149
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Package
The UDP package involves five components:
Control-Block Table
Each entry in this table has a minimum of four fields: the state, which can be FREE
or IN-USE, the process ID, the port number, and the corresponding queue number.
Input Queues
Our UDP package uses a set of input queues, one for each process. In this design, we
do not use output queues.
150
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Package
UDP_Control_Block_Module (process ID, port
Control-Block Module number)
The control-block module is {
responsible for the management of the Search the table for a FREE entry.
if (not found)
control-block table. Delete one entry using a predefined strategy.
When a process starts, it asks for a port Create a new entry with the state IN-USE
number from the operating system. Enter the process ID and the port number.
Return.
The operating system assigns well- } // End module
known port numbers to servers and
ephemeral port numbers to clients.
The process passes the process ID and
the port number to the control-block
module to create an entry in the table
for the process.
151
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP_INPUT_Module (user_datagram)
UDP Package {
Look for the entry in the control_block table
Input Module if (found)
The input modulereceives a user {
Check to see if a queue is allocated
datagram from the IP. It searches If (queue is not allocated)
the control-block table to find an allocate a queue
entry having the same port else
number as this user datagram. enqueue the data
} //end if
If the entry is found, the module else
uses the information in the entry {
to enqueue the data.If the entry is Ask ICMP to send an "unreachable port" message
not found, it generates an ICMP Discard the user datagram
} //end else
message.. Return.
} // end module
152
𝖀𝖘𝖊𝖗 𝕯𝖆𝖙𝖆𝖌𝖗𝖆𝖒 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝖀𝕯𝕻)
UDP Package
Output Module
The output module is responsible for creating and sending user datagrams.
UDP_OUTPUT_MODULE (Data)
{
Create a user datagram
Send the user datagram
Return.
}
153
TCP Header
154
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Segment
A packet in TCP is called a Segment
Segment – Format
Header - 20 to 60 Bytes
In case of no options Header is of size 20 bytes
When options are used Header size extends up to 60 Bytes
Data from application program
157
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Header Contd…
i. Source Port Address iii. Sequence Number
16 bit Field 32 bit field
Defines port number of application Defines number of first byte of data
program in host sending the segment contained in Segment
ii. Destination Port Address Each byte is numbered for
16 bit Field connectivity reasons
Defines port number of application Sequence number provides
program in host receiving the information regarding the first byte of
segment segment to destination host
158
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Header Contd…
iv. Acknowledgement Number v. Header Length
32 bit Field 4 bit Field
Defines the byte number the receiver Indicates number of 4 byte words in
expects to receive from senders Header
If ‘n’ bytes are received from sender Value of header length varies between
‘n+1’ is sent as acknowledgement 5 (5 x 4 = 20) and 20 (20 x 4 = 60)
number vi. Reserved
Acknowledgment and Data go hand in 6 bit field
hand Reserved for future use
159
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Header Contd…
vii. Control
6 bit Field
Defines 6 unique control bits / flags
Can be set one / more at a time
Enables
Control Field of TCP Header
Flow Control
Connection Establishment, Termination
and Abortion
Mode of TCP Data transfer
160
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Header Contd…
viii. Window Size ix. Urgent Pointer
16 bit Field 16 bit field
Maximum Window Size: 65, 535 bytes Used only if urgent data is part of
Defines Window size of sending TCP segment
Determined by Receiver Valid only when urgent flag is set
Referred as (rwnd ) x. Options
Sender must adhere to the window Can accommodate up to 40 bytes of
size fixed by the receiver optional information
161
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Header Contd…
xi. Checksum
16 bit field
Mandatory in TCP
Detects error over entire TCP
Pseudoheader added to segment
166
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
i. Connection Establishment Contd…
Step 1
Client is in active open mode
Client sends first SYN segment and sets flag to SYN
Initial Sequence Number (ISN) : 8000 (Random Number) sent to Server
SYN segment (Control Segment) carries no data
SYN segment consumes one Sequence number
Note: No ACK / Window Size sent along with ISN
167
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
i. Connection Establishment Contd…
Step 2
Server sends second segment (SYN + ACK) and sets flag to SYN & ACK
ACK - Server acknowledges receipt of first segment from Client
SYN – Segment for communication from Server to Client
New Sequence Number : 15000 (Random Number)
Acknowledgement Number for Segment from client: 8001 (Inc. by 1)
Window Size (rwnd): Set to 5000 by Server (to be used by Client)
(SYN+ACK) segment consumes one Sequence number 168
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
i. Connection Establishment Contd…
Step 3
Client sends third segment (ACK) and sets ACK flag
ACK – Client acknowledges receipt of second segment from Server
Sequence Number : 8000 (Used in first Segment)
Acknowledgement Number for Segment from Server: 15001 (Inc. by 1)
Window Size (rwnd) : Set to 10000 by Client (to be used by Server)
(ACK) segment consumes no Sequence number
169
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
i. Connection Establishment Contd…
Synchronous Flooding Attack
Type of Denial of Service Attack (DoS)
Malicious attackers send large count of SYN segments to a Server
SYN segments pretend to come from various Clients using different IP Address
Server assumes that Clients are in active open mode and allocates resources
Server Sends SYN + ACK segments to fake clients and waits for response
Server runs out of resources and is unable to accept connection requests from
legitimate clients 170
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
i. Connection Establishment Contd…
Simultaneous Open
Client and Server issues active open mode (Rare Phenomenon)
SYN + ACK segment sent from Client to Server and vice versa
171
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
ii. TCP Data Transfer
Data transfer is bidirectional after connection is established
Data and acknowledgements can be sent between client and server bidirectionally
Example (After Connection Establishment)
Client transmits 2000 bytes of data in 1st and 2nd segment to the Server
Push flag (PSH) & ACK flags set for Data Segments sent by client
Segment 1: seq(8001), ack(15001), A & P flags set, Data bytes (8001-9000)
Segment 2: seq (9001), ack (15001), A & P flags set, Data bytes (9001 –
10000) 172
Server sends 2000 bytes of
data in the 3rd segment
Segment 3: seq (15001), ack
(10001), A flag set, Data bytes
(15001 – 17000)
ACK flag set & SYN flag not
set for data segments sent
by server
Segment 4: seq (10001), ack
(17001), A flag set, rwnd
(10000)
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
Data Transfer in TCP 173
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
ii. TCP Data Transfer Contd…
Flexibility of TCP
Sending TCP uses buffer to store incoming data stream from applications
Receiving TCP uses buffer to store arriving data and send to applications
Disadvantage: Delayed delivery of data
Pushing Data
Sending TCP creates an segment and transfers immediately by setting PSH bit
PSH bit indicates that receiving TCP must deliver the received data segment to
application program immediately 174
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
ii. TCP Data Transfer Contd…
Data presented from application program to TCP as stream of bytes
Consecutive positions assigned to each byte of data
Exception: Application program needs to send Urgent bytes that needs to be
specially treated (With top priority)
Solution: Urgent Data
Send a data segment by setting the URG bit
Urgent data inserted at segment beginning by the sending TCP
End of the urgent data in segment indicated by urgent pointer field in header
175
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
ii. TCP Data Transfer Contd…
Segment with URG bit is received by the receiving TCP
Receiving TCP informs receiving application of the segment with URG bit
176
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
iii. TCP Connection Termination
Connection termination initiated by the Client by default
However, Server can also choose to close the TCP connection with client
Options for connection termination
a) 3-way Handshaking
b) 4-way Handshaking with Half-Close Option
177
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
a) Connection Termination using 3-way Handshaking
Passive Close – Server program informs TCP that it is ready to close connection
Active Close – Client program intending to close connection to a Server informs
TCP
Step 1
Client process sends close command to Client TCP
Client TCP sends 1st Segment (FIN) with FIN flag and ACK flag set
FIN Segment consumes one sequence number (if it carries no data)
Note: FIN segment may carry last chunk of data also 178
Connection
Termination
using 3-way
Handshaking
179
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
d) A TCP Connection Contd…
a) Connection Termination using 3-way Handshaking
Step 2
Server TCP sends 2nd segment (FIN + ACK) to confirm receipt of FIN segment
Server announces connection closing from its side
2nd Segment may contain last chunk of data
Step 3
Client TCP sends 3rd segment (ACK) that confirms FIN receipt from Server
Acknowledgment number – Sequence number + 1
3rd Segment cannot carry data 180
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
b) Half Close Connection Termination
Half Close – In client / Server communication if one can stop sending data while
the other can send data it is called an Half-Close
The Client or Server can issue a Half-Close request
Example – Sorting
Client sends data for sorting to Server
Client closes connection in Client-Server direction
Server receives data from client & keeps connection open
Till Sorting is completed & result sent back to Client 181
Half-Close
182
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
iv. TCP Connection Reset
Reset Flag (RST) - Denies connection / Aborts connection / Terminates existing
idle connection
Denying Connection
Client requests to a non-extent server port
Server sends segment with RST flag set and denies request
Aborting Connection
Client / Server TCP aborts existing connection by sending RST segment to
abort connection 183
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
A TCP Connection Contd…
iv. TCP Connection Reset Contd…
Termination Idle Connection
Client finds server idle or vice versa
Client / Server sends RST segment to terminate connection
Similar to abort
184
TCP Flow
Control
185
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Flow Control
Creates a balance between rate of data production and the rate of data consumption
Assumption: Channel between sender & receiver is error-free
189
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Flow Control Contd…
Scenario – TCP Flow Control
Segment 3
ACK segment sent from client to server
Segment 4
Client sets window size to 800 (since rwnd from server is 800)
Client process pushes 200 bytes of data to TCP client
TCP client creates data segment with bytes (101-300) and sends to Server
Client window adjusted
Shows 200 bytes as sent but no ACK received from Server 190
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Flow Control Contd…
Scenario – TCP Flow Control
Shows 200 bytes as sent but no ACK received from Server
Server stores 200 bytes in buffer & closes receive window
Server indicates the next expected byte as 301
Segment 5
Server acknowledges receipt of 200 bytes from client & reduces rwnd to 600
Client receives acknowledgement and resizes window size to 600
Client closes the window (101-300) from left to right
Client indicates the next byte to send as 301 191
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Flow Control Contd…
Scenario – TCP Flow Control
Segment 6
Client pushes 300 more bytes to the server (Seq. No = 301 & Data = 300 bytes)
Server stores 300 bytes in buffer
100 bytes of data are pulled by the Client process
So, Window size is reduced by 100 bytes to the left & opened by 100 bytes to the
right
Overall, TCP client window size is reduced by 200 bytes
Now, Receiver window size (rwnd) = 400 192
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Flow Control Contd…
Scenario – TCP Flow Control
Segment 7
TCP Server acknowledges receipt of 300 bytes and sets window size (rwnd) =
400 & TCP Client reduces window size to 400
Sender windows closes by 300 bytes from the left and opens by 100 bytes to the
right
This process continues until all the data segments are sent from server to client and
connection gets closed
193
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Flow Control Contd…
Shrinking of Windows
Shrinking : Decreasing window size i.e., right wall moves towards the left
Sender window may shrink based on rwnd value defined by receiver
Receiver window cannot shrink
Illustration
Upto 205 bytes of data received and acknowledged by sender
Last advertised rwnd = 12 (Window size) & last advertised ACK No = 206
Data can be sent from byte 206 to byte 217 (Since rwnd = 12)
New advertised rwnd = 12 (Window size) & new advertised ACK No = 210
194
The window after the new advertisement; Window has shrunk
195
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Flow Control Contd…
Shrinking of Windows Contd…
Shrinking of window has occurred from byte 217 to byte 213 (Window had
moved from right to left
Shrinking can be prevented by the relation given below:
New ACK number + new rwnd > = Lask ACK Number + Last rwnd
To prevent shrinking,
Wait until enough buffer locations are available in its window
196
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Flow Control Contd…
Silly Window Syndrome
Occurs when either the sending process creates data slowly (or) the receiving
process consumes data slowly (or) both
Silly window syndrome sends / receives data in small segments thus resulting in
poor efficiency
Example
A 42 byte TCP datagram is needed to send Segment with 2 bytes of data
Overhead : 42 / 2 ⇒ Network capacity used inefficiently
197
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Flow Control Contd…
Silly Window Syndrome Created by Sender
Sending TCP creates syndrome since sending application program creates data
slowly i.e., 1 byte at an instance
Suggestions
Prevent sending TCP from transmitting data byte by byte
Sending TCP made to wait & collect data to send data in larger block
Disadvantage: Waiting too long delays the process
Solution
Nagle’s Algorithm 198
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Flow Control Contd…
Nagle’s Algorithm for Silly Window Syndrome Created by Sender
i. First segment of data sent by sending TCP irrespective of the size of segment
ii. Data is accumulated in buffer by sending TCP until acknowledgment is received
from receiving TCP (or) enough data accumulated to send a segment
iii. Repeat step 2 until transmission completes
Nagle’s algorithm works based on speed of application program and the network
speed
Faster the application program larger the segment size
Advantage: Simple to implement 199
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Flow Control Contd…
Silly Window Syndrome Created by Receiver
Syndrome created when serving application consumes slowly
Example
1 KB data blocks created by sending application
1 byte of consumed at a time by receiving application
Once sending window buffer is full, window size (rwnd) becomes 0
Solution 1: Clarks’s Solution
Send ACK as data segment arrives
Set rwnd = 0 iff receive buffer is half empty (or) there is enough space 200
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Flow Control Contd…
Silly Window Syndrome Created by Receiver Contd…
Solution 2: Delayed Acknowledgment
Acknowledgement is withheld when segment arrives
Receiver waits for space in incoming buffer before acknowledging
Delayed ACK prevents sending TCP from sliding
Delayed ACK reduces network traffic
Note: ACK not to be delayed by more than 500 ms
201
TCP Error
Control
202
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Error Control
TCP – Reliable Transport layer Protocol
Entire data stream to be delivered without error / loss / duplication
Reliability is provided by TCP using Error Control
Error Control includes:
Finding and resending corrupted segments
Resending lost segments
Storing out-of-order segments till missed segments arrive
Discarding duplicate segments
Error control achieved by: Checksum, Acknowledgement and Time-out 203
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Error Control Contd…
a) Checksum
TCP uses 16-bit mandatory checksum field
Checksum field associated with each segment
Checks for corrupted segment
Invalid Checksum: Segment discarded by receiving TCP & considered lost
204
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Error Control Contd…
b) Acknowledgement
Acknowledgement segments (ACK) carry no data & confirms data segment receipt
Types : Cumulative and Selective Acknowledgment
Cumulative Acknowledgment (ACK)
32-bit ACK field used
Acknowledges segments cumulatively (sets ACK flag to 1)
No feedback provided for discarded, lost or duplicate segments
Selective Acknowledgement (SACK)
Reports out of order & duplicate segments 205
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Error Control Contd…
b) Acknowledgement Contd…
No provision for SACK in TCP header
SACK included as part of options field in the TCP header
Rules for Generating Acknowledgments
1) When data is sent from sender to receiver, ACK provides the next Seq. No
expected to be received
This results in less traffic and less segments between sender and receiver
2) In case of one in-order segment remaining, receiver needs to delay sending ACK
segment. Network traffic is thus reduced. 206
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Error Control Contd…
b) Acknowledgement Contd…
3) At no point of time there should be more than two in-order segments
unacknowledged. (Thwarts unnecessary retransmission)
4) Receiver acknowledges (ACK) an higher out-of-order sequence number
immediately leading to fast retransmission of next segment
5) Receiver sends ACK when a missing segment arrives. Segments reported as
missing are thus informed to the receiver
6) Receiver discards duplicate segment & sends ACK indicating the next in-order
segment. Lost ACK segment problems are thus solved. 207
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Error Control Contd…
c) Retransmission of Segments
When retransmission occurs?
Expiry of retransmission timer (or)
Sender receives more than 2 duplicate ACK’s for 1st segment
Retransmission after RTO
One retransmission time-out (RTO) maintained by sending TCP for each
connection
In case of time-out, timer is restarted by TCP & first segment of Queue is sent
This version of TCP is called Tahoe 208
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Error Control Contd…
c) Retransmission of Segments Contd…
Retransmission after 3 Duplicate Segments
Also called as Fast Retransmission & followed by most implementations
TCP version called as Reno
If 3 identical duplicate ACK’s along with the original ACK are received for a
segment, the next segment is retransmitted
Note: Retransmission does not wait for time-out in this case
209
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Error Control Contd…
d) Out-of-Order Segments
Out-of-Order segments are not discarded by TCP
TCP flags such segments as out-of-order and store them temporarily until missing
segments arrive
TCP makes sure that data segments are delivered in sequence to the process
210
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Error Control Contd…
e) FSM for Data Transfer in TCP
FSM – Finite State Machine
Similar to Selective repeat and Go Back-N protocol
Sender-side & Receiver Side FSM
Assumption : Unidirectional communication
Ignored Parameters: Selective ACK and Congestion Control
Nagle’s algorithm / Windows shutdown not included in FSM
Advantage: Fast transmission policy using 3 duplicate ACK segments
Bi-directional FSM : Complex and more practical 211
Simplified
FSM for TCP
Sender Side
212
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
Simplified
FSM for TCP
Receiver
Side
213
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
TCP Congestion
Control
214
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Congestion Control
Congestion window and congestion policy handles TCP congestion
a) Congestion Window
Client window size (rwnd) decided by the available buffer space of Server
Ignored entity in deciding window size : Network Congestion
Sender window size determined by,
rwnd (receiver advertised window size) &
cwnd (Congestion window size)
218
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Congestion Control Contd…
b) Congestion Policy
i. Slow Start (Exponential Increase) contd…
Initial value of cwnd = 1 MSS
No of MSS sent No of Segments RTT cwnd in MSS
Acknowledged
Nil Nil - 1
1 1 1 1 x 2 = 2 ⇒ 21
2 2 2 2 x 2 = 4 ⇒ 22
4 4 3 4 x 2 = 8 ⇒ 23
8 8 4 8 x 2 = 16 ⇒ 24219
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Congestion Control Contd…
b) Congestion Policy
i. Slow Start (Exponential Increase) contd…
For Delayed Acknowledgements
If multiple segments are acknowledged accumulatively, cwnd increases by 1
Example: if ACK = 4 them cwnd = 1
Growth is exponential but not to the power of 2
Slow start stops with a threshold value ssthresh
It stops when window size = = ssthresh
220
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Congestion Control Contd…
b) Congestion Policy
ii. Congestion Avoidance : Additive Increase
Slow start increases congestion window size (cwnd) exponentially
Congestion avoidance increases cwnd additively
Additive phase begins when slow start reaches ssthresh i.e. cwnd = I
Increase in cwnd is based on RTT & not on number of ACK’s
222
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Congestion Control Contd…
b) Congestion Policy
iii. Congestion Detection : Multiplicative Decrease
Size of Cwnd must be decreased in case of congestion
Retransmission occurs during missing segments / lost segments
Retransmission helps identify whether congestion has occurred or not
Retransmission occurs when
There is RTO Time-out
On receipt of three duplicate ACK’s
Note: In both cases, ssthresh is reduced by half (Multiplicative decrease) 223
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Congestion Control Contd…
b) Congestion Policy
iii. Congestion Detection : Multiplicative Decrease Contd…
a) Time-out increases possibility of congestion. TCP reacts as follows:
Ssthresh set to half the value of rwnd
Cwnd initialized to 1
Slow start phase is initiated again
b) Three duplicate ACK’s indicates a weaker possibility of Congestion. Also called as
fast transmission & fast recovery. TCP reacts as follows:
Ssthresh set to half the value of rwnd 224
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Congestion Control Contd…
b) Congestion Policy
iii. Congestion Detection : Multiplicative Decrease Contd…
Cwnd = ssthresh
Congestion avoidance phase is initiated again
225
TCP
Congestion
Policy : A
Summary
226
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Congestion Control Contd…
Summarization with Example
Assumptions
Maximum window Size (MSS) = 32
Threshold (ssthresh) = 16
TCP moves to slow start
rwnd starts from 1 and and grows exponentially till it reaches ssthresh (16)
Additive increase increases rwnd from 16 to 20 (one by one)
When rwnd = 20, time-out occurs
Multiplicative Decrease: ssthresh reduced to 10 (half the window size) 227
Congestion
Example
228
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑 (𝕿𝕮𝕻)
TCP Congestion Control Contd…
Summarization with Example Contd…
New ssthresh = 10
TCP moves to Slow start again
rwnd starts from 1 and and grows exponentially till it reaches new ssthresh (10)
Additive increase increases rwnd from 10 to 12 (one by one)
2 duplicate ACK’s are received by the sender
Multiplicative Decrease: ssthresh reduced to 6 (half the window size)
229
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
230
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Introduction to Multicasting
a) Unicasting
One Source and one Destination network
Relationship between Source and Destination : One to One
What is Unicasting?
Each router in the datagram path forwards packets to only one interface
Example
Problem: Delivery of packet from Source to Destination (N6)
Routers used: R1, R2 & R3
No of Ethernet Switches: 1 231
Solution
R1 forwards packets using
interface 3
R4 forwards packets using
interface 2
Delivery from Source to
destination N6 is
network’s responsibility Unicasting – Example
Mode of Delivery : Scenario
234
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Introduction to Multicasting Contd…
c) Multicasting vs Multiple Unicasting
239
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Multicast Addresses in IPv4
Destination address for a group of hosts that are part of a multicast group
If there are no filtering mechanisms, all the recipients will receive the message
broadcast through multicast
Multicast Addresses in IPv4
Block assigned for multicasting is 224.0.0.0/4
i.e., block has 228 = 268,435,456 addresses
224.0.0.0 to 239.255.255.255 is the address space for Multicast
CIDR need not be assigned to every designated range
240
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
243
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Multicast Addresses in IPv4 Contd…
c) AD-HOC Block
Range: 224.0.2.0 to 224.0.255.0
Assigned to applications that does not fit in 1st or 2nd block
d) Stream Multicast Group Block
224.1.0.0/16
Allocated for stream multimedia
e) SAP / SDP Block
224.2.0.0/16
Used for Session Announcement protocol & Session Directory protocol 244
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Multicast Addresses in IPv4 Contd…
f) SSM Block
232.0.0.0/8
Used for Source Specific Multicasting
g) GLOP Block
233..0.0.0/8
Defines a range of globally assigned addresses
Used inside an autonomous system (AS) and assigned to a 16 bit number
AS number inserted as the 2-middle Octet in the block to create range of 256
multicast addresses 245
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Multicast Addresses in IPv4 Contd…
h) Administratively Scoped Block
239.0.0.0/8
Used in a particular area in internet
Address in this block restricted to an organization
246
Internet Group Management Protocol (IGMP)
247
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Internet Group Management Protocol (IGMP)
Multicast Communication: Message sent by sender to recipients of same group
One copy of message is copied and forwarded by multicast routers
Multicast routers must know list of groups & minimum one loyal member related to
each interface
Information about members to be shared between multicast routers
Information collected at two levels:
Locally (collected by IGMP)
Globally (propagated to other routers)
248
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Internet Group Management Protocol (IGMP) contd…
IGMP collects & interprets information about group members in a network locally
Note: IGMP is designed at the IP layer for the above said purpose
249
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Internet Group Management Protocol (IGMP)
Group Management
IGMP manages group membership
Provides information to the multicast routers about membership status of routers
connected to a network
Maintains a list of groups in the network which has at least one loyal member
Without IGMP, traffic increases & more bandwidth is consumed
Versions of IGMP: 1,2 & 3
Version 1 & 2 provides Any Source Multicast (ASM)
Version 3 provides Source Specific Multicast (SSM) 250
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Internet Group Management Protocol (IGMP)
IGMPv3 Messages
Two types of messages
a) Membership Query message
i. General
ii. Group Specific
iii. Group and Source Specific IGMP Messages
b) Membership Report Message
251
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Internet Group Management Protocol (IGMP)
IGMPv3 Messages Contd…
a) Membership Query message
i. General Query Message
Router probes each neighbor to
report the whole group
Membership Query Message Format
membership list
ii. Group Specific Query Message
Router probes each neighbor to report if it is still interested in a specific group
Multicast group address defined as x.y.z.t in group address field 252
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Internet Group Management Protocol (IGMP)
IGMPv3 Messages Contd…
iii. Group and Source Specific Query message
Router probes each neighbor to report it is still in a specific multicast group
b) Membership Query message format
Important fields
Checksum
Number of Sources
Aux data
Aux Data Len 253
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Internet Group Management Protocol (IGMP)
IGMPv3 Messages Contd…
255
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Routing Protocols
256
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Routing Protocols Contd…
Multicast Link state routing
Extension of unicast routing
Uses source based tree approach
Node advertises every group that has any loyal member on the link
Group information comes form IGMP
Router creates ‘n’ groups based on Link state Packets (LSP’s)
Note: Each router has a routing table that has ‘n’ shortest path trees
Disadvantage: More Time & Space needed to create & Store shortest path trees
257
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Routing Protocols Contd…
a) Multicast Open Shortest path first : MOSPF
Data driven protocol & Extension of OSPF
Uses multicast link state routing to create source based trees
Group membership LSA includes hosts in the tree that’s belongs to a group
When MOSPF router encounters a datagram with a given source and group
address
Router constructs the Dijkstra shortest path tree
258
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Routing Protocols Contd…
b) Multicast Distance Vector Routing Protocol
Uses source-based trees but router does not make a routing table
Router receives multicast packet and forwards
After forwarding the packet the table is destroyed
MDV uses a process based on 4 decision making strategies
i. Flooding
ii. Reverse path forwarding (RPF)
iii. Reverse Path Broadcasting (RPB)
iv. Reverse path Multicasting (RPM) 259
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Routing Protocols Contd…
b) Multicast Distance Vector Routing Protocol Contd…
i. Flooding
Router forwards received packets and sends to every interface except itself
Destination group address is not checked
Every network with active members receives the packet
Networks without active members also receive the packet
Flooding supports broadcast not unicast
Disadvantage: Creation of loops
Overcome by Reverse Path Forwarding (RPF) 260
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Routing Protocols Contd…
b) Multicast Distance Vector Routing Protocol Contd…
ii. Reverse Path Forwarding (RPF)
Modified flooding strategy: Only one copy is forwarded to avoid flooding
Router forwards the copy that has travelled the shortest path from Source to
router
RPF uses Unicast routing table to find this packet
Looping is prevented, since there is only one shortest path from Source to Router
Disadvantage: No guarantee that each network receives only one copy; Network
may receive multiple copies 261
Routers: R1, R2, R3, R4, R5 &
R6
Shortest Path : R1, R2 & R2
R1 receives packet from
source through interface m1
Packet forwarded
Packet forwarded to R2 and
R3 similarly
Note: Upstream routers
towards source always
discards packet not gone
Reverse Path Forwarding (RPF)
through the shortest path 262
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Routing Protocols Contd…
b) Multicast Distance Vector Routing Protocol Contd…
iii. Reverse Path Broadcasting (RPB)
Problem in RPF is overcome by eliminating duplication
Restriction used in RPB: Only one parent router defined for each network
Policy: For each source, router sends packet only out of interfaces which is the
designated parent
RPB guarantees the elimination of duplicate copies
Designated Parent: Router with the shortest path to the source
Disadvantage: RPB broadcasts, not multicasts 263
Reverse Path Forwarding Reverse Path Broadcasting
(RPF) (RPB)
266
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN: 0073376043
𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 & 𝕸𝖚𝖑𝖙𝖎𝖈𝖆𝖘𝖙 𝕽𝖔𝖚𝖙𝖎𝖓𝖌 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑𝖘
Routing Protocols Contd…
c) Core-Based Tree Protocol
Group-shared tree, center-based protocol; Uses one tree per group
One of the routers in the tree is called the core
Procedure for sending Packet from Source to Group members:
1) Source encapsulates the multicast packet inside a unicast packet with the unicast
destination address of the core and sends it to the core
This part of delivery is done using a unicast address
The only recipient is the core router
2) Core decapsulates the unicast packet and forwards it to all interested interfaces
267
3) Each router that receives the multicast packet, in turn, forwards it to all interested
interfaces
270
𝕾𝖙𝖗𝖊𝖆𝖒 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑
Introduction to SCTP
Reliable, Message-oriented general purpose transport layer protocol
Capable of handling Multimedia and Stream traffic
Designed for Internet applications
Lies between application & network layer
Servers a a middleman between
application programs & network
operations
Combines best features of UDP & TCP Relationship of SCTP to other Protocols in
TCP/IP Suite 271
𝕾𝖙𝖗𝖊𝖆𝖒 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑
Introduction to SCTP Contd…
SCTP preserves message boundaries
Detects lost data, duplicate data and out-of-order data
Congestion control and flow control mechanisms available in SCTP
Characteristics of SCTP
a) Confirmed Transmission
b) Data Fragmentation
c) Sequenced Delivery
d) Bunding
e) Fault tolerance at Network Level 272
Conceptual Model of SCTP
273
Source: https://indigoo.com/petersblog/?p=185
𝕾𝖙𝖗𝖊𝖆𝖒 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑
Introduction to SCTP Contd…
Key features of SCTP
a) No head-of-line blocking
b) Message-based data transfer
c) Multihoming
d) Protection against connection flooding
274
Source: https://indigoo.com/petersblog/?p=185
𝕾𝖙𝖗𝖊𝖆𝖒 𝕮𝖔𝖓𝖙𝖗𝖔𝖑 𝕿𝖗𝖆𝖓𝖘𝖒𝖎𝖘𝖘𝖎𝖔𝖓 𝕻𝖗𝖔𝖙𝖔𝖈𝖔𝖑
Difference between TCP, UDP & SCTP
275
Source: https://www.ionos.com/digitalguide/server/know-how/sctp/
References
Learning Resources Used for Unit I
1. Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill,
ISBN: 0073376043
2. https://indigoo.com/petersblog/?p=185
3. https://www.ionos.com/digitalguide/server/know-how/sctp/
Prepared By
Ms.M. Vaidehi, Asst.Prof/CSE/SRMIST/KTR
Mr. KC. Prabu Shankar, Asst.Prof/CSE/SRMIST/KTR
276
Thank You
277