Network Layer and Internet Protocols IPv
Network Layer and Internet Protocols IPv
• Function:
• Route packets end-to-end on a network, through
Application multiple hops
Presentation
• Key challenge:
Session • How to represent addresses
Transport • How to route packets
• Scalability
Network • Convergence
Data Link
Physical
2
Layer-3 Functionalities
Devices which work on Network Layer mainly focus on routing. Routing may
include various tasks aimed to achieve a single goal. These can be:
Addressing devices and networks.
Populating routing tables or static routes.
Queuing incoming and outgoing data and then forwarding them according to
quality of service constraints set for those packets.
Internetworking between two different subnets.
Delivering packets to destination with best efforts.
Provides connection oriented and connection less mechanism.
Network Layer Features
With its standard functionalities, Layer 3 can provide various features as:
Quality of service management
Load balancing and link management
Security
Interrelation of different protocols and subnets with different schema.
Different logical network design over the physical network design.
L3 VPN and tunnels can be used to provide end to end dedicated connectivity.
Routers, Revisited
• How to connect multiple
LANs?
Routers
• LANs may be incompatible
• Ethernet, Wifi, etc…
• Connected networks form an
internetwork
• The Internet is the best known
example
5
Routers take help of routing tables, which has the following information:
Address of destination network
Method to reach the network
Routers upon receiving a forwarding request, forwards packet to its next hop
(adjacent router) towards the destination.
The next router on the path follows the same thing and eventually the data
packet reaches its destination.
Network address can be of one of the following:
Unicast (destined to one host)
Multicast (destined to group)
Broadcast (destined to all)
Anycast (destined to nearest one)
Structure of the Internet
Network 3
Network 1
Network 4
Network 2
7
Internetworking Issues
• Naming / Addressing
• How do you designate hosts?
• Routing Internet Service Model
• Best-effort
• Must be scalable (i.e. a switched Internet(i.e.
won’tthings
work) may break)
• Service Model • Store-and-forward datagram network
• What gets sent?
• How fast will it go?
• Lowest common denominator
What happens if there are failures?
• Must deal with heterogeneity
• Remember, every network is different
8
Possible Addressing Schemes
• Flat
• e.g. each host is identified by a 48-bit MAC address
• Router needs an entry for every host in the world
• Too big
• Too hard to maintain (hosts come and go all the time)
• Too slow (more later)
• Hierarchy
• Addresses broken down into segments
• Each segment has a different level of specificity
9
Example: Telephone Numbers
1-617-373-1234
3278
Very General
West Village
West Village GH
Room1234
Room 256
1** Datagram,
10* Destination = 101
100
101 11*
0**
110 00*
111 000
001 01*
010
011
11
IP Addressing
• IPv4: 32-bit addresses
• Usually written in dotted notation, e.g. 192.168.21.76
• Each number is a byte
• Stored in Big Endian order
0 8 16 24 31
Decimal 192 168 21 76
Hex C0 A8 15 4C
0 31
Pfx Network Host
0 1 8 16 24 31
Example: MIT
Class A 0 Ntwk Host
18.*.*.*
1-126
0 2 8 16 24 31
Example: NEU
Class B 10 Network Host
129.10.*.*
128-191
0 3 8 16 24 31
Example:
Class C 110 Network Host
216.63.78.*
192-223 14
How Do You Get IPs?
• IP address ranges controlled by IANA
Subtree size
determined by …
network class
16
Class Sizes
18
Subnet Example
• Extract network:
IP Address: 10110101 11011101 01010100 01110010
Subnet Mask: & 11111111 11111111 11000000 00000000
Result: 10110101 11011101 01000000 00000000
Extract host:
IP Address: 10110101 11011101 01010100 01110010
Subnet Mask: & ~(11111111 11111111 11000000 00000000)
Result: 00000000 00000000 00010100 01110010
19
N-Level Subnet Hierarchy
…
• Tree does not have a fixed depth
…
• Increasingly specific subnet masks
Subtree size
determined by length of …
subnet mask 20
Example Routing Table
Address Pattern Subnet Mask Destination Router
0.0.0.0 0.0.0.0 Router 4
18.0.0.0 255.0.0.0 Router 2
128.42.0.0 255.255.0.0 Router 3
128.42.128.0 255.255.128.0 Router 5
128.42.222.0 2555.255.255.0 Router 1
NO
22
Classless Inter Domain Routing
• CIDR, pronounced ‘cider’
• Key ideas:
• Get rid of IP classes
• Use bitmasks for all levels of routing
• Aggregation to minimize FIB (forwarding information
base)
• Arbitrary split between network and host
• Specified as a bitmask or prefix length
• Example: Northeastern
• 129.10.0.0 with netmask 255.255.0.0
• 129.10.0.0 / 16 23
Aggregation with CIDR
• Original use: aggregating class C ranges
• One organization given contiguous class C ranges
• Example: Microsoft, 207.46.192.* – 207.46.255.*
• Represents 26 = 64 class C ranges
• Specified as CIDR address 207.46.192.0/18
0 8 16 24 31
Decimal 207 46 192 0
Hex CF 2E C0 00
Binary 11001111 00101110 11xxxxxx xxxxxxxx
0 4 8 12 16 19 24 31
Version HLen DSCP/ECN Datagram Length
Identifier Flags Offset
TTL Protocol Checksum
Source IP Address
Destination IP Address
Options (if any, usually not)
Data 26
IP Header Fields: Word 1
• Version: 4 for IPv4
• Header Length: Number of 32-bit words (usually 5)
• Type of Service: Priority information (unused)
• Datagram Length: Length of header + data in bytes
0 4 8 12 16 19 24 31
Version HLen DSCP/ECN Datagram Length
Identifier Flags Offset
TTL Protocol Checksum
Limits packets
Source IP Address
to 65,535
Destination IP Address
bytes
Options (if any, usually not)
Data 27
IP Header Fields: Word 3
• Time to Live: decremented by each router
• Used to kill looping packets
• Protocol: ID of encapsulated protocol
• 6 = TCP, 17 = UDP
• Checksum
0 4 8 12 16 19 24 31
Version HLen DSCP/ECN Datagram Length
Identifier Flags Offset
TTL Protocol Checksum
Source IP Address
Used to Destination IP Address
implement Options (if any, usually not)
trace route Data 28
IP Header Fields: Word 4 and 5
• Source and destination address
• In theory, must be globally unique
• In practice, this is often violated
0 4 8 12 16 19 24 31
Version HLen DSCP/ECN Datagram Length
Identifier Flags Offset
TTL Protocol Checksum
Source IP Address
Destination IP Address
Options (if any, usually not)
Data 29
Problem: Fragmentation
30
IP Header Fields: Word 2
• Identifier: a unique number for the original datagram
• Flags: M flag, i.e. this is the last fragment
• Offset: byte position of the first byte in the fragment
• Divided by 8
0 4 8 12 16 19 24 31
Version HLen TOS Datagram Length
Identifier Flags Offset
TTL Protocol Checksum
Source IP Address
Destination IP Address
Options (if any, usually not)
Data 31
Fragmentation Example
Length = 2000, M = 1
Offset = 0
IP Data
Length = 3820, M = 0
20 1980
IP Hdr Data
20 3800 1980
Length = 1840, M = 0 + 1820
Offset = 1980 = 3800
IP Data
20 1820
32
Fragmentation Example
36
The IPv4 Address Space Crisis
• Problem: the IPv4 address space is too small
• 232 = 4,294,967,296 possible addresses
• Less than one IP per person
• Parts of the world have already run out of addresses
• IANA assigned the last /8 block of addresses in 2011
Regional Internet Registry
Region (RIR) Exhaustion Date
Asia/Pacific APNIC April 19, 2011
Europe/Middle East RIPE September 14, 2012
North America ARIN 13 Jan 2015 (Projected)
South America LACNIC 13 Jan 2015 (Projected)
Africa AFRINIC 17 Jan 2022(Projected)
37
IPv6
• IPv6, first introduced in 1998(!)
• 128-bit addresses
• 4.8 * 1028 addresses per person
• Address format
• 8 groups of 16-bit values, separated by ‘:’
• Leading zeroes in each group may be omitted
• Groups of zeroes can be omitted using ‘::’
2001:0db8:0000:0000:0000:ff00:0042:8329
2001:0db8:0:0:0:ff00:42:8329
2001:0db8::ff00:42:8329
38
IPv6 Trivia
39
IPv6 Header
• Double the size of IPv4 (320 bits vs. 160 bits)
0 4 8 12 16 19 24 31
Version DSCP/ECN Flow Label
Datagram Length Next Header Hop Limit
Version Same
= 6 as IPv4 Groups
Same as IPv4 Same as into Same as TTL in
packets
Source IP Address
Protocol in for
flows, used IPv4
IPv4QoS
Destination IP Address
40
Differences from IPv4 Header
• Several header fields are missing in IPv6
• Header length – rolled into Next Header field
• Checksum – was useless, so why keep it
• Identifier, Flags, Offset
• IPv6 routers do not support fragmentation
• Hosts are expected to use path MTU discovery
• Reflects changing Internet priorities
• Today’s networks are more homogeneous
• Instead, routing cost and complexity dominate
41
Performance Improvements
• No checksums to verify
• No need for routers to handle fragmentation
• Simplified routing table design
• Address space is huge
• No need for CIDR (but need for aggregation)
• Standard subnet size is 264 addresses
• Simplified auto-configuration
• Neighbor Discovery Protocol
• Used by hosts to determine network ID
• Host ID can be random!
42
Additional IPv6 Features
Source Routing
• Host specifies the route to wants packet to take
Mobile IP
• Hosts can take their IP with them to other networks
• Use source routing to direct packets
Privacy Extensions
• Randomly generate host identifiers
• Make it difficult to associate one IP to a host
Jumbograms
• Support for 4Gb datagrams
43
Deployment Challenges
46
6to4 Basics
• Problem: you’ve been assigned an IPv4 address, but you want an IPv6
address
• Your ISP can’t or won’t give you an IPv6 address
• You can’t just arbitrarily choose an IPv6 address
• Solution: construct a 6to4 address
• 6to4 addresses always start with 2002::
• Embed the 32-bit IPv4 inside the 128-bit IPv6 address
Dest: 2002:104F:0800::
Dest: 16.79.8.0
IPv4
Internet
IPv4
Internet IPv4 – 192.88.99.1
IPv6 – 2002:: /16
IPv4 – 207.46.192.0
IPv6 – 2002:CF2E:C000::
IPv6
Many ISPs Internet
provide 6to4
relay routers
IPv6 – 1893:92:13:99:: 49
Routing from Native IPv6 to 6to4
IPv4
Internet
IPv4 – 192.88.99.1
IPv6 – 2002:: /16
IPv4 – 207.46.192.0
IPv6 – 2002:CF2E:C000:: Dest: 207.46.192.0
IPv6
Use normal IPv6 Dest: 2002:CF2E:C000::
Internet
routing to reach a
6to4 relay router
50
IPv6 – 1893:92:13:99::
Problems with 6to4
Uniformity
o Not all ISPs have deployed 6to4 relays
Quality of service
o Third-party 6to4 relays are available
o …but, they may be overloaded or unreliable
Reachability
o 6to4 doesn’t work if you are behind a NAT
Possible solutions
o IPv6 Rapid Deployment (6rd)
⁕ Each ISP sets up relays for its customers
⁕ Does not leverage the 2002:: address space
o Teredo
⁕ Tunnels IPv6 packets through UDP/IPv4 tunnels
⁕ Can tunnel through NATs, but requires special relays
51
Consequences of IPv6
Beware unintended consequences of IPv6
Example: IP blacklists
Currently, blacklists track IPs of spammers/bots
Few IPv4 addresses mean list sizes are reasonable
Hard for spammers/bots to acquire new IPs
Blacklists will not work with IPv6
Address space is enormous
Acquiring new IP addresses is trivial
52