1 of 50

CMPT 471: Networking II�Network Layer: Overview�Mohamed Hefeeda

2 of 50

An IP Packet Journey

2

Alice

VAN

EDM

REG

WIN

TOR

MON

HAL

3 of 50

An IP Packet Journey

3

Alice

VAN

EDM

REG

WIN

TOR

MON

HAL

4 of 50

An IP Packet Journey

4

src: Alice

dst: SFU

data

VAN

EDM

REG

WIN

TOR

MON

HAL

5 of 50

An IP Packet Journey

5

src: Alice

dst: SFU

data

VAN

EDM

REG

WIN

TOR

MON

HAL

6 of 50

An IP Packet Journey

6

VAN

EDM

REG

WIN

TOR

MON

HAL

src: Alice

dst: SFU

data

7 of 50

An IP Packet Journey

7

VAN

EDM

REG

WIN

TOR

MON

HAL

src: Alice

dst: SFU

data

8 of 50

An IP Packet Journey

8

VAN

EDM

REG

WIN

TOR

MON

HAL

src: Alice

dst: SFU

data

9 of 50

What happens between two routers

9

Data Plane

VAN

EDM

Data Plane

IF 1

IF 2

IF 3

IF 4

IF 1

IF 2

IF 3

IF 4

src: Alice

dst: SFU

data

SFU IF 2

Alice IF 4

DST OUT_IF

EDM Forwarding Table

Redundancy

10 of 50

What happens between two routers

10

Data Plane

VAN

EDM

Data Plane

IF 1

IF 2

IF 3

IF 4

IF 1

IF 2

IF 3

IF 4

src: Alice

dst: SFU

data

SFU IF 1

Alice IF 3

DST OUT_IF

VAN Forwarding Table

11 of 50

What happens between two routers

11

Data Plane

VAN

EDM

Data Plane

src: Alice

dst: SFU

data

IF 1

IF 2

IF 3

IF 4

IF 1

IF 2

IF 3

IF 4

12 of 50

What happens between two routers

12

In the current Internet, forwarding happens by:

    • examining the destination address, and
    • matching it with a local forwarding table

But, who calculates the forwarding tables?

src: Alice

dst: SFU

data

Forwarding Table

IP Packet

Match

This is called Packet Forwarding

    • moving packets from router’s input to appropriate router output
    • done by the data-plane component

13 of 50

Routers Have “Brains”

13

Control Plane

Control Plane

Data Plane

Data Plane

This brain is called the Control Plane

VAN

EDM

14 of 50

Routers Have “Brains”

14

Control Plane

Control Plane

The control plane runs a routing algorithm to:

    • find routes, and
    • fill the tables

VAN

EDM

SFU IF 1

Alice IF 3

DST OUT_IF

VAN Forwarding Table

SFU IF 2

Alice IF 4

DST OUT_IF

EDM Forwarding Table

Routing algorithm

Routing algorithm

15 of 50

Control Plane: Two Approaches

15

Control Plane

Control Plane

VAN

EDM

SFU IF 1

Alice IF 3

DST OUT_IF

VAN Forwarding Table

SFU IF 2

Alice IF 4

DST OUT_IF

EDM Forwarding Table

Routing algorithm

Routing algorithm

Control Plane

REG

SFU IF 2

Alice IF 4

DST OUT_IF

REG Forwarding Table

Routing algorithm

Distributed Approach: routers exchange messages with each other to calculate tables

    • Examples: OSPF, ISIS

16 of 50

Control Plane: Two Approaches

16

Agent

Agent

VAN

SFU IF 1

Alice IF 3

DST OUT_IF

VAN Forwarding Table

SFU IF 2

Alice IF 4

DST OUT_IF

EDM Forwarding Table

Agent

REG

SFU IF 2

Alice IF 4

DST OUT_IF

REG Forwarding Table

Centralized Approach: routers exchange messages with an external software

    • Software-defined networking (SDN)
    • Examples: OpenFlow

Control Plane

17 of 50

Forwarding vs Routing

17

Forwarding

Routing

Plane

Data plane

