You are on page 1of 43

McGraw-Hill The McGraw-Hill Companies, Inc.

, 2000
8-1
Chapter 8
I nternet Protocol
(I P)
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-2
! IP is unreliable and connectionless datagram protocol
! Best-effort delivery service IP provides no error
checking (like post office)
! Packet switching using datagram approach (each
datagram routed independently, each datagram can follow
different route datagrams can arrive out of order)
! Datagrams can be lost and IP doesnt care
! IP relies on higher layer protocols (like TCP) to take care
of lost and out of order datagrams
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-3
Position of IP in TCP/IP protocol suite
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-4
IP Datagram
IPv4 or IPv6
Header
Length (lwords)
Header + data in
bytes (to find
about padding)
Used for
fragmentation
Today max
number of hops
The higher-level protocol that
uses this datagram - multiplexing
(ICMP = 1, IGMP = 2,
TCP = 6, UDP = 17, OSPF = 89)
Covers only header
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-5
Service Type or Differentiated Services
Gives priority
when it comes to
discarding
datagrams due to
congestion (will
be used in future)
No bits: normal
See book
IP Datagram (cont.)
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-6
IP Datagram (cont.)
Minimize
delay
FTP (control)
Minimize
delay
TELNET
Maximize
throughput
FTP (data)
Maximize
reliability
SNMP
Maximize
throughput
SMTP (data) Normal BOOTP
Minimize
delay
SMTP
(command)
Normal ICMP
Default types of services
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-7
Time to Leave
To limit number of obsolete packets in internetwork
Old datagrams can confuse upper layers (TCP)
Each router decrements TTL, drops the datagram if TTL becomes 0
Time stamps require synchronized clocks
Today are used max number of hops (two times max number
of routers between any two hosts)
Can be used to limit journey of the packet (1 confines packet to the
local network)
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-8
Example 1
An IP packet has arrived with the first 8 bits as shown:
0100 0010
The receiver discards the packet. Why?
There is an error in this packet. The 4 left-most bits (0100)
show the version, which is correct. The next 4 bits (0010)
show the header length, which means (2 4 = 8), which is
wrong. The minimum number of bytes in the header must
be 20. The packet has been corrupted in transmission.
Solution:
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-9
Example 2
In an IP packet, the value of HLEN is 1000 in binary.
How many bytes of options are being carried by this
packet?
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 main header, the next 12 bytes are the
options.
Solution:
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-10
Example 3
In an IP packet, the value of HLEN is 5
16
and the value of
the total length field is 0028
16
. 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).
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-11
An IP packet has arrived with the first few hexadecimal
digits as shown below:
4 5 00 0028 00010000 01 02..........
How many hops can this packet travel before being
dropped? The data belong to what upper layer protocol?
Example 4
TTL
To find the time-to-live field, we should 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.
Solution:
Protocol
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-12
Fragmentation
Size of datagrams is 20 bytes to 64 Kbytes (in the
future will even be larger). Size of LAN frames is
usually in smaller range (Ethernet: 26+(46 to 1500)
bytes.
MTU = Maximum Transfer Unit (max size of data)
296 PPP
576 X.25
1,500 Ethernet
4,325 FDDI
4,464 Token Ring (4 Mbps)
17,914 Token Ring (16 Mbps)
MTU Protocol
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-13
Fragmentation (cont.)
In order to encapsulate datagrams into frames with small MTU they have to be
fragmented.
Unique for all datagrams sent from this source IP
Each fragment has the same datagram ID
In units of 8 bytes
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-14
Fragmentation example
Fragmentation (cont.)
The size of fragments must be
such that this number must be
divisible by 8
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-15
Details
Fragment is
further fragmented
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-16
Example 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?
If the Mbit 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 nonfragmented packet is considered the last fragment.
Solution:
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-17
Example 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?
If the Mbit 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 dont know if it is the first
one or a middle one; we need more information (the
value of the fragmentation offset). However, we can
definitely say the original packet has been fragmented
because the M bit value is 1.
Solution:
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-18
Example 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?
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.
Solution:
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-19
Example 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?
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.
Solution:
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-20
Example 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?
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.
Solution:
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-21
Options
The variable part of the datagram header (max size = 40 bytes).
Used for network testing and debugging.
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-22
Categories of options:
Options (cont.)
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-23
No operation option:
Options (cont.)
Used as a filler between options (e.g. to align the next option
on 4, 8 16 or 32-bit boundary)
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-24
End of option option:
Options (cont.)
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-25
Record route option
Options (cont.)
Used to record routers that handle the datagram (up to 9 IP addresses)
P
l
a
c
e

h
o
l
d
e
r
s
Points to the next
available place holder
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-26
Options (cont.)
Record route concept
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-27
Strict source route option
Options (cont.)
Sender could use the predetermined routes to chose:
safer (more reliable) routes
routes with minimal delay
to avoid travel through competitors network
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-28
Options (cont.)
All routers in the list must be visited.
A datagram will be dropped if it arrives to a router which is not in the list
If the list is exhausted and destination is not reached, the datagram is dropped
Strict source route concept
As the packet goes the IP addresses
from options are replaced with the IP
addresses of actually visited routers
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-29
Loose source route option
Options (cont.)
More relaxed: datagram must visit all routers from the list, but can visit
others too
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-30
Timestamp option
Options (cont.)
Number of routers that
could not add their timestamp
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-31
Use of flag in timestamp
Options (cont.)
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-32
Timestamp concept
Options (cont.)
Timestamp concept
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-33
Example 10
Which of the six options must be copied to each
fragment?
We look at the first (left-most) bit of the code for each option.
No operation: Code is 00000001; no copy.
End of option: Code is 00000000; no copy.
Record route: Code is 00000111; no copy.
Strict source route: Code is 10001001; copied.
Loose source route: Code is 10000011; copied.
Timestamp: Code is 01000100; no copy.
Solution:
Copy bit Class
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-34
Example 11
Which of the six options are used for datagram control
and which are used for debugging and management?
Solution:
We look at the second and third (left-most) bits of the code.
No operation: Code is 00000001; control.
End of option: Code is 00000000; control.
Record route: Code is 00000111; control.
Strict source route: Code is 10001001; control.
Loose source route: Code is 10000011; control.
Timestamp: Code is 01000100; debugging
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-35
Checksum
IP header is divided into sections
Ones complement
addition
(n = 2*8 = 16)
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-36
Checksum in ones complement arithmetic
Checksum (cont.)
Uncorrupted packet
Sum (with checksum field = 0)
Checksum
If there is no corruption
the sum is 0
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-37
Checksum (cont.)
IP header
Header is divided
into sections
(of two bytes)
Complemented
Sections added using
ones complement
(see Appendix C)
Binary example:
Checksum is
initially
set to zero
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-38
Checksum (cont.)
Hexadecimal example:
(See Appendix C)
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-39
IP Package
Encapsulation,
checksum
1
2
5
3
4
a
x For hosts
b
c
1
2
3
4
x
For routers
Fragments can also
be fragmented
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-40
Processing Module
if (loopback or packet has reached the final destination) {
Send packet to reassembly module;
return;
}
if (the machine is a router){
Decrement TTL;
if (TTL <= 0) {
Discard the packet;
Send ICMP error message;}
else
Send packet to routing module;
return;
}
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-41
Fragmentation module
if (datagram size > MTU)
if (D-bit set) { // D - do not fragment bit
Discard the datagram;
Send ICMP error message; return;}
else {
Divide datagram into fragments;
Add header to each fragment;
Add options to each fragment (if necessary);
Send fragmented datagrams to the link layer;
return;}
else {
Send datagram to link layer;
return;
}
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-42
Reassembly table
(FREE or IN-USE)
Each fragment of the same datagram
has the same datagram ID
Pointer to linked list
Each datagram has
its own queue
McGraw-Hill The McGraw-Hill Companies, Inc., 2000
8-43
Reassembly module
If (fragment offset = 0 and M = 0) { // M more fragments
Send datagram to upper layer;
return;}
Search the reassembly table; // If more fragments
if (not found, i.e. source IP and datagram ID dont match)
Create a new entry;
Insert fragment in approp. position in list (use offset);
if (all fragments have arrived)
Reassemble the fragments (extract data);
Deliver data to upper layer;
else
if (time-out expired) {
Discard all fragments (the entire list);
Send ICMP error message;}
return;
(Invoked on IP datagram arrival)

You might also like