Unit1 CN
Unit1 CN
5
IP Datagrams
Packets in the network (internet) layer are called datagrams.
A datagram is a variable-length packet consisting of two parts:
header and data.
The header is 20 to 60 bytes in length and contains information
essential to routing and delivery.
6
Figure 1.2 IP datagram
7
Header Format
Version (VER): This 4-bit field defines the version of the IP protocol.
Currently the version is 4.
Header length (HLEN): This 4-bit field defines the total length of the
datagram header in 4-byte words. This field is needed because the
length of the header is variable (between 20 and 60 bytes).
Service type: In the original design of IP header, this field was referred
to as type of service (TOS), which defined how the datagram should be
handled. This field now defines a set of differentiated services. The new
interpretation is shown in Figure 1.3.
The codepoint subfield can be used in two different ways.
a. When the 3 right-most bits are 0s, the 3 left-most bits are interpreted
the same as the precedence bits in the service type interpretation.
b. When the 3 right-most bits are not all 0s, the 6 bits define 56 (64 − 8)
services based on the priority assignment by the Internet or local
authorities according to Table 1.1.
8
The DSCP field consists of 6 bits, which allows for 64
different possible values (2^6 = 64).
x x x 0 0 0 x x x x x 0
Precedence x x x x 1 1
interpretation
x x x x 0 1
Differential service
interpretation
Table 1.1 Values of Codepoints
10
Header Format
Total length: This is a 16-bit field that defines the total length (header
plus data) of the IP datagram in bytes.
Length of data = total length − header length
Figure 1.4 Encapsulation of a small datagram in an Ethernet frame
12
Header Format Cont.
Some of the value of this field for different higher-level protocols is
shown in Table 1.2.
Table 1.2 Protocols
Example 1.2
In an IP packet, the value of HLEN is 1000 in binary. How many bytes of
options are being carried by this packet?
Solution
The HLEN value is 8, which means the total number of bytes in the header is 8 × 4
or 32 bytes. The first 20 bytes are the base header, the next 12 bytes are the options.
14
Example 1.3
In an IP packet, the value of HLEN is 516 and the value of the total length field is
002816. How many bytes of data are being carried by this packet?
Solution
The HLEN value is 5, which means the total number of bytes in the header is 5 × 4
or 20 bytes (no options). The total length is 40 bytes, which means the packet is
carrying 20 bytes of data (40 − 20).
Example 1.4
An IP packet has arrived with the first few hexadecimal digits as shown below:
How many hops can this packet travel before being dropped? The data belong
to what upper layer protocol?
Solution
To find the time-to-live field, we skip 8 bytes (16 hexadecimal digits). The time-to-
live field is the ninth byte, which is 01. This means the packet can travel only one
hop. The protocol field is the next byte (02), which means that the upper layer
protocol is IGMP (see Table 1.2)
15
When data is transmitted over a network using Internet
Protocol (IP), it is divided into smaller units called packets or
datagrams.
IP datagram
19
IP Fragmentation Cont.
Fragmentation offset: This 13-bit field shows the relative position
of this fragment with respect to the whole datagram. It is the offset
of the data in the original datagram measured in units of 8 bytes.
Figure 1.8 shows a datagram with a data size of 4000 bytes
fragmented into three fragments.
Figure 1.8 Fragmentation example
Offset = 0000/8 = 0
0000 1399
Bytes 0000–3999
Bytes 1400–2799
Original datagram Fragment 2
1220
14,567 0 350
Bytes 2800–3999
Fragment 3
Figure 1.9 Detailed fragmentation example 21
Example 1.5
A packet has arrived with an M bit value of 0. Is this the first fragment, the last
fragment, or a middle fragment? Do we know if the packet was fragmented?
Solution
If the M bit is 0, it means that there are no more fragments; the fragment is the last
one. However, we cannot say if the original packet was fragmented or not. A non
fragmented packet is considered the last fragment.
Example 1.6
A packet has arrived with an M bit value of 1. Is this the first fragment, the last
fragment, or a middle fragment? Do we know if the packet was fragmented?
Solution
If the M bit is 1, it means that there is at least one more fragment. This fragment can
be the first one or a middle one, but not the last one. We don’t know if it is the first
one or a middle one; we need more information (the value of the fragmentation
offset). See also the next example.
22
Example 1.7
A packet has arrived with an M bit value of 1 and a fragmentation
offset value of zero. Is this the first fragment, the last fragment, or
a middle fragment?
Solution
Because the M bit is 1, it is either the first fragment or a middle one.
Because the offset value is 0, it is the first fragment.
Example 1.8
A packet has arrived in which the offset value is 100. What is the number of
the first byte? Do we know the number of the last byte?
Solution
To find the number of the first byte, we multiply the offset value by 8. This means
that the first byte number is 800. We cannot determine the number of the last byte
unless we know the length of the data.
23
Example 1.9
A packet has arrived in which the offset value is 100, the value of HLEN is 5
and the value of the total length field is 100. What is the number of the first byte
and the last byte?
Solution
The first byte number is 100 × 8 = 800. The total length is 100 bytes and the header
length is 20 bytes (5 × 4), which means that there are 80 bytes in this datagram. If the
first byte number is 800, the last byte number must be 879.
24
IP Fragmentation Options
25
Figure 1.10 Option format
Number
Record-Route Option:
A record-route option is used to record the Internet routers that handle the datagram.
It can list up to nine router IP addresses since the maximum size of the header is 60
bytes, which must include 20 bytes for the base header.
This implies that only 40 bytes are left over for the option part.
The source creates placeholder fields in the 29
option to be filled by the visited routers.
Figure 1.14 Record-route option
When the datagram is traveling, each router that processes the datagram compares
the value of the pointer with the value of the length.
If the value of the pointer is greater than the value of the length, the option is full and
no changes are made.
The pointer field is an offset integer field containing the byte number of the first
empty entry. In other words, it points to the first available entry.
the router adds the IP address of its interface from which the datagram is leaving.
The router then increments the value of the pointer by 4.
30
Figure 1.15 Record-route concept
7 15 4 7 15 8 7 15 12 7 15 16
140.10.6.3 140.10.6.3 140.10.6.3
200.14.7.9 200.14.7.9
138.6.22.26
67.34.30.6 138.6.25.40
67.14.10.22
138.6.22.26
200.14.7.14
140.10.6.3
140.10.5.4
200.14.7.9
67.0.0.0/24 140.10.0.0/16 200.14.7.0/24 138.6.0.0/16
Network Network Network Network
Strict-source-route option:
It is used by the source to predetermine a route for the datagram as it travels through
the Internet.
Dictation of a route by the source can be useful for several purposes.
The sender can choose a route with a specific type of service, such as minimum delay
or maximum throughput.
Alternatively, it may choose a route that is safer or more reliable for the sender’s
purpose. 31
Figure 1.16 Strict-source-route option
67.34.30.6 138.6.25.40
67.14.10.22
138.6.22.26
200.14.7.14
140.10.6.3
140.10.5.4
200.14.7.9
33
Figure 1.19 Time-stamp option
The flags field specifies the visited router responsibilities. If the flag
value is 0, each router adds only the timestamp in the provided field.
If the flag value is 1, each router must add its outgoing IP address
and the timestamp. If the value is 3, the IP addresses are given, and
each router must check the given IP address with its own incoming
IP address. 34
Figure 1.20 Use of flags in timestamp
68 28 5 0 1 68 28 13 0 1 68 28 21 0 1 68 28 29 0 1
140.10.6.3 140.10.6.3 140.10.6.3
36000000 36000000 36000000
200.14.7.9 200.14.7.9
36000012 36000012
138.6.22.26
36000020
67.34.30.6
67.14.10.22
138.6.22.26
200.14.7.14
140.10.6.3
140.10.5.4
200.14.7.9
37
Example 1.13
We can also use the ping utility with the -R option to implement the record
route option. The result shows the interfaces and IP addresses.
Example 1.14
The traceroute utility can also be used to keep track of the route of a packet.
The result shows the three routers visited.
38
Example 1.15
The traceroute program can be used to implement loose source routing. The -g
option allows us to define the routers to be visited, from the source to
destination. The following shows how we can send a packet to the fhda.edu
server with the requirement that the packet visit the router 153.18.251.4.
Example 1.16
The traceroute program can also be used to implement strict source routing.
The -G option forces the packet to visit the routers defined in the command line.
The following shows how we can send a packet to the fhda.edu server and force
the packet to visit only the router 153.18.251.4.
39
CHECKSUM
The error detection method used by most TCP/IP protocols is called
the checksum.
The checksum protects against the corruption that may occur
during the transmission of a packet.
It is redundant information added to the packet.
The checksum is calculated at the sender and the value obtained is
sent with the packet.
The receiver repeats the same calculation on the whole packet
including the checksum.
If the result is satisfactory (see below), the packet is accepted;
otherwise, it is rejected.
40
Checksum Calculation at the Sender
At the sender, the packet header is divided into n-bit sections (n is
usually 16).
These sections are added together using one’s complement
arithmetic, resulting in a sum that is also n bits long.
The sum is then complemented (all 0s changed to 1s and all 1s to 0s)
to produce the checksum.
Receiver
Section 1 n bits
Section 2 n bits
..............
Checksum n bits
..............
Section k n bits
Sum n bits
Complement
If the result is 0, keep;
n bits otherwise, discard.
Result
n bits
Checksum
Packet
Sum : T
T _T
Checksum : _T
Sender Datagram
42
Example 1.17
Figure 1.24 shows an example of a checksum calculation at the sender site for
an IP header without options. The header is divided into 16-bit sections. All the
sections are added and the sum is complemented. The result is inserted in the
checksum field.
5 0
1 0
17
10.12.14.5
12.6.7.9
43
Example 1.18
Figure 1.25 shows the checking of checksum calculation at the receiver site (or
intermediate router) assuming that no errors occurred in the header. The
header is divided into 16-bit sections. All the sections are added and the sum is
complemented. Since the result is 16 0s, the packet is accepted.
Figure 1.25 Example of checksum calculation at the receiver
44
Address Resolution Protocol
OBJECTIVES:
• To make a distinction between logical address (IP address)
and physical address (MAC address).
• To describe how the mapping of a logical address to a
physical address can be static or dynamic.
• To show how the address resolution protocol (ARP) is used
to dynamically map a logical address to a physical address.
• To show that the proxy ARP can be used to create a
subnetting effect.
• To show that an ARP software package can be made of five
components.
ADDRESS MAPPING
The hosts and routers are recognized at the network level by their
logical addresses.
A logical address is an internetwork address and unique universally.
It is called a logical address because it is usually implemented in
software.
Every protocol that deals with interconnecting networks requires
logical addresses.
The logical addresses in the TCP/IP protocol suite are called IP
addresses and are 32 bits long.
A physical address is a local address, because it is usually (but not
always) implemented in hardware.
Examples of physical addresses are 48-bit MAC addresses in the
Ethernet protocol, which are imprinted on the NIC installed in the
host or router.
46
ADDRESS MAPPING
Static Mapping
Static mapping means creating a table that associates a logical
address with a physical address.
This table is stored in each machine on the network.
Each machine that knows, for example, the IP address of another
machine but not its physical address can look it up in the table.
Dynamic Mapping
Each time a machine knows the logical address of another machine,
it can use a protocol to find the physical address.
Two protocols have been designed to perform dynamic mapping:
Address Resolution Protocol (ARP) and Reverse Address
Resolution Protocol (RARP).
ARP maps a logical address to a physical address;
RARP maps a physical address to a logical address.
47
Address Resolution Protocol
48
Anytime a host or a router has an IP datagram to send to another
host or router, it has the logical (IP) address of the receiver.
But the IP datagram must be encapsulated in a frame to be able to
pass through the physical network.
This means that the sender needs the physical address of the
receiver.
A mapping corresponds a logical address to a physical address.
LAN
System A System B
Request
LAN
System A System B
Reply
51
ARP Packet Format
The fields are as follows:
Hardware type: This is a 16-bit field defining the type of the network on
which ARP is running.
Each LAN has been assigned an integer based on its type. For example,
Ethernet is given the type 1. ARP can be used on any physical network.
Protocol type This is a 16-bit field defining the protocol.
For example, the value of this field for the IPv4 protocol is 080016.
ARP can be used with any higher-level protocol.
Hardware length: This is an 8-bit field defining the length of the physical
address in bytes.
For example, for Ethernet the value is 6.
Protocol length: This is an 8-bit field defining the length of the logical
address in bytes.
For example, for the IPv4 protocol the value is 4.
Operation: This is a 16-bit field defining the type of packet. Two packet
types are defined: ARP request (1), ARP reply (2).
52
ARP Packet Format Cont.
Sender hardware address: This is a variable-length field defining
the physical address of the sender.
For example, for Ethernet this field is 6 bytes long.
Sender protocol address: This is a variable-length field defining the
logical (for example, IP) address of the sender.
For the IP protocol, this field is 4 bytes long.
Target hardware address: This is a variable-length field defining the
physical
address of the target.
For example, for Ethernet this field is 6 bytes long.
For an ARP request message, this field is all 0s because the sender
does not know the physical address of the target.
Target protocol address: This is a variable-length field defining the
logical (for
example, IP) address of the target.
For the IPv4 protocol, this field is 4 bytes long.
53
Figure 1.28 Encapsulation of ARP packet
Type: 0x0806
Encapsulation
An ARP packet is encapsulated directly into a data link frame.
For example, an ARP packet is encapsulated in an Ethernet frame.
Note that the type field indicates that the data carried by the frame
is an ARP packet.
Operation
Let us see how ARP functions on a typical internet.
First we discuss the four cases in which a host or router needs to
use ARP.
54
Figure 1.29 Four cases using ARP
55
Example 8.1
A host with IP address 130.23.43.20 and physical address
B2:34:55:10:22:10 has a packet to send to another host with IP
address 130.23.43.25 and physical address A4:6E:F4:59:83:AB.
The two hosts are on the same Ethernet network. Show the ARP
request and reply packets encapsulated in Ethernet frames.
Solution
Figure 1.30 shows the ARP request and reply packets. Note that the
ARP data field in this case is 28 bytes, and that the individual
addresses do not fit in the 4-byte boundary. That is why we do not
show the regular 4-byte boundaries for these addresses. Also note
that the IP addresses are shown in hexadecimal.
56
Figure 1.30 Example 1.26
57
Figure 1.31Proxy ARP
Added subnetwork
The proxy ARP router replies 141.23.56.21 141.23.56.22 141.23.56.23
to any ARP request received
for destinations 141.23.56.21,
141.23.56.22, and 141.23.56.23.
Request
Proxy ARP
Router or host router
59
Figure 1.32 ARP components
60
ARP PACKAGE Cont.
Cache Table
A sender usually has more than one IP datagram to send to the same
destination.
It is inefficient to use the ARP protocol for each datagram destined
for the same host or router.
The solution is the cache table.
When a host or router receives the corresponding physical address
for an IP datagram, the address can be saved in the cache table.
The cache table is implemented as an array of entries. In our
package, each entry contains the following fields:
State: This column shows the state of the entry. It can have one of
three values: FREE, PENDING, or RESOLVED.
Hardware type
Protocol type
Hardware length. 61
ARP PACKAGE Cont.
Protocol length
Interface number: A router (or a multihomed host) can be
connected to different networks, each with a different interface
number.
Each network can have different hardware and protocol types.
Queue number: ARP uses numbered queues to enqueue the
packets waiting for address resolution.
Packets for the same destination are usually enqueued in the same
queue.
Attempts: This column shows the number of times an ARP request
is sent out for this entry.
Time-out: This column shows the lifetime of an entry in seconds.
Hardware address: This column shows the destination hardware
address. It remains empty until resolved by an ARP reply.
Protocol address
62
Output Module
63
Input Module
64
Cache Control Module
65
66
Example 8.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 (R in the table). It extracts
the hardware address, which is 457342ACAE32, and sends the packet and the
address to the data link layer for transmission. The cache table remains the
same.
67
Example 8.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 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. The new cache table is shown in Table
8.6.
68
Example 8.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. The new cache table is
shown in Table 8.7.
69
Twenty-five seconds later, the cache-control module updates every entry. The
time-out values for the first three resolved entries are decremented by 60. The
time-out value for the last resolved entry is decremented by 25. The state of
the next-to-the last entry is changed to FREE because the time-out is zero.
For each of the three pending entries, the value of the attempts field is
incremented by one. After incrementing, the attempts value for one entry (the
one with IP address 201.11.56.7) is more than the maximum; the state is
changed to FREE, the queue is deleted, and an ICMP message is sent to the
original destination See Table 8.8.
70
Reverse Address
Resolution Protocol
RARP Procedure
Steps to Achieve the IP Address from RARP Server:
1.Source Device “Generates RARP Request Message” – The
source device generates a RARP Request message. The Source puts
its own data link-layer address as both the Sender Hardware
Address and also the Target Hardware Address. It leaves both the
Sender Protocol Address and the Target Protocol Address blank.
2.Source Device “Broadcasts RARP Request Message” – The
source broadcasts the ARP Request message on the local network.
3.Local Devices “Process RARP Request Message” – The
message is received by each device on the local network and
processed. Devices that are not configured to act as RARP servers
ignore the message.
72
RARP Procedure
4. RARP Server Generates RARP Reply Message: Any device on
the network that is a RARP server responds to the broadcast from
the source device. It generates a RARP Reply and sets the Sender
Hardware Address and Sender Protocol Address to its own
hardware and IP address of course. It looks up in a table the
hardware address of the source, determines that device’s IP address
assignment, and puts it into the Target Protocol Address field.
5. RARP Server Sends RARP Reply Message: The RARP server
sends the RARP Reply message unicast to the device looking to be
configured.
6. Source Device Processes RARP Reply Message: The source
device processes the reply from the RARP server. It then configures
itself using the IP address in the Target Protocol Address supplied
by the RARP server
73
RARP Procedural Steps
74
Introduction to Internet Control Message
Protocol (ICMP)
135
USER DATAGRAM PROTOCOL
UDP Datagram various fields
Length:
Length field specifies the entire length of UDP
UDP length=IP length – IP headers Length
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:
plus data)
• This field is used to detect errors over the entire user 136
datagram (header
USER DATAGRAM PROTOCOL
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
USER DATAGRAM PROTOCOL
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
USER DATAGRAM PROTOCOL
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.
Sender is unknown about the loss
and duplication.
When error detects in receiver the
datagram is discarded
Encapsulation
• in protocol filed.
A process send message through Indicating UDP protocol.
UDP
The IP datagram is then passed to
Along pair of socket address and
the length of data. the data link layer.
The data link layer receives the IP
datagram and passes it to141 the
physical layer.
The physical layer encodes the bits
USER DATAGRAM PROTOCOL
UDP Services cont…
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 Decapsul1a42tion
USER DATAGRAM PROTOCOL
UDP Services cont…
The header is dropped and the user datagram is passed to UDP with the sender
and receiver IP addresses.
143
USER DATAGRAM PROTOCOL
UDP Services cont…
Queuing in UDP
144
USER DATAGRAM PROTOCOL
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
USER DATAGRAM PROTOCOL
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
USER DATAGRAM PROTOCOL
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
USER DATAGRAM PROTOCOL
UDP Services cont…
148
USER DATAGRAM PROTOCOL
UDP Package
UDP design
149
USER DATAGRAM PROTOCOL
UDP Package
The UDP package involves five components:
Control-Block Table
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
USER DATAGRAM PROTOCOL
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
USER DATAGRAM PROTOCOL
UDP_INPUT_Module (user_datagram)
{
Look for the entry in the control_block table
• UDP Package
if (found)
{
Input Module
Check to see if a queue is allocated
The input modulereceives
If (queue is not allocated)
allocate a queue
a user datagram from the
else
IP. It searches
enqueue the thedata
control-
block table
} //end if to find an
entry else
having the same
port number
{ as this user
Ask ICMP to send an "unreachable port" message
datagram.
Discard the user datagram
If the entry is found, the
} //end else
moduleReturn. uses the
} // end module
information in the entry
to enqueue the data.If the
152
entry is not found, it
generates an ICMP
message..
USER DATAGRAM PROTOCOL
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
UDP Features at a Glance
• UDP is connectionless
• To transmit a packet, TCP needs a three way handshake before it starts sending data.
• When a sender sends the data to the receiver, it requires a positive acknowledgement
from the receiver confirming the arrival of data.
• If the acknowledgement has not reached the sender, it needs to resend that data.
Step 1: SYN
• SYN is a segment sent by the client to the server.
• It acts as a connection request between the client and server. It informs the
server that the client wants to establish a connection.
• The ACK segment informs the client that the server has received the
connection request and it is ready to build the connection.
• The SYN segment informs the sequence number with which the server is
ready to start with the segments.
Step 3: ACK
• ACK (Acknowledgment) is the last step before establishing a successful TCP
connection between the client and server.
• The ACK segment is sent by the client as the response of the received ACK and
SN from the server. It results in the establishment of a reliable data
connection.
• After these three steps, the client and server are ready for the data
communication process
TCP Header
The following diagram represents the TCP header format-
1. Source Port-
• Source Port is a 16 bit field.
• It identifies the port of the sending application.
2. Destination Port-
• Destination Port is a 16 bit field.
• It identifies the port of the receiving application.
3. Sequence Number-
• Sequence number is a 32 bit field.
• TCP assigns a unique sequence number to each byte of data contained in the
TCP segment.
• This field contains the sequence number of the first data byte.
Acknowledgement Number-
• Acknowledgment number is a 32 bit field.
• It contains sequence number of the data byte that receiver expects to receive next
from the sender.
• It is always sequence number of the last received data byte incremented by 1.
Header Length-
• Header length is a 4 bit field.
• It contains the length of TCP header.
• It helps in knowing from where the actual data begins.
Reserved Bits-
• The 6 bits are reserved.
• These bits are not used.
URG Bit-
URG bit is used to treat certain data on an urgent basis.
• When URG bit is set to 1,
• It indicates the receiver that certain amount of data within the current segment is
urgent.
• Urgent data is pointed out by evaluating the urgent pointer field.
• The urgent data has be prioritized.
• Receiver forwards urgent data to the receiving application on a separate channel.
ACK Bit-
ACK bit indicates whether acknowledgement number field is valid or not.
• When ACK bit is set to 1, it indicates that acknowledgement number contained in the
TCP header is valid.
• For all TCP segments except request segment, ACK bit is set to 1.
• Request segment is sent for connection establishment during Three Way Handshake.
PSH Bit-
PSH bit is used to push the entire buffer immediately to the receiving application.
• When PSH bit is set to 1,
• All the segments in the buffer are immediately pushed to the receiving application.
• No wait is done for filling the entire buffer.
• This makes the entire buffer to free up immediately.
Checksum-
• Checksum is a 16 bit field used for error control.
• It verifies the integrity of data in the TCP payload.
• Sender adds CRC checksum to the checksum field before sending the data.
• Receiver rejects the data that fails the CRC check.
Urgent Pointer-
• Urgent pointer is a 16 bit field.
• It indicates how much data in the current segment counting from the first data
byte is urgent.
• Urgent pointer added to the sequence number indicates the end of urgent data
byte.
• This field is considered valid and evaluated only if the URG bit is set to 1.
Options-
• Options field is used for several purposes.
• The size of options field vary from 0 bytes to 40 bytes.
Options field is generally used for the following purposes-
• Time stamp
• Window size extension
• Parameter negotiation
• Padding
Time Stamp-
• When wrap around time is less than life time of a segment,
• Multiple segments having the same sequence number may appear at the
receiver side.
• This makes it difficult for the receiver to identify the correct segment.
• If time stamp is used, it marks the age of TCP segments.
• Based on the time stamp, receiver can identify the correct segment.
Window Size Extension-
• Options field may be used to represent a window size greater than 16 bits.
• Using window size field of TCP header, window size of only 16 bits can be represented.
• If the receiver wants to receive more data, it can advertise its greater window size using this field.
• The extra bits are then appended in Options field.
Parameter Negotiation-
• Options field is used for parameters negotiation.
• Example- During connection establishment,
• Both sender and receiver have to specify their maximum segment size.
• To specify maximum segment size, there is no special field.
• So, they specify their maximum segment size using this field and negotiates.
Padding-
• Addition of dummy data to fill up unused space in the transmission unit and make it conform to the
standard size is called as padding.
• Options field is used for padding.
Error Control in TCP
TCP protocol has methods for finding out corrupted segments, missing segments, out-
of-order segments and duplicated segments.
Error control in TCP is mainly done through the use of three simple techniques :
• 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.
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
( )
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
( )
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
( )
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
( )
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
The window after the new advertisement; Window has shrunk
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
( )
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
( )
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
( )
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
( )
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) accommodate max size
of segment
( )
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
TCP Error
Control
( )
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
( )
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
( )
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
( )
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.
( )
TCP Error Control Contd…
b) Acknowledgement Contd…
3) At no point of time there should be more than two in-order segments
unacknowledged. (avoid 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.
( )
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
( )
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
( )
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
( )
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
Simplified
FSM for TCP
Sender Side
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN:
0073376043
Simplified
FSM for TCP
Receiver
Side
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN:
0073376043
TCP Congestion
Control
( )
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)
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN:
0073376043
( )
TCP Congestion Control
b) Congestion Policy
Contd…
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 1x2=2 21
2 2 2 2x2=4 22
4 4 3 4x2=8 23
8 8 4 8 x 2 = 16 24
( )
TCP Congestion Control
b) Congestion Policy
Contd…
i. Slow Start (Exponential Increase) contd…
For Delayed Acknowledgements
If multiple segments are acknowledged accumulatively, cwnd increases by 1
Example: if ACK = 4 then cwnd = 5
Growth is exponential but not to the power of 2
Slow start stops with a threshold value ssthresh
It stops when window size = = ssthresh
( )
TCP Congestion Control
b) Congestion Policy
Contd…
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
Source: Behrouz A. Forouzan, “TCP IP Protocol Suite ” 4th edition, 2010, McGraw-Hill ISBN:
0073376043
( )
TCP Congestion Control
b) Congestion Policy
Contd…
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)
( )
TCP Congestion Control
b) Congestion Policy
Contd…
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
( )
TCP Congestion Control
b) Congestion Policy
Contd…
iii. Congestion Detection : Multiplicative Decrease Contd…
Cwnd = ssthresh
Congestion avoidance phase is initiated again
TCP
Congestion
Policy : A
Summary
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)
Congestion
Example
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)
Multicasting and
Multicast Routing Protocols
Objectives
Upon completion you will be able to:
• Differentiate between a unicast, multicast, and broadcast message
• Know the many applications of multicasting
• Understand multicast link state routing and MOSPF
• Understand multicast link state routing and DVMRP
• Understand the Core-Based Tree Protocol
• Understand the Protocol Independent Multicast Protocols
• Understand the MBONE concept
219
UNICAST, MULTICAST,
AND BROADCAST
A message can be unicast, multicast, or broadcast. Let us clarify these
terms as they relate to the Internet.
Unicasting
Multicasting
Broadcasting
Multicasting versus Multiple Unicasting
220
Unicasting
221
Note:
222
Multicasting
223
Note:
224
Multicasting versus multiple unicasting
225
Note:
226
MULTICAST APPLICATIONS
Multicasting has many applications today such as access to distributed
databases, information dissemination, teleconferencing, and distance
learning.
227
MULTICAST ROUTING
In this section, we first discuss the idea of optimal routing, common in all
multicast protocols. We then give an overview of multicast routing
protocols.
229
Shortest path tree in unicast routing
230
Note:
231
Note:
232
Source-based tree approach
233
Group-shared tree approach
234
Note:
236
MULTICAST LINK STATE
ROUTING: MOSPF
In this section, we briefly discuss multicast link state routing and its
implementation in the Internet, MOSPF.
237
Note:
238
MULTICAST DISTANCE
VECTOR: DVMRP
In this section, we briefly discuss multicast distance vector routing and its
implementation in the Internet, DVMRP.
239
Note:
240
Note:
241
RPF
243
RPF versus RPB
245
RPF, RPB, and RPM
246
Note:
247
CBT
The Core-Based Tree (CBT) protocol is a group-shared protocol that uses
a core as the root of the tree. The autonomous system is divided into
regions and a core (center router or rendezvous router) is chosen for each
region.
248
Group-shared tree with rendezvous router
249
Sending a multicast packet to the rendezvous router
250
Note:
251
PIM
Protocol Independent Multicast (PIM) is the name given to two
independent multicast routing protocols: Protocol Independent Multicast,
Dense Mode (PIM-DM) and Protocol Independent Multicast, Sparse Mode
(PIM-SM).
PIM-DM
PIM-SM
252
Note:
253
Note:
254
Note:
255
Note:
256
MBONE
A multicast router may not find another multicast router in the
neighborhood to forward the multicast packet. A solution for this problem
is tunneling. We make a multicast backbone (MBONE) out of these isolated
routers using the concept of tunneling.
257
Logical tunneling
258
MBONE
259