Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet...

242
Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer

Transcript of Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet...

Page 1: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 1

Computer NetworksAn Open Source Approach

Chapter 4: Internet Protocol Layer

Page 2: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 2

Content 4.1 General Issues 4.2 Data-Plane Protocols: IPv4 4.3 Data-Plane Protocols: IPv6 4.4 Control-Plane Protocols: Address

Management 4.5 Control-Plane Protocols: Error Reporting 4.6 Control-Plane Protocols: Routing 4.7 Control-Plane Protocols: Multicast Routing 4.8 Summary

Page 3: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Data Link

IP ARP

ICMP

TCP/UDP

IP addressSubnetDefault router

DHCP server

host

Data Link

IP

NAT Server

NAT

Router

Data Link

IP

RoutingProtocols

RoutingTable

Protocols Discussed in this Chapter

Chapter 4: Internet Protocol Layer 3

Page 4: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

udp_v4_rcv UDP

tcp_v4_rcv TCP

raw_v4_input

Raw IP

Medium Access Control (MAC)

net_tx_action dev_queue_xmit

ip_output

ip_finish_output

ip_finish_output2

ip_push_pending_frames

ip_append_data ip_append_page

TCP UDP Raw IP

dst_output

skb->dst->output

IP

Layer

Transport

Layer

ip_queue_xmit

ip_local_deliver_finish

ip_route_output_flow __ip_route_output_key ip_route_output_slow

ip_rcv

dst_input

ip_route__input

ip_local_deliver

skb->dst->input

ip_rcv_finish

netif_receive_skb net_rx_action

Data link Layer

Open Source Implementation 4.1: IP-Layer Packet Flows in Call Graphs

Chapter 4: Internet Protocol Layer 4

Page 5: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 5

Page 6: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 6

Page 7: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 7

4.1 General Issues

Service Addressing Forwarding Routing Security

Page 8: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 8

Service

Provides a host-to-host transmission service Connects several LANs into an internetwork

a network of networks “Internet”

the global internetwork to which most of networks are connected

Page 9: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 9

Internetwork An example of an internetwork

R1 R2

Ethernet Fast Ethernet

GigabitEthernet

Wireless LAN

H1 H2

H3

R3

Page 10: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 10

Internet Service Model

Connectionless Best effort delivery

packets may be lost packets are delivered out of order duplicate copies of a packet are delivered packets can be delayed for a long time

Next-hop forwarding based on destination address

Page 11: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 11

Address

A globally unique address for host identification

Data link layer: a flat address Network layer: a hierarchical address

Page 12: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 12

Deliver a packet

How to deliver a packet? Routing

Find a path from source to destination Done by routing protocols

Forwarding Forward packets at a router Look up the next-hop from the routing table and then

forward

Page 13: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 13

Forwarding at Data Plane

Steps Extract destination address Look up destination address in routing table

Obtain the output interface from routing table Forward the packet

Page 14: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 14

Look Up the Routing Table

Issues Speed and memory requirement Good data structure

fast look up and table update low memory requirement

Classical approaches Trie Hash Fast lookup table Hardware implementation

Page 15: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 15

Routing at Control Plane

Task of routing Select a path from the source to the destination

Goal of routing Efficient (low delay, high throughput, …) Scalable Stable Robust Fair

Page 16: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 16

IP Routing

Hop-by-hop routing Option: source routing

Shortest path routing Available information

Global information vs. local information Information exchange

Flooding (broadcast) vs. neighbors only

Page 17: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 17

Multicast

Definition of a multicast Communication between a group of hosts Packets are sent to all group members

Issues Group membership

receivers of a multicast session Multicast tree construction

Multiple point-to-point connections or a multicast tree A multicast tree connects the source node to all

destination nodes

Page 18: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 18

Security of IP

Aspects on the network security Access Control

Control who has the rights to access Data Security

Encrypt messages transmitted Intrusion Detection

Detect illegal break in

Page 19: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 19

Data-Plane Protocols and Mechanisms

3.2 Internet Protocol

3.3 Internet Protocol Version 6

Page 20: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 20

4.2 Internet Protocol

Addressing Subnetting Forwarding Packet format Fragmentation and re-assembly

Page 21: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 21

IP Address

A globally unique 32-bit address to identify a network interface

A hierarchical address consists of network id and host id

A router usually has more than one interface and one address

A host may have more than one address

Page 22: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 22

IP Address Notation

140.123.1.1 = 10001100 01111011 00000001 00000001

140 123 11

IP address notation

Page 23: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

23

Transmission Order

byte order transmitted from network layer to data link layer

Big Endian

00000001 00000001 01111011 10001100

byte order stored in memory

Big Endian

10001100 01111011 00000001 00000001

A A+1 A+2 A+3

Little Endian

00000001 00000001 01111011 10001100

A A+1 A+2 A+3

bit order transmitted from Ethernet to physical layer

Little Endian

… 1 0 0 0 1 1 0 0

23Chapter 4: Internet Protocol Layer

Page 24: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 24

Class-ful IP Address

bits 0 1 2 3 4 8 16 24 31

Class A

Class B

Class C

Class D

0 Network Host 0.0.0.0 to

127.255.255.255

128.0.0.0 to

191.255.255.255

192.0.0.0 to

223.255.255.255

224.0.0.0 to

239.255.255.255

240.0.0.0 to

255.255.255.255 Class E

Network

Network Host

Host 1 0

1 1 0

1 1 1 0

1 1 1 1

Multicast address

Reserved

Page 25: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 25

Reserved IP Addresses

Host id = 0 denotes the network itself

Host id = F…F broadcast address of the network

Page 26: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 26

IP Subnet

Network address uniquely identifies a physical network

A physical network consists of several LANs Subnet mask is used to identify a subnet Hosts in the same IP subnet talk directly without

intervening router For example

cs.ccu.edu.tw: 140.123.101.0 subnet mask: 255.255.255.0 or 140.123.101.0/24

Page 27: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

IP Subnet Addressing

Copyright reserved 2001 (Lin & Hwang) 27

bits 0 1 2 3 4 8 16 24 31

Class A

Class B

Class C

0 Network Host

Network

Network Host

Host 1 0

1 1 0

Subnet

Subnet

Subnet

27Chapter 4: Internet Protocol Layer

Page 28: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 28

IP Subnet

R1

R2 R3

140.123.250.1

140.123.250.3 140.123.250.2 Subnet:

140.123.250.0

H3 H4

Subnet: 140.123.2.0

140.123.2.250

140.123.2.1 140.123.2.2

H5

Subnet: 140.123.3.0

140.123.3.1

H1 H2 Subnet:

140.123.1.0

140.123.3.250

140.123.1.250

140.123.1.2 140.123.1.1

Page 29: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 29

Classless IP Address

Classful addressing: Inefficient use of address space

A class B address is too large A class C address is too small

Scalability: too many class C routing entries CIDR: Classless InterDomain Routing

network portion of address of arbitrary length address format: a.b.c.d/x

Page 30: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 30

Page 31: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 31

Authority

ICANN: Internet Corporation for Assigned

Names and Numbers allocates addresses manages DNS assigns domain names, resolves disputes

Page 32: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 32

IP Forwarding

Aspects of forwarding Packets from upper layer protocols Packets from a network interface

Routing table Forwarding is based on routing table Routing entry: (Destination/SubnetMask, NextHop) Default router: (0.0.0.0/0, default router)

Page 33: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 33

Packet Forwarding (at Host)

If (NetworkAddress of the destination == My subnet address) then

Transmit the packet directly to the destination

Else

Look up the routing table

Deliver the packet to the default router

End if

Check if destination is in my sbunet:If ((HostIP ^ DestinationIP) & SubnetMask)==0)

Page 34: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 34

Packet Forwarding (at Router)

Look up the routing table

If the packet is to be delivered to the upper layer

Deliver the packet to an upper layer protocol

Else if the packet is to be delivered to a directly connected subnet

Deliver the packet directly to the destination

Else

Deliver the packet to a next hop router

End if

Page 35: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 35

Table Look Up

Longest prefix match Organization A: 194.24.0.0/21 Organization B: 194.24.7.0/24 194.24.7.10 matches 194.24.0.0/21 (21 bits) as

well as 194.24.7.0/24 (24bits) Longest prefix: 194.24.7.0/24 is the right routing

entry

Page 36: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 36

Page 37: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 37

Open Source Implementation 4.2: IPv4 Packet Forwarding

Search cache first; if not found, search the routing table (FIB).

ip_route_output()

ip_route_output_key()

return ip_route_output_slow() found? yes no

Page 38: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 38

Open Source Implementation 4.2 (cont)Routing Cache

rt_hash_table chain

chain

chain

rtable u.rt_next

rtable

Page 39: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 39

Open Source Implementation 4.2 (cont)Routing Table (FIB)

fib_table

tb_data

fn_hash

fn_zones[32]

fn_zone_list

fn_zones[0] fn_zones[1]