Control plane

Objective

Move pkts to output ports

Compute network paths

Scope

Local to routers

Network level

Implementation

Hardware (often)

Software (often)

Timescale

nanoseconds

milliseconds – seconds

Network layer (or routers) has two functions:

    • Forwarding
    • Routing

18 of 50

Forwarding vs Routing

18

Forwarding

Routing

Plane

Data plane

Control plane

Objective

Move pkts to output ports

Compute network paths

Scope

Local to routers

Network level

Implementation

Hardware (often)

Software (often)

Timescale

nanoseconds

milliseconds – seconds

Network layer (or routers) has two functions:

    • Forwarding
    • Routing

19 of 50

Network Layer: Overview

19

forwarding

table

routing protocols

  • path selection
  • RIP, OSPF, BGP

IP protocol

  • addressing conventions
  • datagram format
  • packet handling conventions

ICMP protocol

  • error reporting
  • router “signaling”

transport layer: TCP, UDP

link layer

physical layer

network

layer

20 of 50

IP is the waist of the “hourglass”

20

  • Multiple higher-layer protocols
    • Transport and Application

  • Multiple lower-layer protocols
    • Link and Physical

  • Single Internet protocol

🡪 No need to update routers and hosts every time we have new: service, device, or link technology, …!

HTTP, FTP, DNS, SMTP, …

TCP, UDP, …

IP

Copper, fiber, radio

Ethernet, PPP, …

CSMA, SONET, …

At every router/host

21 of 50

IPv4 Datagram Format

21

Fragmentation

Header & data

Addressing

E.g., TCP segment

ICMP 0x01

TCP 0x06

UDP 0x11

IPv6 0x29

Size: 20 bytes (min)

22 of 50

IPv4 Fragmentation

  • Different link layer protocols have different MTU
    • MTU: Maximum transmission unit

  • A router can break a datagram into fragments
    • If MTU of outgoing link is less than pkt size

  • Destination reassembles IP fragments
    • To be delivered to transport layer
    • Why is reassembly done at destination?
    • Reduce load on routers. Packet can be fragmented multiple times on the path

22

23 of 50

IPv4 Fragmentation

  • Example:

23

Router A

Router B

MTU = 4000

MTU = 1500

4000 bytes

1500 bytes

1500 bytes

1040 bytes

Fragment 1

Fragment 2

Fragment 3

4000 bytes

24 of 50

IPv4 Fragmentation

  • Example:

24

3980 B

20 B

1480 bytes

20 B

Fragment 1

1480 bytes

20 B

Fragment 2

1020 bytes

20 B

Fragment 3

25 of 50

IPv4 Fragmentation

  • Issues
    • All fragments must be delivered to destination 🡪 increases likelihood of packet dropping!
    • Last fragment may have non-optimal size 🡪 wasting router resources
    • Destination needs to hold IP fragments in memory
    • Only first datagram contains TCP/UDP header
      • Firewalls and other network functions may not work well with IP fragments (some needs to keep state about TCP segments)

  • In the current Internet, fragmentation is not recommended
  • IPv6 does not support fragmentation

25

26 of 50

Time-to-live (TTL)

  • Max. number of traversed hops
    • Before a datagram is dropped (Why?)

  • TTL value is set by the source
    • Linux/Mac 64
    • Windows 128
    • Solaris, Cisco IOS 255

26

Often used in OS Fingerprinting tools

Loops!

27 of 50

Time-to-live (TTL)

  • When a router receives an IP datagram:
    • Decrement TTL by 1
    • If TTL is 0 🡪 drop pkt
    • Else forward pkt

  • Does router need to recalculate checksum?
    • Yes. (TTL is part of the IP header)

27

28 of 50

IPv4 Addressing

  • IP address: 32-bit identifier for an interface
  • Interface: connection between host/router and physical link

  • A router typically has multiple (many) interfaces
  • A host typically has one or two interfaces

An IP addresses is associated with each interface

28

29 of 50

IPv4 Addressing

29

223.1.1.1 = 11011111 00000001 00000001 00000001

223

1

1

1

