IP Datagrams. Datagram Forwarding

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

IP Datagrams.

Datagram
forwarding
The IP datagram
The packets that are forwarded across the
Internet are known as IP datagrams.
An IP datagram consists of a header and a
payload.
The header contains information that allows
Internet routers to forward the datagram from
the source host to the destination host.
IP datagrams have variable size up to a
maximum.
The IP Datagram Header
IP Datagram Forwarding
Routing procedure
Say datagram for destinationD arrives at router R. Assume routing table at R has N entries.
match = false;
for (i = 0; i < N; ++i) {
if (D & Mask[i] == Destination[i]) {
match = true
Next = NextHop[i];
break;
}
}
if (match == true)
forward datagram to Next.
else
drop datagram.
Resolving routing ambiguities
Example: Routing table contains the following
two destinations among others: 128.10.0.0/16
and 128.10.2.0/24.
Datagram with destination D = 128.10.2.3 arrives
at router. It matches both entries.
The ambiguity is resolved by choosing the entry
with the longest prefix( /24).
One solution would be to sort the routing table in
decreasing order of prefix length and do a linear
search on the table until a match is found.
Best-Effort Delivery
IP is said to offer a best-effort service. By this we
mean that IP will try its best to have an IP packet
delivered to the destination, but it cant make any
promises. The following problems can occur:
Datagram duplication.
Out-of-order delivery.
Corrupt packets.
Lost datagrams.
Recovery from these problems is left to the upper
layers.
Encapsulation
The physical networks that comprise the Internet do not
understand the IP datagram format. Each one has its own packet
format. For example, Ethernet uses frames with headers containing
6-byte ethernet addresses.
For IP datagrams to be forwarded between two computers, they
must be encapsulated (placed inside) frames appropriate for the
physical network in which the two computers reside.
For example, if an IP datagram needs to be forwarded from
computer A to computer B, where A and B reside on the same
Ethernet, it needs to be encapsulated inside an Ethernet frame.
The source address of the Ethernet frame is As ethernet interface
address, and the destination address of the frame is Bs ethernet
interface address.
Transmission across the Internet
MTU and Datagram Fragmentation
MTU = maximum transmission unit = max payload a physical frame can
carry.
Ethernet MTU = 1500
On the other hand, IP datagrams can be as large as 65535 bytes = 2
16
1.
How can such large datagrams be encapsulated inside the much smaller
frames?
Answer: Fragmentation. Large IP datagrams are split into smaller IP
datagrams that can fit inside smaller physical frames.
Fragments contain a fragment offset field that indicated the relative
position of the datagram payload with respect to the original
(unfragmented) datagram.
Fragments are collected at the destination and reassembled to generate
the original (unfragmented) datagram.
Fragments themselved can be further fragmented it they need to travel
through networks with smaller and smaller MTUs.
Fragment Loss. Reassembly timer
Because IP is unreliable, a fragment may get lost.
Once the destination receives some fragment, it
starts a timer (reassembly timer). If the timer
expires before all the remaining fragments have
arrived, it is assumed that some fragment was
lost.
All the fragments that have been accumulated up
to the point when the reassembly timer expired
are discarded.
Support Protocols
Address Resolution Protocol (ARP)
Problem: Router A needs to forward an IP
datagram to router B (which is on the same
Ethernet LAN).
Router A knows the IP address of B.
But the IP datagram must be encapsulated
within an Ethernet frame, whose Ethernet
destination address is the address of Bs NIC.
How can A discover the Ethernet Address of
Bs NIC?
ARP contd
A uses the Address Resolution Protocol (ARP) to
discover Bs NIC Ethernet address. It goes like this:
A broadcasts an Ethernet frame on the LAN. The payload
of the frame is an ARP request: who has address
148.4.20.10 (Bs IP address).
All computers in the LAN hear the broadcast.
The computer whose IP address is 148.4.20.10 (B) replies
to A: my ethernet address is aa:bb:cc:dd:ee:ff.
Now A has the ethernet address of Bs NIC, and can send
the IP datagram to B encapsulated within an Ethernet
frame with destination address aa:bb:cc:dd:ee:ff.
ARP messages are encapsulated inside Ethernet frames
having type 0x0806
ARP message format
ARP caching
ARP responses are cached.
In the previous example, when A receives the reply from B,
it makes an entry in ARP cache: 148.4.20.10 is at
aa:bb:cc:dd:ee:ff. This is called an address binding.
Next time an IP datagram needs to be forwarded to B, it
first looks up the ARP cache. If the address binding is
already there, A doesnt need to send another ARP request.
The ARP cache is flushed periodically, to make sure entries
are always up-to-date (think about what would happen if
Bs NIC needs to be replaced: the IP address of B does not
change, but the ethernet addr. of its NIC does)
Internet Control Message Protocol
Used mostly for error-reporting at the IP level.
For example, if the TTL of the IP datagram reaches 0
when it reaches a router, the datagram is dropped by
the router, and the router sends an ICMP message back
to the source of the datagram to inform it that the
datagram was dropped because its TTL reached 0 (Time
Exceeded)
If a router does not know how to route an IP datagram,
it drops the datagram an send an ICMP message back
to the source (Destination unreachable).
Encapsulation of ICMP messages
ICMP Header
Dynamic Host Configuration Protocol
(DHCP)
Allows a computer to obtain an IP address and
other parameters from a DHCP server.
A DHCP server is a program running in some
fixed computer in the LAN that has been
configured to assign IP addresses from a given
range to other computers in the LAN that
request them.
The DHCP server also provides things like
default routes, and DNS server addresses.
DHCP relays
DHCP requests are broadcasted within the local LAN
(frame dest ff:ff:ff:ff:ff:ff)
If the DHCP server is in a different LAN, the request
wont reach that server.
One way around this is to configure some other
computer in the LAN as a dhcp relay agent : the relay
will intercept the DHCP request and forward it to the
DHCP server on the other LAN.
Simplifies management, as only one DHCP sever needs
to be configured for the entire network, rather than
having to configure separate DHCP servers for each
LAN.

You might also like