Network Layer
DAT230 – Communication Technology I
Naeem Khademi
Associate Professor, IDE/UiS
[email protected]
1
The Network Layer
Network layer (L3): a network-level (i.e., end-to-end)
communication between source and destination– in contrast to
DL layer scope is no longer per link; IPv4 and IPv6 are two
principal L3 protocols!
– Basic operations: addressing, encapsulation, decapsulation, routing
– IP encapsulates transport layer PDU (i.e., segment/datagram for
TCP/ UDP)
– IP can be understood by all L3 devices along the network path (e.g.,
routers or L3 switches)
– IP addressing does not change along the end-to-end path (except with
NAT, discussed later!)
IP is connectionless, best-effort (BE) and media-independent
– No control info (sync, ack packets); connections have to be
implemented by an L4 proto
– BE: no packet delivery guarantee, losses may occur, no retry, no acks
(unreliable!)
– Packets may arrive out-of-sequence, with error/corrupted so; IP relies on L4 to implement these fixes!
– IP functions irrespective of DLL protocol or media (PHY) – can be sent over fiber, copper, wireless, etc.
– How to handle different media? L3 establishes its MTU supplied by the control info from L2
– IP fragmentation: when L3 splits IPv4 packets into smaller units (causes latency) -- e.g., router from
Ethernet to a slow WAN with smaller MTU; unsupported by IPv6 2
Examples of IP Fragmentation & Path MTU Discovery
Figures: CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Path MTU Discovery (PMTUD): avoids
network fragmentation; Routers return MTU
(Max. Transmission Unit) to source and
discard large packets.
– Networks have different packet size limits for
many reasons
– Large packets sent with fragmentation &
reassembly
3
Reassembly within network vs at the destination
IPv4 Packet Header
IPv4 packet header: in binary, with most
important info about the packet (e.g., src/dst IP
address); three major limitations
– IPv4 address depletion: not much left from
IPv4 address space
– Lack of end-to-end connectivity: private
addressing & NAT was created to extend the
IPv4 address space at the cost of losing direct
communication and public IP addressing
– Increased network complexity: NAT originally
meant as a temporary solution, but it now
creates issues with header manipulation and
causing additional latency
Function Description
Version This will be for v4, as opposed to v6, a 4-bit field= 0100
Differentiated Services Used for QoS: DiffServ – DS field or the older IntServ – ToS or Type of Service
Header Checksum Detect corruption in the IPv4 header
Time to Live (TTL) Layer 3 hop count. When it becomes zero the router will discard the packet.
Protocol I.D.s next level protocol: ICMP, TCP, UDP, etc.
Source IPv4 Address 32-bit source address
Destination IPV4 Address 32-bit destination address 4
IP Addressing (#1)
• Addresses are allocated in blocks called prefixes!
– Determined by network portion
– Network addr/length -- e.g., 18.0.31.0/24
• Classful addressing: old addresses came in blocks of fixed size (A, B, C)
– Carries size as part of address; inflexible! E.g. class B allocated address has 65K
hosts even though net might have 2K hosts only.
– Called classful (vs. classless) addressing
• Sub-netting splits up IP prefix to help with management of network – known to local
routers but looks like a single prefix from outside (routers)!
Network divides it into subnets internally
24 bits
16 bits
ISP gives network
a single prefix
Figures: CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
IP Addressing (#2)
• Classless InterDomain Routing (CIDR): more efficient use of IPv4 address
space than classful method
• CIDR network portion can be of arbitrary length; within the allocated portion of
ISP’s address space
network part host part
11001000 00010111 00010000 00000000
200.23.16.0/23
Assigned by ICANN
ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20
Organization #0 11001000 00010111 00010000 00000000 200.23.16.0/23
Organization #1 11001000 00010111 00010010 00000000 200.23.18.0/23
Organization #2 11001000 00010111 00010100 00000000 200.23.20.0/23
…
Organization #7 11001000 00010111 00011110 00000000 200.23.30.0/23
IPv4 NAT
CN5E by Tanenbaum & Wetherall, © Pearson Education-Prentice Hall and D. Wetherall, 2011
Network Address Translation (NAT): allows
an organization to use a smaller number of
public IP addresses with the use of private
IP addresses
– Maps one external IP address to many internal
IP addresses
– Uses TCP/UDP port to tell connections apart
– Violates layering; very common in homes, etc. IPv4 address assignment and census map in 2013 by CAIDA
– With special config, servers cannot be behind
a NAT since clients don’t know the server’s
local address to establish a connection to!
Private IPv4 addresses per RFC1918
Class Address Range Net. Prefix
A 10.0.0.0 – 10.255.255.255 10.0.0.0/8
B 172.16.0.0 – 172.31.255.255 172.16.0.0/12
C 192.168.0.0 – 192.168.255.255 192.168.0.0/16
7
IPv6
IPv6: developed by the IETF to overcome the
limitations of IPv4
– Introduced in 1995 (RFC1883) yet
we’re still using IPv4!!
– Increased address space: 4 billion
IPv4 address (232) vs 340 trillion
trillion trillion IPv6 addresses (2128)!
– Improved packet handling: simpler
headers with fewer fields! 40 bytes
long header; IPv4 “flag”, “fragment
offset”, “header checksum” removed!
– Eliminates the need of NATs i.e.,
“everybody gets an IPv6 address”
8
IPv6 Packet Header
• May contain extension headers (EH)
– Provide optional network layer info
– Are optional
– Placed between IPv6 header and
payload
– May be used for fragmentation,
security, mobility support, etc.
• Unlike IPv4, routers don’t fragment
IPv6 packets
Function Description
Version This will be for v6, as opposed to v4, a 4-bit field= 0110
Traffic Class Used for QoS: Equivalent to DiffServ – DS field
Flow Label Informs device to handle identical flow labels the same way, 20-bit field
Payload Length This 16-bit field indicates the length of the data portion or payload of the IPv6 packet
Next Header I.D.s next level protocol: ICMP, TCP, UDP, etc.
Hop Limit Replaces TTL field Layer 3 hop count
Source IPv6 Address 128-bit source address
Destination IPV6 Address 128-bit destination address
9
Host Routing
• Packets created at the src; each host devices
creates their own routing table
• A host can send packets to the following:
– Own: 127.0.0.1 (IPv4), ::1 (IPv6)
– Local: dst on the same LAN
– Remote: dst on different LAN
• Source determines if host is local or remote:
– IPv4: Source uses its own IP address and
subnet mask, along with the destination IP
address
– IPv6: Source uses network address and prefix
advertised by the local router
• Local traffic to host interface; remote traffic to the DGW on the LAN (router or L3 switch)
• Default Gateway (DGW):
– Same IP address range as the rest of the LAN
– Can accept data from LAN and forward it off the LAN (i.e., another outgoing interface)
– Can route to other networks
– Either set statically by the host or determined through DHCP protocol in IPv4
– IPv6 uses either router solicitation (RS) or manual config 10
Routing & Route Types
Route types in IP routing table:
I. Directly Connected: automatically added
by the router, with active interface with an
address.
II. Remote: router does not have a direct
connection and may be learned:
o Manually: with a static route
• Must be adjusted manually by net
admin when there’s a change in topo
• Good for small networks
o Dynamically: using a routing protocol
III. Default Route: forwards all traffic to a
specific direction if no match in routing
table
11
Dynamic Routing
Dynamic routing:
• Remote network discovery
• Maintain up-to-date info Routing table
• Select best path to destination
• Find new best path when topology
changes
• Can share static default router
with other routers
• DR protocols: OSPF, EIGRP,…
L – Directly connected local interface IP address
C – Directly connected network
S – Static route was manually configured by an
administrator
O – OSPF (remote, dynamic)
D – EIGRP (remote, dynamic)
Dynamic routing Dynamic routing, link failure
12