IP Tutorial
IP Tutorial
Sankhayan Choudhury
Dept. of Computer Science
University of Calcutta
1
Outline
Internetworking problem
Internet’s Architectural principles
IP solution
IP forwarding
IP addressing
IP datagram Format
IP fragmentation & reassembly
2
The Internetworking Problem
Two nodes communicating across a “network of networks”…
How to transport packets through this heterogeneous mass ?
A C loud
B
C loud
C loud
3
Internet’s Architectural principles
End-to-end principle: (Dave Clark, MIT)
The network cannot be trusted
Network provides minimum functionality
(connectionless forwarding, routing)
User must in any case check for errors
Value-added functions at hosts (control
functions): opposite of telephony model
(phone simple, network complex)
4
Architectural principles (contd)
IP over everything:
An internetworking protocol which works over all
underlying sub-networks and provides a single, simple
service model (“best-effort delivery”) to the user.
Interconnection based on IP overlay over all kinds of
networks
Framing or encapsulation
Address resolution
IP-address to network address for each transport
technology
Unique IP-address
Interconnection based on translation
5
Hourglass design
6
IP solution
For heterogeneity, Provide new packet format
and overlay it on subnets.
For scalability, Uses topological addressing
Implications: Hierarchical address, Address
resolution, Fragmentation/re-assembly, Packet
format design, Forwarding algorithm etc
Protocols: IP and ARP
7
An IP Internet – Network of Networks
Network 1 (Ethernet)
H7 R3 H8
H1 H2 H3
Network 4
(point-to-point)
Network 2 (Ethernet)
R1
R2
H4
Network 3 (FDDI)
H5 H6
8
Protocol Stack – IP is Common to All
H1 H8
TCP TCP
R1 R2 R3
IP IP IP IP IP
9
IP Features
Connectionless service
datagram/packet-based
Data forwarding
Addressing
Fragmentation and reassembly
Supports variable size datagrams
Best-effort delivery: Delay, out-of-order,
corruption, and loss possible. Higher layers
should handle these.
10
What IP does NOT provide
End-to-end data reliability & flow control
(done by TCP or application layer protocols)
Sequencing of packets (like TCP)
Error detection in payload (TCP, UDP or other
transport layers)
Error reporting (ICMP)
Setting up route tables (RIP, OSPF, BGP etc)
Connection setup (it is connectionless)
Address/Name resolution (ARP, RARP, DNS)
11
How does IP forwarding work ?
A) Source & Destination in same network
Recognize that destination IP address is
on same network.
Find the destination LAN address.
Send IP packet encapsulated in LAN frame
directly to the destination LAN address.
Encapsulation => source/destination IP
addresses don’t change
12
IP forwarding (contd)
B) Source & Destination in different
networks
Recognize that destination IP address is
not on same network.
Look up destination IP address in a (routing)
table to find a match, called the next hop
router IP address.
Send packet encapsulated in a LAN frame to
the LAN address corresponding to the IP
address of the next-hop router.
13
Getting a datagram from source to
dest.
routing table in A
Dest. Net. next router Nhops
223.1.1 1
223.1.2 223.1.1.4 2
IP datagram: 223.1.3 223.1.1.4 2
misc source dest
data
fields IP addr IP addr A 223.1.1.1
14
Getting a datagram from source to
dest.
misc Dest. Net. next router Nhops
data
fields 223.1.1.1 223.1.1.3
223.1.1 1
223.1.2 223.1.1.4 2
Starting at A, given IP 223.1.3 223.1.1.4 2
datagram addressed to B:
look up net. address of B A 223.1.1.1
15
Getting a datagram from source to
dest.
misc Dest. Net. next router Nhops
data
fields 223.1.1.1 223.1.2.3
223.1.1 1
Starting at A, dest. E: 223.1.2 223.1.1.4 2
look up network address of E 223.1.3 223.1.1.4 2
E on different network
A, E not directly attached A 223.1.1.1
routing table: next hop router 223.1.2.1
to E is 223.1.1.4 223.1.1.2
223.1.1.4 223.1.2.9
link layer sends datagram to
B
router 223.1.1.4 inside link- 223.1.2.2
223.1.1.3 223.1.3.27 E
layer frame
datagram arrives at 223.1.1.4 223.1.3.1 223.1.3.2
16
Getting a datagram from source to
dest.
Dest. next
misc network router Nhops interface
223.1.1.1 223.1.2.3 data
fields
223.1.1 - 1 223.1.1.4
Arriving at 223.1.4, destined for 223.1.2 - 1 223.1.2.9
223.1.2.2 223.1.3 - 1 223.1.3.27
look up network address of E
E on same network as A 223.1.1.1
router’s interface 223.1.2.9
223.1.2.1
router, E directly attached 223.1.1.2
223.1.1.4 223.1.2.9
link layer sends datagram to
223.1.2.2 inside link-layer B
223.1.2.2
frame via interface 223.1.2.9 223.1.1.3 223.1.3.27 E
datagram arrives at 223.1.3.2
223.1.3.1
223.1.2.2!!! (hooray!)
17
Addressing & Resolution
How to find if destination is in the same
network?
IP address = network ID + host ID. Source and
destination network IDs match => same
network
Splitting address into multiple parts is called
hierarchical addressing
How to find the LAN address
corresponding to an IP address?
Address Resolution Problem.
Solution: ARP, RARP/ DHCP
18
Resolving Addresses
Hardware only recognizes MAC addresses
IP only uses IP addresses
Consequence: software needed to perform
translation
Part of network interface
Known as address resolution
19
Address Resolution
Layer 2 protocol
Given
A locally-connected network, N
IP address C of computer on N
Find
Hardware address for C
Technique
Address Resolution Protocol
20
Address Resolution Protocol
(ARP)
21
ARP Table
22
ARP Lookup Algorithm
Look for target IP address, T, in ARP table
If not found
Send ARP request message to T
Receive reply with T’s hardware address
Add entry to table
Return hardware address from table
23
Illustration of ARP Exchange
24
ARP Process
The sender knows the IP address of the target.
IP asks ARP to create an ARP request message.
ARP request message contains sender physical
address, the sender IP address and the target IP
address. The target physical address field is filled
with Os.
The message is passed to the data link layer
where it is encapsulated in a frame by using the
physical address of the sender as the source
address and the physical broadcast address as
the destination address.
25
ARP Process
The target machine replies with an ARP
reply message that contains its physical
address. The message is unicast.
The sender receives the reply message. It
now knows the physical address of the
target machine.
The IP datagram, which carries data for
the target machine, is now encapsulated in
a frame and is uni-casted to the
destination.
26
Possible Cases: ARP
27
Mapping: Physical to Logical
28
RARP
Physical to Logical Address mapping mechanism
A RARP request is created and broadcast on the local
network.
Another machine on the local network that knows all the IP
addresses will respond with a RARP reply.
The requesting machine must be running a RARP client
program; the responding machine must be running a
RARP server program.
In RARP, broadcasting is done at the data link layer. The
physical broadcast address (all 1’s in the case of
Ethernet) does not pass the boundaries of a network.
If an administrator has several networks or several
subnets, it needs to assign a RARP server for each
network or subnet.
29
BOOTP
An application layer client server protocol; maps
physical to logical address.
The client and server may be in the same or different
network.
BOOTP messages are encapsulated in a UDP packet,
and the UDP in an IP packet.
30
BOOTP
The BOOTP request is broadcast because the client does
not know the IP address of the server.
A broadcast IP datagram cannot pass through any router.
One of the intermediary (host or a router that can be
configured to operate at the application layer) can be
used as a relay agent
The relay agent knows the unicast address of a BOOTP
server. When it receives this type of packet, it
encapsulates the message in a unicast datagram and
sends the request to the BOOTP server.
The BOOTP server knows the message comes from a
relay agent because one of the fields in the request
message defines the IP address of the relay agent.
The relay agent, after receiving the reply, sends it to the
BOOTP client.
31
DHCP
32
Some special IP addresses
All-0s This computer
All-1s All hosts on this net (limited
broadcast: don’t forward out of this net)
All-0 host suffix Network Address (‘0’
means ‘this’)
All-1 host suffix All hosts on the
destination net (directed broadcast).
127.*.*.* Loopback through IP layer
33
IP datagram format
IP protocol version 32 bits
number total datagram
header length type of length (bytes)
ver head. length
(bytes) len service for
“type” of data fragment fragmentation/
16-bit identifier flgs
offset reassembly
max number time to upper Internet
remaining hops live layer checksum
(decremented at
32 bit source IP address
each router)
32 bit destination IP address
upper layer protocol
to deliver payload to Options (if any) E.g. timestamp,
record route
data taken, pecify
(variable length, list of routers
typically a TCP to visit.
or UDP segment)
34
IP Datagram Format
First Word purpose: info, variable size
header & packet.
Version (4 bits)
Internet header length (4 bits): units of 32-bit
words. Min header is 5 words or 20 bytes.
Type of service (TOS: 8 bits): Reliability,
precedence, delay, and throughput. Not widely
supported
Total length (16 bits): header + data. Units of
bytes. Total must be less than 64 kB.
35
Service Type
36
IP Header (Cont)
2nd Word Purpose: fragmentation
Identifier (16 bits): Helps uniquely identify the
datagram between any source, destination
address
Flags (3 bits): More Flag (MF):more fragments
Don’t Fragment (DF)
Reserved
Fragment offset (13 bits): In units of 8 bytes
37
IP Header (Cont)
Third word purpose: demuxing,
error/looping control, timeout.
Time to live (8 bits): Specified in router hops
Protocol (8 bits): Next level protocol to receive
the data: for de-multiplexing.
Header checksum (16 bits): 1’s complement
sum of all 16-bit words in the header.
Change header => modify checksum using 1’s
complement arithmetic.
Source Address (32 bits): Original source.
Does not change along the path. 38
Higher Layer Protocols
39
Header Format (contd)
Destination Address (32 bits): Final
destination. Does not change along the path.
Options (variable length): Security, source
route, record route, stream id (used for voice)
for reserved resources, timestamp recording
Padding (variable length):
Makes header length a multiple of 4
Payload Data (variable length): Data + header
< 65,535 bytes
40
Fragmentation Issue
41
Maximum Transmission Unit
Each subnet has a maximum frame size
Ethernet: 1518 bytes
FDDI: 4500 bytes
Token Ring: 2 to 4 kB
Transmission Unit = IP datagram (data + header)
Each subnet has a maximum IP datagram length
(header + payload) = MTU
Net
Net 11 Net
Net 22
SS R
R R
R
MTU=1500
MTU=1500 MTU=1000
MTU=1000
42
Fragmentation
Datagrams larger than MTU are fragmented
Original header is copied to each fragment and then
modified (fragment flag, fragment offset, length,...)
Some option fields are copied (see RFC 791)
44
Reassembly
Where to do reassembly?
End nodes
Dangerous to do at intermediate nodes
How much buffer space required at routers?
What if routes in network change?
Multiple paths through network
All fragments only required to go through
destination
45
Fragmentation Example
46