fn_zones[2]

fz_next

fz_hash[..]

fn_zone

fz_next

fz_hash[..]

fn_zone

fz_next

fz_hash[..]

fn_zone

fib_node

fn_next

fn_info

fib_node

fn_next

fn_info

fib_info

fib_nh

fib_nh

nh_gw

nh_dev

Page 40: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 40

IP Packet Format (1/5) 0 8 16 24 31

Version

4

Header Length

Type of Service

Packet Length (bytes)

Data

Identifier Flags 13-bit Fragmentation Offset

Time-to-Live Upper Layer Protocol Header Checksum

Source IP Address

Destination IP Address

Options

Page 41: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 41

IP Packet Format (2/5)

Version Number Current version 4 Version for next generation IP is 6

Header Length In units of 4-byte words

Type of Service (TOS) Desired service of the packet

Page 42: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 42

IP TOS

Precedence Type of Service R

Precedence defined In RFC 791: 111: network control 110: Internetwork control 101: CRITIC/ECP 100: Flash override 011: Flash 010: Intermediate 001: Priority 000: Routine

TOS defined in RFC 1349: 1000: minimize delay 0100: maximize throughput 0010: maximize reliability 0001: minimize cost 0000: normal service 1111: maximize security R: Reserved

Not implemented!!Partially implemented!!

New:Used as DS codepoint.

Page 43: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 43

IP Packet Format (3/5)

Packet Length Total number of bytes (header + data) Maximum is 65,535 bytes

Identifier Uniquely identify an IP packet

Flags Low-order two bits: for fragmentation control

First bit: do not fragment Last bit: more

Page 44: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 44

IP Packet Format (4/5)

Fragmentation Offset Position of the fragment, measured in unit of 8

bytes. Time-to-live (TTL)

Used as hop limit Each router decrease TTL by one If TTL reaches zero, sent an ICMP message

Upper Layer Protocol IP:0, ICMP:1, TCP:6, UDP:17

Page 45: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 45

IP Packet Format (5/5)

Header Checksum 16-bit 1’s complement checksum of the IP header

and IP options Source Address (32 bits) Destination Address (32 bits) Options

loose source routing, strict source routing, record route, record timestamp

Data Payload from upper layers

Page 46: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 46

Open Source Implementation 4.3:IPv4 Checksum in Assembly ip_fast_csum() function

(src/include/asm_i386/checksum.h). optimized by writing this function in assembly

languages. For 80x86 machines,

do the summation in 32-bit words first The result is then copied to another register Shifting registers to have 16 bits in their low-order bits add up registers Taking the complement of the result gives the checksum

Page 47: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 47

IP Fragmentation & Reassembly Limitation from data link layers

MTU(different link-layers, different MTUs) An IP packet larger than MTU of its data link layer

needs to be “fragmented” one packet becomes several small packets Re-assembled only at the destination

IP

Packet

Help, cannot get through.

Yes, can get through now.

IP fragments

link-layer link-layer

Page 48: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 48

Fragment Control

Identify fragments of a packet All fragments have the same identifier

Know the position of a fragment Recorded in fragmentation offset (13 bits)

Know the end of a packet more fragment bit of the last fragment is 0

Page 49: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 49

IP Fragmentation Example

Header

id=x, more=0, offset=0 id=x, more=1, offset=0

3200 bytes of data

1480 bytes of data

Header

id=x, more=1, offset=185

1480 bytes of data

Header

id=x, more=0, offset=370

240 bytes of data

Header

(a) Original packet (b) Fragments

Page 50: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 50

Open Source Implementation 4.4:IPv4 Fragmentation Upper layer protocol calls ip_queue_xmit() After routing is determined, call ip_queue_xmit2() ip_queue_xmit2() calls ip_fragment() if the packet

length is larger than the MTU of the device ip_fragment()

A while loop is used to fragment the original packet into fragments

Size (in bytes) of a fragment, except the last one, is set to the largest multiplicative number of 8 that is less than the MTU

Page 51: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 51

Open Source Implementation 4.4 (cont)Re-Assembly

net_bh() ip_rcv() ip_route_input()

ip_local_deliver_finish()

In ip_local_deliver():

more or offset is set? yes

ip_defrag()

In ip_defrag():

ip_find() ip_frag_reasm() all fragments in? ip_frag_queue()

In ip_find():

ip_frag_create()

found in hash table? ipqhashfn()

no

yes return queue

no

ip_local_deliver()

Page 52: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 52

Network Address Translation

Network Address Translation Protocol

Page 53: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 53

Network Address Translation

Why NAT? Solution to IP address depletion Private IP address (RFC 1597)

10.0.0.0-10.255.255.255 172.16.0.0-172.31.255.255 192.168.0.0-192.168.255.255

Network address translation (RFC 3022) Allow hosts with private IP address to have Internet

access Short-term solution for IP address depletion Also provides security for Intranet service

Page 54: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 54

NAT Example

NAT Table

10.2.2.2 ==> 140.123.101.30

10.2.2.3:1175 ==> 140.123.101.30:6175

Router

With

NAT

Src: 10.2.2.2: 1064

Dst: 140.113.250.5: 80

Src: 140.123.101.30: 1064

Dst: 140.113.250.5: 80

Src: 10.2.2.3: 1175

Dst: 140.113.54.100: 21

Src: 140.123.101.30: 6175

Dst: 140.113.54.100: 21

Page 55: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 55

Types of NAT (1/2)

NAT with a pool of global IP addresses 10.2.2.2 ==> 140.123.101.30 10.2.2.3 ==> 140.123.101.31 dynamic: translate IP address on demand static: translate IP address with pre-configuration

NAT with Port Address Translation (NAPT) of one global IP address 10.2.2.2:1064 ==> 140.123.101.30:5064 10.2.2.3:1175 ==> 140.123.101.30:6175

Page 56: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 56

Types of NAT (2/2)

Port redirection Redirect all WWW service to a specific IP and

private port number DNS: www.cs.ccu.edu.tw ==> 140.123.101.38 NAT: 140.123.101.38:80 ==> 10.2.2.2:8080

Transparent proxy Enforce all www traffic to a proxy with cache

140.123.101.38:80 ==> internal www proxy (10.1.1.1) All HTTP requests go to the internal proxy

Page 57: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 57

Page 58: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 58

Page 59: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 59

Page 60: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 60

Page 61: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 61

Problems with NAT (1/2)

Modify source IP and/or port number Modify IP header checksum Modify TCP checksum Application dependent modification

ICMP: Basic NAT: ICMP checksum, query id (echo) NAPT: ICMP packets that may contain IP address

destination unreachable (3), source quench (4), redirect (5), time exceeded (11), IP header error (12)

Page 62: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 62

Problems with NAT (2/2)

Application Specific Gateways (ALGs) FTP

PORT/PASV command has IP address:port in ASCII Translate IP address may result in a change of packet

size If new size is shorter, pad with zeroes If new size is longer, need to change TCP sequence

number Affects acknowledge, congestion control, … A special table is used to correct the TCP sequence and

acknowledge numbers Others: SMTP, SNMP, …….

Page 63: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 63

Page 64: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 64

Open Source Implementation 4.5: NAT Source and destination NAT implementation

in Linux iptables

From

Interface

PRE_ROUTING

(Destination NAT)

POST_ROUTING

(Source NAT)

Routing

Decision

LOCAL_OUT

(Destination NAT)

Upper Layer (TCP/UDP)

To

Interface

Page 65: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 65

Open Source Implementation 4.5 (cont) Data structure

Hash table: ip_conntrack_hash[] Hash function: hash_conntrack() Linear search with a hashed list

do_masquerade() ip_conntrack_in() resolve_normal_ct()

ip_conntrack_find_get()

Page 66: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 66

Open Source Implementation 4.5 (cont) NAT function flows

ip_nat_out()

manip_pkt()

ip_nat_localout()

ip_nat_out() do_bindings()

upper_layer_protocol->manip_pkt()

Page 67: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 67

Open Source Implementation 4.5 (cont) FTP ALG function flows

do_bindings() helper->help() ftp_data_fixup()

mangle_rfc959_packet() ip_nat_seq_adjust()

ip_nat_mangle_tcp_packet() ip_nat_resize_packet()

Page 68: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 68

Page 69: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 69

4.3 Internet Protocol Version 6

Changes from IPv4 IPv6 Header IPv6 Extension Header IPv6 Fragmentation and Reassembly IPv6 Address Space

Page 70: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 70

IPv6

Problems with IPv4 Shortage of address space Lack of Quality of Service guarantee

New features of IPv6 Enlarge address space Fixed header format helps speed processing/forwarding Better support for Quality of Service Auto-configuration new “anycast” address: route to “best” of several replicated

servers

Page 71: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 71

IPv6 Header (1/2)

16 0 4 24 31

Version Traffic Class 12

Flow Label

Payload Length Next Header Hop Limit

Source Address (16 octects)

