Network Layer
Internet protocol
1
Transport
Application HTTPS FTP HTTP SMTP DNS
Transport TCP UDP
IP
Network
802.11 X.25 … ATM
Host-to-Net
Endpoint
The network layer
• Main function: Move data from sending to
receiving endpoint Process
• on sending endpoint: encapsulate
transport segments into datagrams
• on receiving endpoint: deliver datagrams
to transport layer Network
• The network layer also runs in every Layer
router
• The router examines header fields in all
network-layer datagrams passing through Process
it
Endpoint
Two key network-layer functions
• Forwarding: move Analogy: taking a
packets from router’s road trip
input to appropriate
router output Forwarding:
process of getting
• Routing: determine route through single
taken by packets from interchange
source to destination
• routing algorithms
Routing: process
of planning trip
from source to
• The network layer solves
destination
the routing problem.
4
Data plane and Control Plane
Data plane = Forwarding Control plane = Routing
• local, per-router function • network-wide logic
• determines how datagram • determines how datagram is
arriving on router input routed along end-to-end path
from source to destination
port is forwarded to endpoint
router output port
• two control-plane approaches:
• Distributed routing algorithm
values in arriving
packet header running on each router
• Centralized routing algorithm
0111 1 running on a (logically)
3
2 centralized server
Internet Addressing
7
The Internet needs addresses
• Addresses allow endpoints to identify, and hence talk to
each other
• E.g., like people have names
• Addresses allow routers to determine how to move a
packet
• E.g., like the postal system
• Network layer addresses are designed to help routers
perform the forwarding and routing functions efficiently
• Specifically, we’ll look at Internet Protocol (IP) addresses.
• Most popular: IP version 4 or IPv4. (Coming up later: IPv6)
IPv4 Addresses
• 32 bits long
• Identifier for a network interface
• An IP address corresponds to the point of
attachment of an endpoint to the network.
• An IP address is NOT an identifier for the endpoint
• Dotted quad notation: each byte is written in
decimal in MSB order, separated by dots. Example:
10000000 11000011 00000001
01010000
128 . 95 . 1 . 80
Grouping IP addresses by prefixes
• IP addresses can be grouped based on a shared
prefix of a specified length
• Example: consider two IP addresses:
• [Link] and [Link]
• The addresses share a prefix of (bit) length 24: 128.95.1
• The addresses have different suffixes of (bit) length 8
• IP addresses: prefix corresponds to the network
component and the suffix to an endpoint/host
component of the address
IP addresses use hierarchy to
scale routing
NJ
• IP addresses of endpoint interfaces in a
network (e.g., Rutgers Busch campus) share a
prefix of some length
• Each interface/endpoint has a different suffix,
and hence a different 32-bit IP address
• Using prefixes reduces the amount of
information needed to forward packets over
the Internet
• IP prefixes are like zip codes: routers don’t
need to store info for each endpoint, just each
prefix
• Prefixes also allow IP addresses to be
delegated from one network to another (more
on this later)
IP addresses use hierarchy to
scale routing
NJ
• Postal envelopes should show clearly
delineated zip codes.
• Q: How to identify the prefix from a 32-
bit IP address?
• Two methods:
• Old: Classful addressing
• New: Classless addressing (also called
classless inter-domain routing, or CIDR)
Classful IPv4 addressing
Classful IPv4 addressing
Class 32 bits
A 0 Net Host 0.x.x.x –
127.x.x.x
Unicast: single endpoint
dest
B 10 Net Host 128.x.x.x –
191.x.x.x
Unicast: single endpoint
dest
C 110 Net Host 192.x.x.x –
Unicast: single endpoint
223.x.x.x
dest
D 1110 Multicast address 224.x.x.x –
239.x.x.x
Destination is a group of
hosts
E 1111 Reserved 240.x.x.x –
8 bit 16 bit 24 bit 255.x.x.x
First octet of IP address
prefix prefix prefix gives you the prefix
length.
Classful IPv4 addressing
• Class A:
• For very large organizations
• 224 = 16 million hosts allowed
• Class B:
• For large organizations
• 216 = 65 thousand hosts allowed
• Class C
• For small organizations
• 28 = 255 hosts allowed
• Class D
• Multicast addresses
• No network/host hierarchy
Problems with classful
addressing
• IP prefixes are allocated to organizations (e.g., Rutgers) by
Internet Registry organizations (e.g., ARIN, in North America)
• Many organizations required something bigger than class C
address, but smaller than a class A (or even B) address
• However, the Internet was running out of class B addresses
• Too many networks required multiple class C addresses
• Not enough nets in class A for large + medium organizations
• Key issue: Classful addressing is too coarse-grained: The
addressing strategy must allow for greater diversity of
network sizes
Classless IPv4
addressing (CIDR)
Classless IPv4 addressing
• Also called classless inter-domain routing (CIDR)
• Key idea: Network component of the address (ie:
prefix) can have any length (usually from 8—32)
• Address format: a.b.c.d/x, where x is the prefix
length
• Customary to use 0s for all suffix bits
network host
part part
11001000 00010111 00010000 00000000
[Link]/23
CIDR
• An ISP can obtain a block of [Link]/16
addresses and partition this further
to its customers
• Say an ISP has [Link]/16 address
(65K addresses).
200.8.0.
• The ISP has customer who needs 0
200.8.0. [Link]/
only 64 addresses starting from 1 26
…
[Link]
200.8.1.
• Then that block can be specified as 0
200.8.1.
[Link]/26 1
…
• [Link]/26 is “inside” [Link]/16 [Link]
55
Netmask (or subnet mask)
• An alternative to denote the IP prefix length of an
organization
• 32 bits: a 1-bit denotes a prefix bit position. 0 is the
host part. network host
part part
11001000 00010111 00010000 00000000
[Link]/23
network Host
part of part of
mask mask
11111111 11111111 11111110 00000000
Netmask: [Link]
Detecting addresses from same
network
• Given IP addresses A and B, and netmask M.
1. Compute logical AND (A & M).
2. Compute logical AND (B & M).
3. If (A & M) == (B & M) then A and B are
on the same subnet.
• Ex: A = [Link], B = [Link], M = [Link]
• A and B are in the same network according to the
netmask
• A & M == B & M == [Link]
Finding your own IP address(es)
• A small demo