01 IP Basics
01 IP Basics
01 IP Basics
• IP header format
• IP addressing
• IP forwarding
Internetworking
• What is internetwork
– An arbitrary collection of networks interconnected to provide some sort
of host-host to packet delivery service
• Version (4 bits): 4
IP header format
Used as follows:
– Sender sets the value (e.g., 64)
– Each router decrements the value by 1
– When the value reaches 0, the datagram is dropped
IP header format
4 = IP-in-IP
encapsulation
• Protocol (1 byte):
– Specifies the higher-layer protocol. 6 = TCP 17 = UDP
IP
IP header format
• SourceAddr, DestinationAddr
– Source & destination IP addresses
IP header format
• Options:
• Record Route: each router that processes the packet adds its IP
address to the header.
• Timestamp: each router that processes the packet adds its IP
address and time to the header.
• (loose) Source Routing: specifies a list of routers that must be
traversed.
• (strict) Source Routing: specifies a list of the only routers that
can be traversed.
• IP options increase routers processing overhead
• Pad:
– Padding bytes are added to ensure that header ends
on a 4-byte boundary
Overview
• IP header format
• IP addressing
• IP forwarding
What is an IP Address?
• An IP address is a unique global identifier for a
network interface
– An IP address uniquely identifies a network location
• IPv4 (32-bit)
– Classful IP addresses (obsolete)
– Classless inter-domain routing (CIDR) (RFC 854,
current standard)
128.143.137.144
Structure of an IP address
0 31
network prefix host number
Class A 0
Network Prefix Host Number
8 bits 24 bits
bit # 0 1 2 15 16 31
bit # 0 1 2 3 23 24 31
bit # 0 1 2 3 4 5 31
• IP header format
• IP addressing
• IP forwarding
Forwarding of IP datagrams
• There are two distinct processes for delivering
IP datagrams:
1. Forwarding (data plane): How to pass a
packet from an input interface to the output
interface?
2. Routing (control plane): How to find and
setup the forwarding tables?
Key points
• Each IP datagram contains the IP destination address
• All hosts and routers that share the same network part
of their address are connected to the same physical
network
Yes
Is dst on the same Deliver the packet to the
physical network? Network directly
1. How to determine
No whether a dst is on the
same physical network?
2. How to determine the
Forward to next-hop
router next hop router?
– Routing
Detailed forwarding algorithm
• If (networkNum == networkNum of one of my
interfaces) then
– Deliver packet over the interface
• Else
– if (NetworkNum is in my forwarding table) then
• Deliver to the NextHop router
– Else
• Deliver packet to the default router
How to determine the
NetworkNum of a destination
address?
• Destination address & network mask =
NetworkNum
128 143 137 144
Addr 10000000 10001111 10001001 10010000
255 255 255 0
Mask 11111111 11111111 1111111 00000000
• Host route
– Destination address is an interface address (e.g., 10.0.1.2/32)
– Used to specify a separate route for certain hosts
• Default route
– Used when no network or host route matches
• Loopback address
– Routing table for the loopback address (127.0.0.1)
– The next hop lists the loopback interface as outgoing interface
Unified forwarding algorithm
10.0.0.0/8 eth0
128.143.0.0/16 R2
128.143.64.0/20 R3
128.143.192.0/20 R3
128.143.71.0/24 R4
128.143.71.55/32 R3
0.0.0.0/0 (default) R5
• IP header format
• IP addressing
• IP forwarding