0% found this document useful (0 votes)
16 views19 pages

L13 - Network Layer DHCP, NAT, IP Forwarding

The document covers key concepts of the Network Layer in computer networks, including IP addressing, DHCP, NAT, and IP forwarding. It explains how DHCP dynamically assigns IP addresses to devices, the purpose and operation of NAT for translating private addresses to public ones, and the method of IP forwarding using longest prefix matching. These topics are essential for understanding how data is routed and managed across networks.

Uploaded by

atorzsas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views19 pages

L13 - Network Layer DHCP, NAT, IP Forwarding

The document covers key concepts of the Network Layer in computer networks, including IP addressing, DHCP, NAT, and IP forwarding. It explains how DHCP dynamically assigns IP addresses to devices, the purpose and operation of NAT for translating private addresses to public ones, and the method of IP forwarding using longest prefix matching. These topics are essential for understanding how data is routed and managed across networks.

Uploaded by

atorzsas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

CP 372

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?

• Hard-coded by system admin


(Static, Manual)
• Windows: Control panel-
>network & Internet->view
network status and tasks-
>change adapter settings-
>wifi (right click and select
properties) ->tcp/ipv4-
>properties
• Difficult network and address
reconfiguration (e.g.,
subnetting, moving machines
between networks)
• More suitable for static,
small, and easily maintained
networks (Ex: among devices
on the same network)
5
How to Get an IP Address?

• DHCP: dynamically get


address from the network
server (dynamic,
automatic)
• Application layer
protocol, runs over UDP
• Allows reuse of
addresses (only hold
address while
connected)

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

DHCP server: 223.1.2.5 DHCP discover


Arriving Client
src : 0.0.0.0, 68
Broadcast: is there a
dest.: 255.255.255.255,67
DHCPyiaddr:
server0.0.0.0
out there? • 255.255.255.255 is
transaction ID: 654 broadcast address
DHCP offer • 0.0.0.0 means “this
src: 223.1.2.5, 67 host” address
Broadcast: I’m a DHCP
dest: 255.255.255.255, 68 • yiaddr: your Internet
server! Here’s an IP
yiaddrr: 223.1.2.4
address
address youID:can
transaction 654 use
lifetime: 3600 secs • DHCP ACK can
DHCP request include more info
src: 0.0.0.0, 68 (e.g., DNS server
Broadcast: OK. I’ll take
dest:: 255.255.255.255, 67
yiaddrr: 223.1.2.4 address, masks)
that IP address!
transaction ID: 655 • DHCP server must be
lifetime: 3600 secs
in the same
DHCP ACK network/subnetwork
src: 223.1.2.5, 67
Broadcast: OK. You’ve
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
got that IPID:
transaction address!
655 8
lifetime: 3600 secs
NAT
(Network Address Translation)
9
Why?

• Motivation: By the 90’s, IP addresses were close to running


out (why?)
• 32-bit addresses (IPv4) mean you have 2^32 possible
unique addresses, what if the number of users exceed that?

• 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 operates on a router, usually connecting two networks together, and


translates the private (not globally unique) addresses in the internal network
into legal addresses, before packets are forwarded to another network

NAT-enabled Router

• Basically, NAT allows a single device, such as a router, to act as an agent


between the Internet (or public network) and a local network (or private
network), which means that only a single unique IP address is required to
represent an entire group of computers to anything outside their network

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

Wide Area Network Local Area Network


NAT translation table 1: host 10.0.0.1
2: NAT router WAN side addr LAN side addr
changes datagram sends datagram to
source addr from 138.76.29.7, 5001 10.0.0.1, 3345 128.119.40.186, 80
10.0.0.1, 3345 to …… ……
138.76.29.7, 5001,
updates table S: 10.0.0.1, 3345
D: 128.119.40.186, 80
10.0.0.1
1
S: 138.76.29.7, 5001
2 D: 128.119.40.186, 80 10.0.0.4
10.0.0.2
138.76.29.7 S: 128.119.40.186, 80
D: 10.0.0.1, 3345
4
S: 128.119.40.186, 80
D: 138.76.29.7, 5001 3 10.0.0.3
4: NAT router
3: reply arrives changes datagram
dest. address: dest addr from
138.76.29.7, 5001 138.76.29.7, 5001 to 10.0.0.1, 3345
13
NAT Controversies
• NAT is controversial:
• Port numbers are meant to be used for addressing processes, not for
addressing hosts
• Routers should only process up to Layer 3
• Violates end-to-end argument
• We should use IPv6 rather than trying to solve the problem using
NAT

• But like it or not, NAT has become an important component of the


Internet

14
IP Forwarding

15
Forwarding Basics

Node 3

Node 1 Destination Next node Node 6


Destination Next node 1 1 Destination Next node
2 4 1 3
2 2
4 4 2 5
3 3
4 4 5 6 3 3
6 6 4 3
5 2
6 3 5 5

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

11001000 00010111 00011000 00000000


through
11001000 00010111 00011000 11111111
1 Longest prefix matching
Problem: Prefixes of different length, more
11001000 00010111 00011001 00000000
through 2
than one match for a destination address
11001000 00010111 00011111 11111111 Solution: When looking for forwarding
table entry for given destination address,
3
otherwise use longest address prefix that matches
destination address.

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

Dest. IP Address: 10000000 10001111 01000111 00000101


10.01010/8: 00001010 00000000 00000000 00000000
128.143.0.0/16: 10000000 10001111 00000000 00000000
128.143.64.0/20: 10000000 10001111 01000000 00000000
128.143.68.0/22: 10000000 10001111 01000100 00000000
128.143.70.0/24: 10000000 10001111 01000110 00000000
18
128.143.71.16/28: 10000000 10001111 01000111 00001000
19

You might also like