Destination Address (16 octects)

Page 72: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 72

IPv6 Header (2/2)

Version: 6 Traffic class:

identify class of service E.g., DiffServ (DS codepoint)

Flow Label: identify datagrams in same “flow”

Next header: identify upper layer protocol for data

Page 73: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 73

Changes from IPv4 (1/3)

16 0 4 24 31

Version Traffic Class 12

Flow Label

Payload Length Next Header Hop Limit

Source Address (16 octects)

Destination Address (16 octects)

0 8 16 24 31

Version

4

Header Length

Type of Service

Packet Length (bytes)

Data

Identifier Flags 13-bit Fragmentation Offset

Time-to-Live Upper Layer Protocol Header Checksum

Source IP Address

Destination IP Address

Options

Page 74: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 74

Changes from IPv4 (2/3)

Expanded Addressing Capabilities From 32 bits to 128 bits (more level and nodes) Improve multicast routing (“scope” field) “anycast address”: send a packet to any one of a

group of nodes

Header Format Simplification Reduce bandwidth cost

Extensions More flexibility

Page 75: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 75

Changes from IPv4 (3/3)

Options Allowed, but outside of header, indicated by “Next

Header” field

Checksum Removed to reduce processing at routers

Fragmentation Not allowed at intermediate routers

Page 76: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 76

IPv6 Extension Header Examples

Next Header = TCP

IPv6 Header TCP Header Data

Next Header = TCP

Routing Header TCP Header Data

Next Header = Routing

IPv6 Header

Next Header = TCP

Fragment Header TCP Header Data

Next Header = Routing

IPv6 Header

Next Header = Frag.

Routing Header

(a) No extension header

(b) IPv6 header followed by a routing header

(c) IPv6 header followed by a routing header and a fragment header

Page 77: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 77

IPv6 Extension Header (1/2) Order of extension headers

IPv6 (41) Hop-By-Hop Options header (0) Destination Options header (60) Routing header (43) Fragment header (44) Authentication header (51) Encapsulating Security Payload header (50) Destination Options header (60) Upper-layer header

ICMPv6(58) TCP(6), UDP(17), RSVP(46), SCTP(132)

Page 78: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 78

IPv6 Extension Header (2/2)

Not processed by intermediate routers except hop-by-hop option header

Processed strictly in order Each extension header occurs at most once

except Destination Options header, which occurs at most twice

Page 79: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Order of IPv6 Extension Headers

Basic IPv6 header

Basic IPv6 header

Hop-by-Hop Options header (0)

Destination Options header (60)

Routing header (43)

Fragment header (44)

Authentication header (51)

Encapsulating Security Payload header (50)

Destination Options header (60)

Mobility header (135)

No Next header (59)

Upper-layer header: TCP (6), UDP (17), ICMPv6 (58)

Chapter 4: Internet Protocol Layer 79

Page 80: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 80

Fragment Header

Fragmentation is only performed by source Fragment header format

16 0 8 29 31 Next Header Reserved Fragment Offset R M

Identifier

Page 81: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 81

Fragmentation Example

IPv6 Header Fragment 1 Data

(a) Original packet

Fragment 2 Data Fragment 3 Data

IPv6 Header Fragment Header

(b) Fragments

Fragment 1 Data

IPv6 Header Fragment Header Fragment 2 Data

IPv6 Header Fragment Header Fragment 3 Data

Page 82: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 82

Packet Size Issue

MTU of every link must >= 1280 bytes Use Path MTU Discovery to discover MTU greater

than 1280 bytes A node need to accept a fragmented packet that

is as large as 1500 octets

Page 83: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 83

IPv6 Addressing

Three categories Unicast Multicast Anycast

Notation 16-bit Hex’s separated by colons 3FFD:3600:0000:0000:0302:B3FF:FE3C: C0DB Consecutive null 16-bit numbers replaced by :: 3FFD:3600:0:0:0:0:1:A =>3FFD:3600::1:A

Page 84: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 84

IPv6 Address AssignmentPrefix Address Type Portion

0000 0000 Reserved (IPv4 compatibility) 1/256

0000 0001 Unassigned 1/256

0000 001 Reserved for NSAP 1/128

0000 010 Reserved for IPX 1/128

0000 011 Unassigned 1/128

0000 1 Unassigned 1/32

0001 Unassigned 1/16

001 Aggregatable Global Unicast Address 1/8

010 Unassigned 1/8

011 Unassigned 1/8

100 Unassigned 1/8

101 Unassigned 1/8

110 Unassigned 1/8

1110 Unassigned 1/16

1111 0 Unassigned 1/32

1111 10 Unassigned 1/64

1111 110 Unassigned 1/128

1111 1110 0 Unassigned 1/512

1111 1110 10 Link Local Unicast Address 1/1024

1111 1110 11 Site Local Unicast Address 1/1024

1111 1111 Multicast Address 1/256

Page 85: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 85

Page 86: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 86

IPv6 Unicast Address (1/2)

Unicast Address without Internal Structure:

Node Address

Unicast Address with Subnet:

Subnet Prefix Interface ID

Unicast Unspecified Address:

00000000 0000

Unicast Loopback Address:

00000000 0001

Page 87: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 87

IPv6 Unicast Address (2/2)IPv4-compatible IPv6 Address:

00000000 IPv4 Address0000

32 32 bits

IPv4-Mapped IPv6 Address:

00000000 IPv4 AddressFFFF32 32 bits

NSAP Addresses:

00000001 defined according to usage requirements

IPX Addresses:

00000010 to be defined

::FFFF:8C7B:65A0

::8C7B:65A0

Page 88: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 88

Aggregatable Global Unicast Address

P : Fromat Prefix (001) TLA : Top-Level Aggregation Identifier (8192) RES : Reserved NLA : Next-Level Aggregation Identifier SLA : Site-Level Aggregation Identifier Interface ID : Interface Identifier

3 13 8 24 16 64

P TLA ID NLA ID SLA ID RES Interface ID

Current policy: Registry /23, ISP /35, Site /48

RFC 2374

Page 89: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 89

Interface ID: EUI-64 (RFC 2464) Prefix range from 001 to 111 should use EUI-64

format for interface ID. For 48-bit MAC address

0xff-fe is inserted between the 3rd and 4th bytes The universal/local bit (the second low-order bit of the first

byte) is complemented. Example

MAC: 00-02-b3-1e-83-29 EUI-64 ID: 02-02-b3-ff-fe-1e-83-29 Link local: FE80::202:b3ff:fe1e:8329

Some problem with privacy: a host can be traced from IPv6 address

Page 90: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 90

Current Address Allocations

APNIC 2001:0200::/23 & 2001:0C00::/23 http://www.apnic.net/faq/IPv6-FAQ.html

ARIN 2001:0400::/23 http://www.arin.net/library/guidelines/ipv6_initial.html

RIPE NCC 2001:0600::/23 & 2001:0800::/23 http://www.ripe.net/ripencc/mem-services/registeration/ipv6.html

6Bone 3FFE::/16

6to4 tunnels 2002::/16

Page 91: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 91

IPv6 Multicast Address (1/2)

flag : 00PT T = 0 : well-known multicast address T = 1 : transient multicast address

scope : scope of multicast group 0000 : reserved 0001 : node-local scope 0010 : link-local scope 0101 : site-local scope 1000 : organization-local scope 1110 : global scope

Format:

flag11111111 Group ID8 32 bits4

scope4 8 8

Res Plen Prefix

64

P=0 address not assigned on prefixP=1 assigned based on prefixPlen: length of network prefixPrefix: up to 64 bits

Page 92: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 92

IPv6 Multicast Address (2/2)

Node-Local ScopeFF01:0:0:0:0:0:0:1 All Nodes AddressFF01:0:0:0:0:0:0:2 All Routers Address

Link-Local ScopeFF02:0:0:0:0:0:0:1 All Nodes AddressFF02:0:0:0:0:0:0:2 All Routers AddressFF02:0:0:0:0:1:FFxx:xxxx Solicited Node Address(Unicast : 4037::01:800:200E:8C6C is FF02::1:FF0E:8C6C)

Site-Local ScopeFF05:0:0:0:0:0:0:2 All Routers AddressFF05:0:0:0:0:0:0:3 All DHCP Servers

Page 93: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Reserved IPv6 Multicast AddressScope Reserved Address Purpose

Node-localFF01:0:0:0:0:0:0:1 All modes address

FF01:0:0:0:0:0:0:2 All routers address

Link-local

FF02:0:0:0:0:0:0:1 All nodes address

FF01:0:0:0:0:0:0:2 All routers address

FF01:0:0:0:0:0:1:FFxx:xxxx Solicited node address

Site-localFF05:0:0:0:0:0:0:2 All routers address

FF05:0:0:0:0:0:0:3 All DHCP servers address

Chapter 4: Internet Protocol Layer 93

Page 94: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 94

Transition From IPv4 To IPv6