.

.

.

223.1.1.1

223.1.1.2

223.1.1.3

223.1.1.4

223.1.2.9

223.1.2.2

223.1.2.1

223.1.3.2

223.1.3.1

223.1.3.27

30 of 50

IPv4 Addressing: Subnets

30

223.1.3.X

223.1.2.X

223.1.1.X

223.1.1.1

223.1.1.2

223.1.1.3

223.1.1.4

223.1.2.9

223.1.2.2

223.1.2.1

223.1.3.2

223.1.3.1

223.1.3.27

subnet

31 of 50

Subnets

  • IP address:
    • subnet part: high order bits
    • host part: low order bits

  • What’s a subnet ?
    • interfaces that can reach each other without intervening router

31

223.1.1.1

223.1.1.2

223.1.1.3

223.1.1.4

223.1.2.9

223.1.2.2

223.1.2.1

223.1.3.2

223.1.3.1

223.1.3.27

Subnet

32 of 50

Subnets

  • How many subnets?
    • 6

  • Recipe
    • to determine the subnets, detach each interface from its host or router, creating islands of isolated networks
    • each isolated network is a subnet

32

223.1.9.2

223.1.9.1

223.1.7.0

223.1.7.1

223.1.8.0

223.1.8.1

223.1.2.6

223.1.2.2

223.1.2.1

223.1.3.2

223.1.3.1

223.1.3.27

223.1.1.1

223.1.1.2

223.1.1.3

223.1.1.4

33 of 50

IPv4 Addressing: CIDR

  • CIDR: Classless Inter Domain Routing
  • IP address is composed of
    • a subnet part (or prefix)
    • a host part (or suffix)
  • Address format: a.b.c.d/x, where x is # bits in subnet portion (called mask)

33

11001000 00010111 00010000 00000000

200.23.16.0/24

Subnet part

24 bits

Host part

32 - 24 = 8 bits

34 of 50

IPv4 Addressing: CIDR

34

11001000.00010111.00010000. 00000000 200.23.16.0

200.23.16.0/24

/24 bits means that we have 8 bits to use for hosts

Subnet part (Prefix) Host part (Suffix) IP address

11001000.00010111.00010000. 00000001 200.23.16.1

11001000.00010111.00010000. 00000010 200.23.16.2

11001000.00010111.00010000. 11111110 200.23.16.254

11001000.00010111.00010000. 11111111 200.23.16.255

35 of 50

IPv4 Addressing: CIDR

35

11001000.00010111.00010000. 00000000 200.23.16.0

Subnet part (Prefix) Host part (Suffix) IP address

11001000.00010111.00010000. 11111111 200.23.16.255

In practice, the first and last IP addresses of a prefix are reserved

Identifies the network

(host part is all 0’s)

Identifies the broadcast address

(host part is all 1’s)

🡪 /24 can support up to 254 (=256-2) hosts

36 of 50

How to get an IP address?

How does a host get IP address?

  • Hard-coded by system admin in a file
  • DHCP: Dynamic Host Configuration Protocol
    • dynamically get address from a server

36

37 of 50

How to get an IP address?

How does a network get IP address space?

  • Gets allocated portion of its provider ISP’s address space

37

38 of 50

How to get an IP address?

38

ISP A 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

Example: Given an ISP network called A with address 200.23.16.0/20.

How can it allocate IP addresses for 8 customer networks?

Use additional 3 bits to allocate addresses for the 8 customer networks.

39 of 50

Hierarchical IP Addressing

  • IP addresses are hierarchical

39

200.23.16.0/20

200.23.16.0/23

200.23.18.0/23

200.23.20.0/23

200.23.30.0/23

This is ISP A

The eight customer networks

200.23.18.0/26

200.23.18.64/26

200.23.18.192/26

200.23.19.0/26

Other eight customer networks of 200.23.18.0/23

200.23.0.0/16

ISP A is a customer of other provider

40 of 50

Hierarchical IP Addressing

  • Hierarchical addressing allows efficient advertisement of routing information:

40

“Send me anything

with addresses

beginning

