L13 - Network Layer DHCP, NAT, IP Forwarding
L13 - Network Layer DHCP, NAT, IP Forwarding
Computer Networks
Network Layer
DHCP,NAT, IP Forwarding
Reminder from Previous Lecture
2
Reminder
Network Layer Functions
• Addressing
• Routing
• Forwarding
IP Addressing
• 32 Bits (ex: 192.168.5.3)
• Hierarchically organized
into networks and
subnetworks
• Should be “unique” 3
DHCP
(Dynamic Host Configuration
Protocol) 4
How to Get an IP Address?
6
How to Get an IP Address?
• DHCP: Allows reuse of addresses (only hold address while connected)
• DHCP is useful in residential ISP (Internet Service Provider) access
networks for instance
• Consider, for example, a residential ISP that has 2,000 customers, but no
more than 400 customers are ever online at the same time
• In this case, rather than needing a block of 2,048 addresses (2^11), a DHCP
server that assigns addresses dynamically needs only a block of 512 (2^9)
addresses
• As the hosts join and leave, the DHCP server needs to update its list of
available IP addresses
• Each time a host joins, the DHCP server allocates an arbitrary address from
its current pool of available addresses; each time a host leaves, its address is
returned to the pool
7
DHCP Operation
• Solutions
• Increase number of address bits
• IPv6 uses 128 bits for addressing
• Use private addresses for hosts inside each network that are
not seen by the outside world
• Private Addresses
• Enables reuse of these addresses
• Private addresses must be translated to global addresses
when packets exit the private network: NAT
10
What is NAT?
NAT-enabled Router
11
How?
• Hosts are assigned addresses from given ranges:
• Range 1: 10.0.0.0 to 10.255.255.255
• Range 2: 172.16.0.0 to 172.31.255.255
• Range 3: 192.168.0.0 to 192.168.255.255
NAT-enabled Router
• Each network uses just one IP address assigned to its main
router as far as public network is concerned
• NAT:
• The main network router treats hosts as if they are different
applications
• Uses a different port numbers for each request from each host
• Translate information from incoming and outgoing packets
• With 16-bit port number: more than 60,000 connections with one global
IP address
12
Example
14
IP Forwarding
15
Forwarding Basics
Node 3
Node 4
Destination Next node
1 1
2 2
Node 2 Node 5
3 3
Destination Next node Destination Next node
5 5
1 1 6 3 1 4
3 1 2 2
4 4 3 4
5 4 4 4
6 5 6 6
16
Reminder
Exhaustive:
Classless inter-domain routing (CIDR):
• Each individual address has a
• Each network address is stored with its
separate entry in the routing table.
prefix as one entry
• Tables are huge but each destination
• Router looks for a NetID match for the
address can be found (with very
destination address in the table and
long time though) and its next hop
reports its next hop
identified
Destination Address Range Link interface
11001000 00010111 00010*** ********* 0
Destination Address Range Link Interface
11001000 00010111 00011000 ********* 1
11001000 00010111 00010000 00000000 2
11001000 00010111 00011*** *********
through 0
11001000 00010111 00010111 11111111 otherwise 3
17
Longest Prefix Matching
• Search for the table entry that has the longest prefix match
Destination address Next hop
10.0.0.0/8 R1
128.143.0.0/16 R2
128.143.64.0/20 R3
128.143.71.5 128.143.68.0/22 R3
128.143.70.0/24 R4
128.143.71.16/28 R3
default R5