Not all routers can be upgraded simultaneous How will the network operate with mixed IPv4 and IPv6

routers? Transition assumptions

No “Flag Day” Last Internet transition was 1983 (NCP TCP)

Transition will be incremental Possibly over several years

Transparent to end users Seamless transition from IPv4 to IPv6

IPv6 is designed with transition in mind Assumption of IPv4/IPv6 coexistence

Page 95: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 95

Transition Approaches

Dual Stacks Allow IPv4/IPv6 to co-exist on one device

Tunnels For tunneling IPv6 across IPv4 clouds

Encapsulate IPv6 packets in IPv4 packets (PID=41) Manually configured tunnel Automatic tunnel

Relies on some special IPv6 addresses

Translators IPv6 only device communicates with IPv4 only device

Page 96: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Copyright reserved 2001 (Lin & Hwang) 96

fib6_node

fib6_node fib6_node rt6_info

tb6_root

fib6_table

rt6_info

Neighbor

Entry

*parent

*right *left

Conceptual View of IPv6 Routing Table

96Chapter 4: Internet Protocol Layer

Page 97: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Copyright reserved 2001 (Lin & Hwang) 97

fib6_table

hlist_node tb6_hlist

fib6_node tb6_root

fib6_node *parent

fib6_node *left

fib6_node *right

rt6_info *leaf

rt6_info *rr_ptr

fib6_node *parent

fib6_node *left

fib6_node *right

rt6_info *leaf

rt6_info *rr_ptr

fib6_node *parent

fib6_node *left

fib6_node *right

rt6_info *leaf

rt6_info *rr_ptr

fib6_node

inet6_dev *rt6i_idev

fib6_node *rt6i_node

in6_addr rt6i_gateway

rt6_info *leaf

rt6key src

rt6key dst

rt6_info

fib6_table *rt6i_table

FIB6 Data Structure

97Chapter 4: Internet Protocol Layer

Page 98: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 98

Chapter 4Internet Protocol

LayerPart II

Page 99: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 99

Control Plane Mechanisms

Address Management Address resolution Address configuration

Error reporting Internet Control Message Protocol

Routing Intra-domain routing Inter-domain routing

Multicast

Page 100: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 100

4.4 Address Management

Address resolution Address configuration

Page 101: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 101

Address Resolution

Address Resolution Protocol (ARP)

Page 102: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 102

Address Resolution

What is address resolution Translate address at different layers For example

host name to IP address IP address to Ethernet address

Why address resolution MAC address vs. IP address

Page 103: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 103

Address Resolution Protocol

Protocol operation Source node broadcasts an ARP request packet

on the IP subnet All nodes on the subnet will receive the ARP

request, but only the target node (or some designate server) will reply an ARP reply packet via unicast

Source node receives the reply and gets the MAC address of the target node

Cache is used to speed up (w/ timer)

Page 104: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 104

ARP Packet Format (1/3)

16 0 8 24 31

Hardware Address Type Protocol Address Type

H. Addr Len P. Addr Len Operation Code

Sender Hardware Address (0-3)

Sender Hardware Addr (4-5) Sender Protocol Addr (0-1)

Sender Protocol Addr (2-3)

Target Hardware Address (0-3)

Target Hardware Addr (0-1)

Target Protocol Address

Page 105: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 105

ARP Packet Format (2/3)

HARDWARE ADDRESS TYPE Link types: Ethernet=0x0001

PROTOCOL ADDRESS TYPE Upper layer protocol identifier: IP=0x0800

HADDR LEN Length of the address of the link layer: Ethernet=6

PADDR LEN Length of the address of the network layer: IP=4

Page 106: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 106

ARP Packet Format (3/3)

OPERATION Operation code: ARP request=1, ARP reply=2 RARP

request=3, RARP reply=4 SENDER HADDR

Sender link layer address SENDER PADDR

Sender network layer address TARGET HADDR

Target link layer address, fill zero if unknown TARGET PADDR

Target network layer address

Page 107: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 107

Encapsulate ARP Packet into MAC Frame Protocol id: 0x0806 Destination address of an ARP request

packet: 0xFFFFFFFFFFFF

Page 108: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 108

Page 109: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 109

Reverse ARP (RARP)

Allow a diskless workstation to discover its IP address

Need a RARP server on each network Bootp:

Use UDP messages which are forwarded over routers to find the file server that holds the mapping

Page 110: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 110

Open Source Implementation 4.6:ARP Data structure

Hash table: arp_table Hash parameters: a primary key and device interface index

Functions Arp_send(): set up ARP header and then xmit Arp_rcv(): Only deal with reply or request operation.

Request: calls ip_input_route(), if routes to local, calls arp_send() to send out ARP reply. Otherwise, if the host is an arp proxy, also sends ARP reply.

Reply: update ARP table. __neigh_lookup(): calls neigh_lookup() to search the arp hash

table, if not found, create one Eth_rebuild_header (old) or arp_solicit() calls arp_send()

Page 111: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 111

Address Configuration

Dynamic Host Configuration Protocol (DHCP)

Page 112: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 112

Address Configuration

What is address configuration Automatically and dynamically assign an IP

address to a host Why address configuration

Setting IP address is error prone. Insufficient IP addresses: share IP addresses

among hosts Better network management

Page 113: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 113

DHCP Protocol

Dynamic Host Configuration Protocol DHCP is derived from BOOTP

Some fields are not for host configuration Operations

A host broadcasts a DHCPDISCOVER message A DHCP server receives and replies it Or a DHCP relay server receives it and forwards

to the DHCP server, gets the configuration and relays to the host

DHCP message are sent over UDP (port 67)

Page 114: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 114

State Diagram for DHCP Client

Initial

Offer

Renew Request

Bind

Rebind

/DHCPDISCOVER

/DHCPREQUEST

DHCPACK Renewal expires /DHCPREQUEST

Rebinding expires /DHCPREQUEST

DHCPNACK or Lease expires

DHCPACK

DHCPACK

DHCPNACK

DHCPOFFER

Page 115: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 115

DHCP Packet Format 16 0 8 24 31

Operation

Transaction ID

Hard. Type Hardware Len Hops

Client IP Address

Seconds Flags B

Your IP Address

Server IP Address

Router IP Address

Client Hardware Address (16 octects)

Server Host Name (64 octects)

Boot File Name (128 octects)

Options (variable)

Page 116: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 116

DHCP Packet Format

More information for host configuration such as default router, subnet mask encoded in the option field (code=55, length, parameter)

ID Request Parameter 1 Subnet mask 3 Default gateway 6 DNS server

12 Host name 15 Domain name 17 Boot path 40 NIS domain name

Page 117: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 117

DHCP Packet Format

Options Option field starts with three fields: code (53), length(1),

type(1-7)Type DHCP Message

1 DHCPDISCOVER 2 DHCPOFFER 3 DHCPREQUEST 4 DHCPDECLINE 5 DHCPACK 6 DHCPNACK 7 DHCPRELEASE

Page 118: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 118

Page 119: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 119

Open Source Implementation 4.7:DHCP

ip_auto_config() ic_dynamic() ic_bootp_send_if()

ic_dhcp_init_options()

struct bootp_pkt { /* BOOTP packet format */ struct iphdr iph; /* IP header */ struct udphdr udph; /* UDP header */ u8 op; /* 1=request, 2=reply */ u8 htype; /* HW address type */ u8 hlen; /* HW address length */ u8 hops; /* Used only by gateways */ u32 xid; /* Transaction ID */ u16 secs; /* Seconds since we started */ u16 flags; /* Just what it says */ u32 client_ip; /* Client's IP address if known */ u32 your_ip; /* Assigned IP address */ u32 server_ip; /* (Next, e.g. NFS) Server's IP address */ u32 relay_ip; /* IP address of BOOTP relay */ u8 hw_addr[16]; /* Client's HW address */ u8 serv_name[64]; /* Server host name */ u8 boot_file[128]; /* Name of boot file */ u8 exten[312]; /* DHCP options / BOOTP vendor extensions */};

Page 120: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 120

4.5 Error Reporting

Internet Control Message Protocol (ICMP)

Page 121: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 121

Error Control Protocol

What is error control protocol A protocol for reporting error or status of TCP/IP

at remote site (router or host) Why error control protocol

For monitoring the status of TCP/IP at each host/router

For reporting error between hosts or routers

Page 122: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 122

Internet Control Message Protocol (ICMP) ICMP runs over IP

ICMP Header ICMP Data

IP Header IP Data

Page 123: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 123

ICMPv4 Packet Format Type and Code are used to identify an error event The data filed contains

STD 5, RFC 792, “Internet Control Message Protocol” IP header plus the first 64 bits of the packet that elicited the ICMP message

STD 3, RFC 1122, “Requirements for Internet Hosts – Communication Layers” IP header and at least the first 8 data octets of the datagram that triggered the

error (more than 8 octets MAY be sent) RFC 1812, "Requirements for IP Version 4 Routers“