200.23.16.0/20

200.23.16.0/23

200.23.18.0/23

200.23.30.0/23

ISP A

Organization 0

Organization 7

Internet

Organization 1

200.23.20.0/23

Organization 2

.

.

.

.

.

.

200.23.16.0/20

ISP B

“Send me anything

with addresses

beginning

199.31.0.0/16

199.31.0.0/16

41 of 50

Hierarchical IP Addressing

  • Hierarchical addressing allows efficient advertisement of routing information:
  • 🡺 forwarding tables have 100s of thousands entries instead of billions

41

“Send me anything

with addresses

beginning

200.23.16.0/20”

200.23.16.0/23

200.23.18.0/23

200.23.30.0/23

ISP A

Organization 0

Organization 7

Internet

Organization 1

ISP B

“Send me anything

with addresses

beginning

199.31.0.0/16

or 200.23.18.0/23

200.23.20.0/23

Organization 2

.

.

.

.

.

.

200.23.16.0/20

199.31.0.0/16

Organization 1 moves to ISP B

42 of 50

Hierarchical IP Addressing

  • Routers forward a packet to its destination based on the subnet part, not the host part
    • use longest address prefix that matches destination address
    • This is called the longest prefix matching

42

200.23.18.0/23 IF2

DST OUT_IF

Forwarding Table

200.23.16.0/20 IF1

199.31.0.0/16 IF2

src: Alice

dst: 200.23.16.5

data

200.23.16.0/23

200.23.18.0/23

200.23.30.0/23

ISP A

Organization 0

Organization 7

Organization 1

ISP B

200.23.20.0/23

Organization 2

.

.

.

.

.

.

200.23.16.0/20

199.31.0.0/16

IF 1

IF 2

Longest prefix match

43 of 50

Hierarchical IP Addressing: Summary

  • Scalable forwarding tables

  • Adding/removing hosts without modifying forwarding table

  • Small prefix advertisement overhead

43

44 of 50

IPv6

  • Initial motivation:
    • 32-bit address space soon to be completely allocated.

  • Additional motivation:
    • header format helps speed processing/forwarding
    • header changes to facilitate QoS

  • IPv6 datagram format:
    • fixed-length 40-byte header
    • no fragmentation allowed

44

45 of 50

IPv6 Datagram Format

45

Priority/Traffic Class: identify priority among datagrams in flow

Flow Label: identify datagrams in same “flow”

Next header: identify upper layer protocol for data

46 of 50

Other Changes

  • Checksum: removed entirely to reduce processing time at each hop
  • Options: allowed, but outside of header, indicated by “Next Header” field
  • No Fragmentation:
    • Packet is dropped if its size is larger than outgoing link MTU
    • An error message is sent to the sender

46

47 of 50

IPv4 🡪 IPv6

  • Not all routers can be upgraded simultaneously
    • how will network operate with mixed IPv4 and IPv6 routers?

  • Tunneling:
    • IPv6 datagram carried as payload in IPv4 datagram among IPv4 routers

47

IPv4 source, dst addr

IPv4 header fields

IPv4 datagram

IPv6 datagram

UDP/TCP payload

IPv6 source dest addr

IPv6 header fields

48 of 50

IPv4 🡪 IPv6: Tunneling

48

IPv4 tunnel

connecting IPv6 routers

A

B

E

F

IPv6

IPv6

IPv6

IPv6

Logical View

Physical View

A

B

E

F

IPv6

IPv6

IPv6

IPv6

C

D

IPv4

IPv4

49 of 50

IPv6 Deployment

  • It is hard to change the network-layer protocols!
  • IPv6 was first introduced in 1995!

49

Percentage of users accessing Google using IPv6: Source

50 of 50

Network Layer--Data Plane: Summary

  • Network layer: forwarding vs. routing
    • Control plane vs data plane
    • Distributed control plane (traditional) vs centralized control plane (new)
  • IPv4, IPv6
    • Tunnelling to allow incremental deployment of IPv6
  • Subnets and hierarchical addressing
    • Allows routing at large scale (much fewer entries in routing tables)

50