SHOULD contain as much of the original datagram as possible without the length of the ICMP datagram exceeding 576 bytes

16 0 8 24 31

Type Code Checksum

Data

Page 124: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 124

Type and CodeType Code Description

0 0 Echo reply (ping) 3 0 Destination network unreachable 3 1 Destination host unreachable 3 2 Destination protocol unreachable 3 3 Destination port unreachable 3 4 Fragmentation needed and DF set 3 5 Source route failed 3 6 Destination network unknown 3 7 Destination host unknown 4 0 Source quench (congestion control) 5 0 Redirect (destination network) 5 1 Redirect (host) 8 0 Echo request (ping) 9 0 Route advertisement

10 0 Router discovery 11 0 TTL expired 12 0 Bad IP header

Page 125: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 125

ICMPv4 Examples (1/6) Echo Request/Reply

Source sends an echo request (type=8) to a destination, destination responses with an echo reply (type=0) The data received by the Echo Request must be entirely included in the

Echo Reply. The Identifier and Sequence Number is used by the client to match the

reply with the request that caused the reply. ping uses echo request and reply

16 0 8 24 31

Type Code Checksum

Data

Identifier Sequence Number

Page 126: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 126

ICMPv4 Examples (2/6) Destination Unreachable (type=3)

destination unreachable is used to report various unreachable reasons, such as network, host, or port unreachable.

However, code 4 of type 3 message is used to report the error that fragmentation is needed at an intermediate router (due to MTU) but the do not fragment bit in the IP header is set.

16 0 8 24 31

Type=3 Code Checksum

IP header + first 8 bytes of original packet’s data

Empty Next-hop MTU

Page 127: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 127

ICMPv4 Examples (3/6) Source Quench

when buffer overflows, router sends a source quench (type=4) to source

Routing redirect If a host forwards a packet to a wrong router, router sends a

redirect (type=5, code=0 or 1, (network/ host)) ICMP message to source 16 0 8 24 31

Type Code Checksum

Data

Gateway (router) IP address

16 0 8 24 31

Type Code Checksum

Data

Unused

Page 128: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 128

ICMPv4 Examples (4/6)

Time Exceeded If TTL is less or equal to zero (after decrement), router sends

a Time Exceeded (type=11) ICMP message to source traceroute implementation

traceroute sends an ICMP echo request with TTL=1 to the target machine

When the first router receives the message, it responds with a time exceeded message

traceroute then sends another echo request with TTL=2 The message passes the first router, but discarded by the

second router with a returned time exceeded message Traceroute repeats sending echo requests until it receives

an echo reply from the target machine

Page 129: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 129

ICMPv4 Examples (5/6)

IP header error Wrong IP header, such as wrong option field. (type=12) Code=0: IP header is invalid Code=1: a required option is missing

Page 130: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 130

ICMPv4 Examples (6/6)

Time Stamp Request/Reply Type=13/14, code=0

Information Request/Reply Type=15/16, code=0

Address Mask Request/Reply Type=17/18, code=0

Page 131: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 131

ICMPv6

New type and code Type 0..127: error report

1: Destination unreachable 2: Packet too big 3: Time Exceeded 4: Parameter problem

Type 128..255: informational 128, 129: Echo request & reply (RFC 2463) 130, 131, 132: Multicast group membership management (RFC 2710) 133,134: Router solicitation and advertisement (RFC 2461) 135, 136: Neighbor solicitation and advertisement (RFC2461) 137: Redirect (RFC 2461) 138: Router renumbering (RFC 2894) 139, 140: node information query/response (draft, name-lookups) 141, 142: Inverse ND solicitation/ Adv message (RFC 3122) 150, 151: Home agent address discovery request/reply (draft) 152, 153: Mobile prefix solicitation/advertisement

Page 132: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 132

ICMPv6 Type Code Description

1 0 No route to destination

1 1 Communication with destination

administratively prohibited

1 3 Address unreachable

1 4 Port unreachable

2 0 Packet too big

3 0 Hop limit exceeded in transit

3 1 Fragment reassembly time exceeded

4 0 Erroneous header field encountered

4 1 Unrecognized Next Header type

4 2 Unrecognized IPv6 option encountered

128 0 Echo request

129 0 Echo reply

130 0 Multicast Listener Query

131 0 Multicast Listener Report

132 0 Multicast Listener Done

133 0 Router Solicitation

134 0 Router Advertisement

135 0 Neighbor Solicitation

136 0 Neighbor Advertisement

137 0 Redirect

Page 133: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 133

Open Source Implementation 4.8:ICMP Data structure

ICMP header: struct icmphdr

Error when forwarding IP packets ip_forward() icmp_send()

TTL<=1 Strict source routing Fail Route redirect

Error when receiving IP packets ip_route_input_slow() ip_error() icmp_send()

destination unreachable

Page 134: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 134

Open Source Implementation 4.8 (cont) Receiving ICMP packets

Control handlers: icmp_pointers[] icmp_unreach() for type 3, 4, 11, and 12 icmp_redirect() for type 5 icmp_echo() for type 8 icmp_timestamp() for type 13 icmp_address() for type 17 icmp_address_reply() for type 18 icmp_discard() for other types

icmp_rcv() icmp_pointers ICMPv6

icmpv6_send() icmpv6_rcv() icmpv6_echo_reply(), icmpv6_notify()

Page 135: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 135

Page 136: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 136

4.6 Routing

Principle Intra-domain routing Inter-domain routing

Page 137: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 137

Routing Principle

Link State Routing Distance Vector Routing

Page 138: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 138

Routing

Task of routing Select a path from the source to the destination

Goal of routing Efficient (low delay, high throughput, …) Scalable Stable Robust Fair

Page 139: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 139

Optimality of IP Routing

IP uses hop-by-hop routing(forwarding) Each router determines its own routing table Why packets will be delivered to their destinations

along the optimal path? If k is an intermediate node on the optimal path from

source node s to destination d The path from s to k is also the optimal path from s to k A shortest path tree can be constructed from a source to

the rest of the graph.

Page 140: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 140

Page 141: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 141

Routing Algorithm Classification

Global or decentralized information? Link State routing: use Dijkstra algorithm Distance Vector routing: use distributed

Bellman-Ford algorithm Static

Fixed routing table, set up manually Dynamic (adaptive)

Routing table adapts to network status

Page 142: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 142

The Shortest Path Algorithm

View a network as a graph Nodes are routers Edges are physical links

Associated with a link cost: delay, congestion level, …

Find the least cost path Depends on information available

Page 143: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 143

Link-State Routing

Routing information Global information is available by reliable

broadcasting Dynamic: information exchanged when topology

changes or periodically Path calculation

Dijkstra algorithm

Page 144: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 144

Dijkstra AlgorithmFor each v in V-{s} { If v is adjacent to s C(v)=lc(s,v) else C(v)=? } T = {s} While (T≠ V) { find w not in T s.t. C(w) is the minimum for all w in (V-T) T = T ∪{w} For each v in V-T C(v) = MIN(C(v), C(w)+lc(w,v)) P(v)=w) }

Page 145: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 145

Dijkstra Algorithm Example

A

D

E C

B

1

1

1 3

2

4

1

Iteration T C(B),p(B) C(C),p(C) C(D),p(D) C(E),p(E) 0 A 4,A 1,A ∞ ∞ 1 AC 3,C 4,C 2,C 2 ACE 3,C 3,E 3 ACEB 3,E 4 ACEBD

Page 146: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 146

Routing Table at Node A

Destination Cost NextHop B 3 C C 1 C D 3 C E 2 C

Page 147: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 147

Distance Vector Algorithm

Routing information Only local information is known

Knows status of adjacent links and routing information of adjacent nodes

Dynamic: information exchanged when link cost or shortest path changed

Path calculation Bellman-Ford

Page 148: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 148

Bellman-Ford AlgorithmWhile (1) { If x received route update message from y { For each (Dest, Distance) pair in y’s report { If (Dest is new) { /* Dest not in routing table */ Add a new entry for destination Dest rt(Dest).distance = Distance+lc(x,y) rt(Dest).NextHop = y } else if ((Distance+lc(x,y))<rt(Dest).distance){ /* y reports a shorter distance to Dest */ rt(Dest).distance = Distance+lc(x,y) rt(Dest).NextHop = y } } Send update messages to all neighbors if route changes Also send update messages to all neighbors periodically }

Page 149: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 149

Bellman-Ford Algorithm Example:Step 1

A

D

E C

B

1

1

1 3

2

4 1

Dt. C NH

B

C

4

1

B

C

Dt. C NH

A

B

1

2

A

B

1

3 D D

E E

Dt. C NH

C

D

1

1

C

D

Dt. C NH

B

C

1

3

B

C

1 E E

Dt. C NH

A

C

4

2

A

C

1 D D

Page 150: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 150

Bellman-Ford Algorithm Example:Step 2

A

D

E C

B

1

1

1 3

2

4 1

Dt. C NH

A

B

1

2

A

B

1

2 D E

E E

Dt. C NH

B

C

3

1

C

C

2

4 D C

E C

Dt. C NH

A

B

2

2

C

D

1

1 C C

D D

Dt. C NH

A

B

4

1

C

B

1

2 C E

E E

Dt. C NH

A

C

3

2

C

C

2

1 D D

E D

Page 151: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 151

Bellman-Ford Algorithm Example:Step 3

A

D

E C

B

1

1

1 3

2

4 1

Dt. C NH

A

B

1

2

A

B

1

2 D E

E E

Dt. C NH

B

C

3

1

C

C

2 3 D C

E C

Dt. C NH

A

B

2

2

C

D

1

1 C C

D D

Dt. C NH

A

B

3 1

E

B

1

2 C E

E E

Dt. C NH

A

C

3

2

C

C

2

1 D D

E D

Page 152: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 152

Bellman-Ford Algorithm Example Routing table of node A after convergence

Destination Cost NextHop B 3 C C 1 C D 3 C E 2 C

Page 153: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 153

Problem with DV Routing (1/2) Phenomenon

good news travels fast bad news travels slowly

A

D

E C

B

7

1

1 3

2

4

1

1

A

D

E C

B

1

1

1 3

2

50

1

Route updated in two iterations. Route updated in more than 25 iterations.

Page 154: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 154

Problem with DV Routing (2/2) Routing loop

Due to the above phenomenon Loop formed before routing converged

Partial solutions Split horizon

Routing updates sent to a neighbor should not contain route learned from that neighbor.

Poisoned reverse If A learns a route to D from B, then A tells B that he cannot reach D so to

poison the route. Hold down timer

When a router receives an update from a neighbor indicating a network is inaccessible, the router marks the route as inaccessible and starts a holddown timer

Holddown timers help prevent counting to infinity but also increase convergence time

Page 155: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 155

Hierarchical Routing

Not a flat network: too many routing entries Define an AS

Routers within an AS are under the same administrative control

Routing within an AS and between AS’s Intra-domain routing Inter-domain routing

Page 156: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 156

AS

The Internet consists of Autonomous Systems (AS) interconnected with each other: Stub AS: small corporation Multihomed AS: large corporation (no transit) Transit AS: provider

Two-level routing: Intra-AS: routing within an AS Inter-AS: routing between AS’s

Page 157: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 157

An example of Hierarchical Routing

Inter-domain routers (exterior gateway)

Intra-domain routers (interior gateway)

Domain B

Domain A Domain C

C.1

C.2

C.3 A.3

A.1

A.2

B.3

B.1 B.4

B.2

Page 158: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 158

Example of Internet Routing Protocols Intradomain routing

RIP OSPF

Interdomain routing BGP-4

Page 159: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 159

Intra-domain Routing

Routing Information Protocol (RIP) Open Shortest Path First (OSPF)

Page 160: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 160

Intra-domain Routing

What is intra-domain routing Routing within a domain (AS) Administrator decides the routing protocol Administrator has total control on all routers

Why intra-domain routing Maintain connectivity within a domain

Page 161: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 161

Intra-domain Routing

Runs Interior Gateway Protocols (IGP) Most Common IGP’s

RIP: Routing Information Protocol OSPF: Open Shortest Path First

Page 162: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 162

RIP

Originally designed for Xerox PARC Universal Protocol (used in XNS)

Adopted by UNIX and TCP/IP in 1982 routed of BSD

RIP: RFC 1058 [1988] RIPv2: RFC 1388 [1993] RIPng: RFC 2080 [1997]

Page 163: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 163

RIP

Distance Vector routing Use hop count as cost metric (up to 15) Restrict size of the network to 15 Exchange routing message (advertisement)

every 30 seconds Each advertisement consists of up to 25 routes

(destination nets)

Page 164: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 164

RIPv2 Packet Format 16 0 8 24 31

Command

Family of net 1

Subnet Mask for net 1

Version Must be zero

Address of net 1

Route Tag for net 1

Next Hop for net 1

Distance to net 1

Subnet Mask for net 2

Address of net 2

Next Hop for net 2

Distance to net 2

Family of net 2 Route Tag for net 2

Page 165: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 165

RIP Packet Format and Stability RIP packet format

commands: request or reply, version number up to 25 destination addresses

Stability hop count limit: 15 means infinity Stabilization Timer:

allows RIP to learn all routes from its neighbors before sending full updates

Split horizons no update on backward route (omits routes learned from that

neighbor) Poison Reverse Update

sends updates to a neighbor includes routes learned from that neighbor but sets the route metric to infinity

Page 166: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 166

Routing Table of RIP

Taken from a cisco router at cs.ccu.edu.twDestination Gateway Distance

/Hop Update timer

Flag Interface

35.0.0.0/8 140.123.1.250 120/1 00:00:28 R Vlan1 127.0.0.0/8 directly connected C Vlan0 136.142.0.0/16 140.123.1.250 120/1 00:00:17 R Vlan1 150.144.0.0/16 140.123.1.250 120/1 00:00:08 R Vlan1 140.123.230.0/24 directly connected C Vlan230 140.123.240.0/24 140.123.1.250 120/4 00:00:22 R Vlan1 140.123.241.0/24 140.123.1.250 120/3 00:00:22 R Vlan1 140.123.242.0/24 140.123.1.250 120/1 00:00:22 R Vlan1 192.152.102.0/24 140.123.1.250 120/1 00:01:04 R Vlan1 0.0.0.0/0 140.123.1.250 120/3 00:00:08 R Vlan1

Page 167: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 167

Open Source Implementation 4.9: RIP GNU Zebra Project

Supports many routing protocols RIP, OSPF, BGP

Runs routing daemon as user process Communicates with kernel via netlink

Page 168: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 168

Open Source Implementation 4.9 (cont)Routing Daemon and Kernel

Packets from NICs

Data packets

KernelRouting TableControlpackets

Routing manager(Zebra, routed, gated, …)

Handling protocol specific packetsUser space

Kernel space

Page 169: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 169

Open Source Implementation 4.9 (cont) Overview of Zebra Routing Protocols

KernelRouting Table

ioctl sysctl proc fs rtnetlinknetlink

Zebra Daemon

RIPd OSPFd BGPd RIPngd

Rou

ting

Info

rmatio

n(v

ia so

cket in

terfa

ce)

Page 170: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 170

Page 171: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 171

Open Source Implementation 4.9 (cont) RIP Daemon (ripd)

Interfacerip_networkrip_neighbor

rip_passive_interfaceip_rip_version

ip_rip_authenticationrip_split_horizon

InitializationScheduling

routemap offset

RIP Peerrip_peer_timeoutrip_peer_updaterip_peer_display

Zebraclient

RIP corerip_version

rip_default_metricrip_timersrip_route

rip_distance

Zebra Daemon

Page 172: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

RFCs Supported by Zebra

Daemons RFC# Function

ripd 2453 Manages RIPv1, v2 protocol

ripngd 2080 Manages RIPng protocol

ospfd 2328 Manages OSPFv2 protocol

ospf6d 2740 Manages OSPFv3 protocol

bgpd 1771 Manages BGP-4 and BGP-4+ protocol

Chapter 4: Internet Protocol Layer 172

Page 173: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 173

OSPF Features (1/3)

OSPF v2: RFC 2328 [1998] OSPF v3: RFC 2740 [1999] Run internal to a single Autonomous System Link-state routing protocol Shortest-path tree be constructed for routing table

Dijkstra algorithm Support for equal-cost multipath routing Support for TOS-based routing Support variable subnet length

each route distributed has a destination and mask

Page 174: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 174

OSPF Features (2/3)

Integrated uni- and multicast support: Multicast OSPF (MOSPF) uses same topology

database as OSPF Two levels of hierarchy : areas within an AS

Area: a group of contiguous networks and hosts Topology of an area is invisible form outside

Routing in the AS takes place on two level intra-area routing, inter-area routing

Page 175: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 175

OSPF : Two Levels of Hierarchy

AS boundary router

Area B Area A Area C

Area border router

backbone router Area border

router

internal router internal

router internal router

Backbone

Page 176: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 176

OSPF Hierarchy

Area border routers “summarize” distances to networks of its area advertise to other Area Border routers

Area internal routers Only participate intra-area routing Receive external routes broadcasted by area border router

Backbone routers run OSPF routing limited to backbone

AS Boundary routers connect to other AS’s

Page 177: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 177

OSPF Features (3/3)

External routing data is advertised through AS Flood without modification Two types of cost

type 1: compatible with costs within area, cost to an external network is the sum of internal cost and external cost

type 2: order of magnitude larger, cost to an external network is solely determined by external cost

Page 178: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 178

OSPF

Features Supports stub to reduce broadcasting

An area can be figured as stub when there is a single exit point from the area.

AS boundary routers cannot be placed internal to stub areas.

No AS external advertisements are flood into /through stub areas.

Page 179: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 179

N1

N2

N3

N4

N8N6

N7

N11

N9

N10

N12

N15

N12N13

N14

Internal router

Area border router

H1

RT1

RT2

RT4

RT3

RT5

RT6

RT10

RT11

RT9

RT12

RT7

RT8

3

3

1

1

1

1

1

1

1 1

1

4

2

2

2

2

8

8

8

66

7 6

6

88

8

9

1

10

3

7

5

Ia

Ib

Area 1

Area 2

Area 3

Stub

AS boundary router

Page 180: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 180

OSPF Example: Intra-area Summarized area information advertised by

RT3 and RT4 to backbone.Network Cost advertised by RT3 Cost advertised by RT4

N1 4 4

N2 4 4

N3 1 1

N4 2 3

N1

N2

N3

N4

RT1

RT2

RT4

RT3

3

3

1

1

1

1

2

Area 1

Page 181: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Intra-Area Routing Table for RT1Network Cost Next Hop

N1 3 Direct

N2 4 RT2

N3 1 Direct

N4 3 RT3

Chapter 4: Internet Protocol Layer 181

Page 182: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 182

OSPF Example: Inter-area Backbone information advertised into area

1 by RT3 and RT4.Destination Cost

advertised by RT3

Cost advertised

by RT4 Ia, Ib 20 27 N6 16 15 N7 20 19

N8 18 18 N9-N11 29 36

RT5 14 8 RT7 20 14

N12

N15

N12N13

N14

RT4

RT3

RT5

RT6

RT10RT7 2

8

8

8

66

7 6

6

88

8

9

7

5

Ia

Ib

N61

1

Page 183: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 183

OSPF Example: Final Routing Table RT4’s routing table

Destination Path Type Cost Next Hop

N1 intra-area 4 RT1 N2 intra-area 4 RT2 N3 intra-area 1 direct

N4 intra-area 3 RT3 N6 Inter-area 15 RT5

N7 inter-area 19 RT5 N8 Inter-area 18 RT5

N9-N11 inter-area 36 RT5 N12 Type 1 external 16 RT5

N13 Type 1 external 16 RT5 N14 Type 1 external 16 RT5

N15 Type 1 external 23 RT5

Page 184: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 184

Page 185: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Five Types of OSPF messages

Types Description

1 Hello

2 Database Description

3 Link State Request

4 Link State Update

5 Link State Acknowledgement

Chapter 4: Internet Protocol Layer 185

Page 186: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 186

Page 187: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Five types of LSAs

Chapter 4: Internet Protocol Layer 187

LS TypeLS Name Originated by Scope of

FloodDescription

1

Router LSAs All routers Area Describes the collected states of the router’s interfaces to an area

2Network LSAs Designated router Area Contains the list of

routers connected to the network

3Summary LSAs (IP network)

Area border router Associated areas

Describes routers to inter-area networks

4Summary LSAs (ASBR)

Area border router Associated areas

Describes routers to AS boundary routers

5AS-external LSAs AS boundary router AS Describes routers to

other ASs

Page 188: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 188

Open Source Implementation 4.10: OSPF

Interface

InitializationScheduling

RouteOSPF coreip_ospf_interfaceip_ospf_neighbor

ospf_router_idnetwork_area

show_ip_ospf_cmd

OSPF SPF calcuation

zclient

Zebradaemon

Network

LSDBOSPF FloodingRoute Map

route_map_updateroute_map_event

LSALink State

Advertisement

ASEAS external

route calculation

Page 189: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 189

Page 190: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 190

Inter-domain Routing

Border Gateway Protocol (BGP)

Page 191: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 191

Inter-domain Routing

Called Exterior Gateway Protocols (EGP) Most common EGP

BGP: Border Gateway Protocol

Page 192: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 192

BGP Features (1/3) RFC 1771 (BGP-4) “Path vector” routing

loop free inter-domain routing between ASs Runs over TCP with port 179 Routing table keeps all feasible paths

Only advertises optimal path to neighbors

Page 193: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 193

BGP Features (2/3)

Can be used within and between ASs multiple border routers (BGP speaker) within an

AS IBGP: Interior BGP

runs between routers in the same AS All BGP speakers within the AS must be fully meshed

(through IGP protocol) EBGP: Exterior BGP

runs between routers belonging to two different ASs

Page 194: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 194

BGP Features (3/3) Support information aggregation

CIDR Confederation

could also be used to allow multiple ASs within an AS

Policy routing at AS access-list permit or deny (route or path filtering)

Link cost metric combination of different metric with the degree of

preference (weight, loc pref, med, …)

Page 195: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 195

BGP Messages Open

First message sent after connection Keepalive

Send often enough to keep from timer expiration Update

No periodic refresh of the entire table Advertise a single feasible route to a peer Withdraw multiple routes previously advertised Message contains path attributes and Network Layer

Reachability Information (NLRI) Notification

send when an error is detected

Page 196: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 196

Page 197: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 197

BGP Routing Algorithm Path vector routing

Different ASs may have different link cost metrics Loop free is very important Policy routing is preferred (different priorities, prohibit lists, …) AS_PATH of the path attribute

A list of ASs to the destination Loop is found if current AS already in the AS_PATH

Next_Hop of the path attribute indicates the next router to the destination

NLRI A list of subnets that can be reached by the AS_PATH

Page 198: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 198

BGP Path Selection Path selection

(1) If Next_Hop is inaccessible, drop the update

(2) Prefer largest LOCAL_PREF

(3) Prefer shorter AS_PATH

(4) Prefer lower origin code (igp<egp<incomplete)

(5) Prefer lower MED (MULTI_EXIT_DISC)

(6) Prefer external path over internal path

(7) Prefer closer IGP neighbor

(8) Prefer BGP router with lower ip address

Advertise the highest degree of preference for each destination to neighbor BGP speakers

Page 199: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 199

BGP PATH Attributes (1/2) Origin

Defines the origin of the path information IGP, BGP, Incomplete (unknown, e.g., static route)

AS_PATH Ordered list or a set

Next_Hop IP of the next hop to the destination For multiaccess network, nexthop could be a router

other than the BGP speaker

Page 200: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 200

BGP PATH Attributes (2/2)

LOCAL_PREF Indicate preferred exit router within an AS

Multi_Exit_Disc(MED) When a router has multiple external links to the same

AS, the link to the router with lower MED is preferred.

Page 201: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 201

BGP Example

Network Next Hop LOCAL_

PREF Weight Best? PATH Origin

139.175.56.165 0 N 4780,9739 IGP 140.123.231.103 0 N 9918,4780,9739 IGP 61.13.0.0/16 140.123.231.100 0 0 Y 9739 IGP 139.175.56.165 0 Y 4780,9277,17577 IGP

61.251.128.0/20 140.123.231.103 0 N 9918,4780,9277,17577 IGP

211.73.128.0/19 210.241.222.62 0 Y 9674 IGP 139.175.56.165 0 N 4780,9919 IGP 140.123.231.103 0 N 9918,4780,9919 IGP 218.32.0.0/17 140.123.231.106 0 Y 9919 IGP 139.175.56.165 0 N 4780,9919 IGP 140.123.231.103 0 N 9918,4780,9919 IGP 218.32.128.0/17 140.123.231.106 0 Y 9919 IGP

Page 202: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 202

Page 203: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 203

4.7 Multicast

Internet Group Management Protocol (IGMP) Distance Vector Multicast Routing Protocol (DVMRP) Protocol-Independent Multicast (PIM) New Developments: SSM, MSDP, Anycast RP Multicast Backbone (MBONE)

Page 204: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 204

Multicast

Communication among more than two parties Multi-party video conferencing Distance learning

Issues Maintain group member information Construct a multicast tree for packet transmission Many to many communication

Page 205: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 205

Membership Management

IGMP

Page 206: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 206

Internet Group Management Protocol ( IGMPv2) RFC 2236 Used by IP hosts to report multicast group

memberships to routers

Enhances IGMPv1 Querier election mechanism

IGMPv2 Leave Group message

Group-Specific Query message

Page 207: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 207

Protocol Overview (1/4)

Multicast router plays one of the two roles: Querier or Non-Querier Querier is responsible for maintain membership

information Router with the smallest IP address becomes the

Querier Routers hear the Query messages and make the

judge Querier periodically sends General Query to solicit

membership information A General Query is sent to 224.0.0.1 (ALL-

SYSTEMS multicast group)

Page 208: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 208

Protocol Overview (2/4)

When a host receives a General Query Delays a random time from the range of

[0..Max Response Time](starts a timer) Max Resp. Time is given in the Query message

Sends a report with TTL=1 when timer expires Report suppression

If another host’s report received, stop the timer and does not send the report

Similar for a host receives a Group-Specific Query

Page 209: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 209

Protocol Overview (3/4)

When a router receives a report adds the group being reported to the list of

multicast groups Sets timer for the membership to [Group

Membership Interval]. Deletes it if no reports received before timer expired Query is sent periodically

When a host joins a multicast group Sends an unsolicited report immediately

Page 210: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 210

Protocol Overview (4/4)

When a host leaves a multicast group If it was the last host to reply to a Query, it

should send a Leave Group message to all-routers multicast address (224.0.0.2)

When a router receives a Leave Group message Sends Group-specific Queries every [Last

Member Query Interval] to the group being left for [Last Member Query Count] times.

If no reports received before [Last Member Query Interval], assumes no local members.

Page 211: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 211

IGMPv2 Message Format (1/2) message format

type0x11=Membership Query - General query - Group-Specific Query0x16=Version 2 Membership Report0x17=Leave Group

16 0 8 24 31

Type Max. Resp. Time

Checksum

Multicast group Address

Page 212: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 212

IGMPv2 Message Format (2/2) Max Response Time

- only in membership query message- set to be zero in other messages

Checksum- 16-bit one’s complement

Group address- zero when sending a General Query- group address when sending a Group-Specific query

Page 213: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 213

IGMPv3

IETF RFC 3376 Adds support for “source filtering”

A receiver may request to receive packets only from specific source addresses

Select source addresses by INCLUDE or EXCLUDE IPMulticastListen(socket, interface, multicast-address,

filter-mode, source-list) filter-mode: INCLUDE or EXCLUDE

Page 214: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 214

Multicast Routing Protocols

DVMRP PIM-SM SSM MSDP Anycast RP

Page 215: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 215

Multicast Routing Protocols

Two types of multicast tree source-based tree core-based tree (shared tree)

Multicast protocols DVMRP PIM

Sparse mode Dense mode

SSM MSDP Anycast RP MBGP

What’s the difference:

per (S,G) tree or

per (*,G) tree

Page 216: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Example where Steiner tree is different from least-cost-path tree

Copyright reserved 2001 (Lin & Hwang) 216

A

C

D

B

3

4 3

3 1

1

216Chapter 4: Internet Protocol Layer

Page 217: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 217

Distance Vector Multicast Routing Protocol (DVMRP) RFC-1054 Derived from RIP

Relies on RIP for unicast routing Widely used on the Mbone

Enable incremental deployment of IP multicast since it supports tunnel

Construct a source-based tree per source Provide a shortest path between source and

receivers using Reverse Path Forwarding (RPF) algorithm

Page 218: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 218

RPF Algorithm

Three steps Reverse Path Broadcast (RPB) Prune to a Reverse Path Multicast (RPM) tree Forwarding data uni-directionally

Page 219: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 219

Reverse Path Broadcast (RPB) Broadcast on the Reserve Path

When a multicast packet is received Forward the packet on all of its outgoing links only if

Packet arrives on the interface that is also the interface of the shortest path back to the sender

Packet is not duplicated Otherwise, discard the packet

Page 220: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 220

RPB Example

member mrouter router w/o member

source Forward

Discard

RA

RB

RC

RD

RE

RF

RG

Page 221: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 221

Prune RPB Tree

Prune to RPM tree Routers that do not lead to any members send

prune messages to upstream routers Routers know membership information via

IGMP

Page 222: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 222

Prune RPB Tree Example

member mrouter router w/o member

source Forward

Prune

RB

RC

RD

RE

RG

RA

RF

Page 223: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 223

Example of a RPM tree

member router w/ member

router w/o member

source Forward

Page 224: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 224

DVMRP Drawbacks and Benefits Drawbacks

First packet has to be flooded Periodic prune state refresh Routing state per (source , group) pair

Benefits guarantee efficient delivery easy to implement

Page 225: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 225

Problems of DVMRP

Work well only for densely represented groups periodic broadcast will cause performance

problems Large amount of state information stored

Information for forwarding Prune-state information

Not scaleable

Page 226: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 226

PIM-SM

Protocol Overview Special Features Packet Formats

Page 227: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 227

Protocol Overview Documents

RFC 2362, 4601(August, 2006) Terminologies

DR: Designated Router RP: Rendezvous Point RPT: RP-based Tree

PIM-SM route packets in three phases Phase one: RP tree Phase two: Register Stop Phase three: Shortest-Path Tree (Optional)

Page 228: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 228

Phase One: RP Tree Receiver

Sends join message to DR using IGMP DR sends (*,G) PIM Join message to RP

Reaches RP or converge on a router on the RPT Join message is sent periodically (o.w., it will time

out)

Sender Sender sends a packet with multicast address

as its destination to DR DR unicasts encapsulated packet to RP

PIM Register packets RP decapsulates it and forwards it onto RPT

Page 229: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 229

Phase One: RP Tree (Fig)

member

RP DR

source

Join

Encapsulated

Multicast Send RP

A B

(*,G) (*,G) RTA

Page 230: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 230

Phase Two: Register Stop Motivation

Encapsulation and decapsulation are too expensive Steps

RP initiates an (S,G) source-specific Join to S All the routers on the path records the (S,G) multicast state Packets start to flow following the (S,G) tree to RP RP may now receive duplicate packets: native and

encapsulated. RP discards the encapsulated packet RP sends a Register-Stop message to DR of Source RP forwards native packets to the RPT If the packet reaches a router with (*,G), do a short-cut to

receivers.

Page 231: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 231

Phase Two: Register Stop (Fig)

member

RP DR

source

Source specific join

RP

(S,G)

Page 232: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 232

Phase Three: Shortest-Path Tree Motivation

From source to RP, then to receivers is too long. Steps

A receiver’s DR may optionally initiate to transfer from the RPT to a source-specific tree (SPT)

It issues an (S,G) join to S. The join message may reach the source or converged at some router.

It starts to receive two copies of packets. Drop the one from RPT.

It then sends an (S,G) prune message to RP (S, G, rpt) prune Prune message reaches RP or converged at some

router on RPT

Page 233: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 233

Phase Three: Shortest-Path Tree (Fig)

member

RP DR

source

Source specific join (IGMPv3)

RP

(S,G)

(S,G,rpt)

Source specific prune

Page 234: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 234

Source-specific Joins and Prunes If a receiver sends a source-specific join using

IGMPv3 If no other receiver on that group, DR may omit performing

a (*,G) join. Instead, DR issues a source-specific (S,G) join.

Multicast addresses for source-specific multicast 232.0.0.0 to 232.255.255.255 Only source-specific join will be accepted for group in this

range. A receiver may also sends a source-specific join

with exclusive source list DR will perform a (*,G) join as normal, but may combine

this with an (S,G,rpt) prune for each source in the list.

Page 235: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 235

Page 236: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 236

Page 237: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 237

Inter-domain Multicast: MSDP RP in each domain establishes an MSDP peering relation with

RPs in other domains When the RP learns a new multicast source within its own

domain, it informs its MSDP peers The RP encapsulates the first data packet in a Source Active

(SA) message and sends the SA to all peers. The SA is forwarded by each receiving peer using a modified

RPF check If the receiving MSDP peer is an RP, and the RP has a (*,G)

entry for the group in the SA, the RP sends a (S,G) join. The RP also decapsulates the data and forwards down to its shared tree

The receiver that interests in this (S,G) could sends a (S,G) join to have the shortest path to the source

Each RP periodically sends SAs, which include all sources within its domain.

Page 238: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 238

Inter-domain Multicast: Multi-Protocol BGP (MBGP) Defined in RFC 2283 (extensions to BGP) MBGP is extended to carry different

information to support IPv4 Unicast IPv6 Unicast IPv4 Multicast IPv6 Multicast ….

Routing information may be carried in same BGP session

Page 239: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Open Source Implementation 4.12: MroutedData structures of Mrouted

Copyright reserved 2001 (Lin & Hwang) 239

routing_table

rtentry

rt_next

rt_groups

rt_next

rt_groups

gt_next

gt_gprev

gtable

gt_gnext

gt_prev gt_next

gt_gprev

gtable

gt_gnext

gt_prev

gt_next

gt_gprev

gtable

gt_gnext

gt_prev

Groups orginiated from the

same source.

239Chapter 4: Internet Protocol Layer

Page 240: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 240

Page 241: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

Chapter 4: Internet Protocol Layer 241

Summary on Multicast

Source-based tree Advantage

Optimal path between sources and receivers Disadvantage

Routing information for each (S,G) pair

Shared tree Advantage

Less state in each router Disadvantage

Non-optimal path between sources and receivers

Page 242: Chapter 4: Internet Protocol Layer 1 Computer Networks An Open Source Approach Chapter 4: Internet Protocol Layer.

4.8 Summary

Forwarding: longest prefix matching Routing: two-level, intra-domain and inter-

domain Distance vector routing vs. link state routing:

distributed vs. centralized Other mechanisms: IPv6, NAT, ARP, DHCP,

ICMP Broadcast in subnet: used by ARP and

DHCP

Chapter 4: Internet Protocol Layer 242