75
CSCI 3335: COMPUTER NETWORKS CHAPTER 4 NETWORK LAYER Vamsi Paruchuri University of Central Arkansas http://faculty.uca.edu/vparuchuri/3335.htm Some of the material is adapted from J.F Kurose and K.W. Ro

CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas Some

Embed Size (px)

Citation preview

Page 1: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

CSCI 3335: COMPUTER NETWORKS

CHAPTER 4 NETWORK LAYER

Vamsi ParuchuriUniversity of Central Arkansas

http://faculty.uca.edu/vparuchuri/3335.htm

Some of the material is adapted from J.F Kurose and K.W. Ross

Page 2: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-2

Chapter 4: Network Layer

Chapter goals: understand principles behind network

layer services: network layer service models forwarding versus routing how a router works routing (path selection) broadcast, multicast

instantiation, implementation in the Internet

Page 3: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-3

Chapter 4: Network Layer

4. 1 Introduction4.2 Virtual circuit and datagram networks4.3 What’s inside a router4.4 IP: Internet Protocol

Datagram format IPv4 addressing ICMP IPv6

4.5 Routing algorithms Link state Distance Vector Hierarchical routing

4.6 Routing in the Internet RIP OSPF BGP

4.7 Broadcast and multicast routing

Page 4: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-4

Network layer transport segment

from sending to receiving host

on sending side encapsulates segments into datagrams

on rcving side, delivers segments to transport layer

network layer protocols in every host, router

router examines header fields in all IP datagrams passing through it

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

networkdata linkphysical network

data linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysicalnetwork

data linkphysical

Page 5: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-5

Two Key Network-Layer Functions

forwarding: move packets from router’s input to appropriate router output

routing: determine route taken by packets from source to dest.

routing algorithms

analogy:

routing: process of planning trip from source to dest

forwarding: process of getting through single interchange

Page 6: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-6

1

23

0111

value in arrivingpacket’s header

routing algorithm

local forwarding tableheader value output link

0100010101111001

3221

Interplay between routing and forwarding

Page 7: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-7

Connection setup

3rd important function in some network architectures: ATM, frame relay, X.25

before datagrams flow, two end hosts and intervening routers establish virtual connection routers get involved

network vs transport layer connection service: network: between two hosts transport: between two processes (end-to-end)

Page 8: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-8

Chapter 4: Network Layer

4. 1 Introduction4.2 Virtual circuit (VC) and datagram networks4.3 What’s inside a router4.4 IP: Internet Protocol

Datagram format IPv4 addressing ICMP IPv6

4.5 Routing algorithms Link state Distance Vector Hierarchical routing

4.6 Routing in the Internet RIP OSPF BGP

4.7 Broadcast and multicast routing

Page 9: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-9

Network layer connection and connection-less service

datagram network provides network-layer connectionless service

VC network provides network-layer connection service

Page 10: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-10

Datagram Forwarding table

1

23

IP destination address in arriving packet’s header

routing algorithm

local forwarding tabledest address output

linkaddress-range 1address-range 2address-range 3address-range 4

3221

4 billion IP addresses, so rather than list individual destination addresslist range of addresses(aggregate table entries)

Page 11: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-11

Datagram Forwarding table

Destination Address Range

11001000 00010111 00010000 00000000through 11001000 00010111 00010111 11111111

11001000 00010111 00011000 00000000through11001000 00010111 00011000 11111111

11001000 00010111 00011001 00000000through11001000 00010111 00011111 11111111

otherwise

Link Interface

0

1

2

3

Q: but what happens if ranges don’t divide up so nicely?

Page 12: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-12

Longest prefix matching

Destination Address (DA) Range

11001000 00010111 00010*** *********

11001000 00010111 00011000 *********

11001000 00010111 00011*** *********

otherwise

DA: 11001000 00010111 00011000 10101010

Examples:

DA: 11001000 00010111 00010110 10100001

Which interface?

Which interface?

when looking for forwarding table entry for given destination address, use longest address prefix that matches destination address.

Longest prefix matching

Link interface

0

1

2

3

Page 13: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-13

Chapter 4: Network Layer

4. 1 Introduction 4.2 Virtual circuit and datagram networks 4.3 What’s inside a router 4.4 IP: Internet Protocol

Datagram format IPv4 addressing ICMP IPv6

4.5 Routing algorithms Link state Distance Vector Hierarchical routing

4.6 Routing in the Internet RIP OSPF BGP

4.7 Broadcast and multicast routing

Page 14: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-14

The Internet Network layer

forwardingtable

Host, router network layer functions:

Routing protocols• path selection• RIP, OSPF, BGP

IP protocol• addressing conventions• datagram format• packet handling conventions

ICMP protocol• error reporting• router

“signaling”

Transport layer: TCP, UDP

Link layer

physical layer

Networklayer

Page 15: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-15

Chapter 4: Network Layer

4. 1 Introduction4.2 Virtual circuit and datagram networks4.3 What’s inside a router4.4 IP: Internet Protocol

Datagram format IPv4 addressing ICMP IPv6

4.5 Routing algorithms Link state Distance Vector Hierarchical routing

4.6 Routing in the Internet RIP OSPF BGP

4.7 Broadcast and multicast routing

Page 16: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-16

IP datagram format

ver length

32 bits

data (variable length,typically a TCP

or UDP segment)

16-bit identifier

header checksum

time tolive

32 bit source IP address

IP protocol versionnumber

header length (bytes)

max numberremaining hops

(decremented at each router)

forfragmentation/reassembly

total datagramlength (bytes)

upper layer protocolto deliver payload to

head.len

type ofservice

“type” of data flgsfragment

offsetupper layer

32 bit destination IP address

Options (if any) E.g. timestamp,record routetaken, specifylist of routers to visit.

how much overhead with TCP?

20 bytes of TCP 20 bytes of IP = 40 bytes +

app layer overhead

Page 17: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-17

IP Fragmentation & Reassembly network links have MTU

(max.transfer size) - largest possible link-level frame. different link types,

different MTUs large IP datagram

divided (“fragmented”) within net one datagram

becomes several datagrams

“reassembled” only at final destination

IP header bits used to identify, order related fragments

fragmentation: in: one large datagramout: 3 smaller datagrams

reassembly

Page 18: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

IP Header: Fragmentation

Fields to manage fragmentation Identification (16 bits)

• “Unique ID” for datagram• Original spec said transport layer would set

Flags ( 3 bits)• 1 bit used to say whether there are more fragments

following this one in the original datagram• 1 bit used to say “do not fragment” (drop and send

error message back to source if need to fragment) Fragment Offset (13 bits)

• Give offset of data in this fragment into original datagram

Network Layer 4a-18

Page 19: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-19

IP Fragmentation and Reassembly

ID=x

offset=0

fragflag=0

length=4000

ID=x

offset=0

fragflag=1

length=1500

ID=x

offset=185

fragflag=1

length=1500

ID=x

offset=370

fragflag=0

length=1040

One large datagram becomesseveral smaller datagrams

Example 4000 byte

datagram MTU = 1500

bytes

1480 bytes in data field

offset =1480/8

How would you differentiate a “last fragment” from an unfragmented packet?

Page 20: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Another Example

H1 R1 R2 R3 H8

ETH FDDI

PPP IP (376)

PPP IP (512)

PPP IP (512) (512)

ETH IP

ETH IP

(512)ETH IP

(376)

IP (1400) IP (1400)

R1 R2 R3 (a)

Ident = x

Start of header

Rest of header

1400 data bytes

Offset = 00

(b)

Ident = x

Start of header

Rest of header

512 data bytes

Offset = 01

Ident = x

Rest of header

512 data bytes

Offset = 641

Start of header

Ident = x

Start of header

Rest of header

376 data bytes

Offset = 1280

unfragmented packet

fragmented packets

“M (more)” bit in the IP “Flag” field

ID of the original/unfragmented packet

* 8 bytes

Page 21: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Revision - 1 What is the difference between Routing and

Forwarding

Why are ranges of IP addresses stored in forwarding

table instead of individual IP addresses.

What is longest prefix matching?

What are the key services provided by network

layer?

What is the significance of each field in the IP

header.

What is the size of IP header.Network Layer 4-21

Page 22: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-22

Chapter 4: Network Layer

4. 1 Introduction4.2 Virtual circuit and datagram networks4.3 What’s inside a router4.4 IP: Internet Protocol

Datagram format IPv4 addressing ICMP IPv6

4.5 Routing algorithms Link state Distance Vector Hierarchical routing

4.6 Routing in the Internet RIP OSPF BGP

4.7 Broadcast and multicast routing

Page 23: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-23

IP Addressing: introduction IP address: 32-bit

identifier for host, router interface

interface: connection between host/router and physical link router’s typically

have multiple interfaces

host typically has one interface

IP addresses associated with each interface

223.1.1.1

223.1.1.2

223.1.1.3

223.1.1.4 223.1.2.9

223.1.2.2

223.1.2.1

223.1.3.2223.1.3.1

223.1.3.27

223.1.1.1 = 11011111 00000001 00000001 00000001

223 1 11

Page 24: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-24

Subnets IP address:

subnet part (high order bits)

host part (low order bits)

What’s a subnet ? device interfaces

with same subnet part of IP address

can physically reach each other without intervening router

223.1.1.1

223.1.1.2

223.1.1.3

223.1.1.4 223.1.2.9

223.1.2.2

223.1.2.1

223.1.3.2223.1.3.1

223.1.3.27

network consisting of 3 subnets

subnet

Page 25: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

IP Addresses (Classes)

4: Network Layer 4a-25

0network host

10 network host

110 network host

1110 multicast address

A

B

C

D

class1.0.0.0 to127.255.255.255

128.0.0.0 to191.255.255.255

192.0.0.0 to223.255.255.255

224.0.0.0 to239.255.255.255

32 bits

“class-full” addressing

Unicast

Multicast

1111 reservedE 240.0.0.0 to255.255.255.255Reserved

ClassLeadin

gbits

Size of networ

k bit field

Size of rest

bit field

Class A     0     8     24

Class B     10     16     16

Class C     110     24     8

Page 26: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Hosts per Class

Class A has ~224 hosts (16777216) Class B has ~216 hosts (65536) Class C has ~28 hosts (256)

Class-full addressing: inefficient use of address space, address space

exhaustion e.g., class B net allocated enough addresses for 65K

hosts, even if only 2K hosts in that network

4: Network Layer 4a-26

Page 27: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-27

IP addressing: CIDR

CIDR: Classless InterDomain Routing subnet portion of address of arbitrary length address format: a.b.c.d/x, where x is # bits in

subnet portion of address

11001000 00010111 00010000 00000000

subnetpart

hostpart

200.23.16.0/23

Page 28: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-28

IP addresses: how to get one?

Q: How does a host get IP address?

hard-coded by system admin in a file Windows: control-panel->network-

>configuration ->tcp/ip->properties UNIX: /etc/rc.config

DHCP: Dynamic Host Configuration Protocol: dynamically get address from as server “plug-and-play”

Page 29: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-29

DHCP: Dynamic Host Configuration Protocol

Goal: allow host to dynamically obtain its IP address from network server when it joins networkCan renew its lease on address in useAllows reuse of addresses (only hold address while connected

an “on”)Support for mobile users who want to join network (more

shortly)

DHCP overview: host broadcasts “DHCP discover” msg [optional] DHCP server responds with “DHCP offer” msg

[optional] host requests IP address: “DHCP request” msg DHCP server sends address: “DHCP ack” msg

Page 30: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-30

DHCP client-server scenario

223.1.1.1

223.1.1.2

223.1.1.3

223.1.1.4 223.1.2.9

223.1.2.2

223.1.2.1

223.1.3.2223.1.3.1

223.1.3.27

A

BE

DHCP server

arriving DHCP client needsaddress in thisnetwork

Page 31: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-31

DHCP: more than IP address

DHCP can return more than just allocated IP address on subnet: address of first-hop router for client name and IP address of DNS sever network mask (indicating network versus

host portion of address)

Page 32: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-32

DHCP: example

connecting laptop needs its IP address, addr of first-hop router, addr of DNS server: use DHCP

router(runs DHCP)

DHCPUDP

IPEthPhy

DHCP

DHCP

DHCP

DHCP

DHCP

DHCPUDP

IPEthPhy

DHCP

DHCP

DHCP

DHCPDHCP

DHCP request encapsulated in UDP, encapsulated in IP, encapsulated in 802.1 Ethernet Ethernet frame broadcast (dest: FFFFFFFFFFFF) on LAN, received at router running DHCP server

Ethernet demuxed to IP demuxed, UDP demuxed to DHCP

168.1.1.1

Page 33: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-33

DHCP server formulates DHCP ACK containing client’s IP address, IP address of first-hop router for client, name & IP address of DNS server

router(runs DHCP)

DHCPUDP

IPEthPhy

DHCP

DHCP

DHCP

DHCP

DHCPUDP

IPEthPhy

DHCP

DHCP

DHCP

DHCP

DHCP

encapsulation of DHCP server, frame forwarded to client, demuxing up to DHCP at client

client now knows its IP address, name and IP address of DNS server, IP address of its first-hop router

DHCP: example

Page 34: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-34

IP addresses: how to get one?

Q: How does network get subnet part of IP addr?

A: gets allocated portion of its provider ISP’s address space

ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20

Organization 0 11001000 00010111 00010000 00000000 200.23.16.0/23 Organization 1 11001000 00010111 00010010 00000000 200.23.18.0/23 Organization 2 11001000 00010111 00010100 00000000 200.23.20.0/23 ... ….. …. ….

Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23

Page 35: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-35

IP addressing: the last word...

Q: How does an ISP get block of addresses?

A: ICANN: Internet Corporation for Assigned Names and Numbers

allocates addresses manages DNS assigns domain names, resolves disputes

Page 36: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-36

NAT: Network Address Translation

10.0.0.1

10.0.0.2

10.0.0.3

10.0.0.4

138.76.29.7

local network(e.g., home network)

10.0.0/24

rest ofInternet

Datagrams with source or destination in this networkhave 10.0.0/24 address for

source, destination (as usual)

All datagrams leaving localnetwork have same single source

NAT IP address: 138.76.29.7,different source port numbers

Page 37: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-37

NAT: Network Address Translation

Motivation: local network uses just one IP address as far as outside world is concerned: range of addresses not needed from ISP: just one

IP address for all devices can change addresses of devices in local network

without notifying outside world can change ISP without changing addresses of

devices in local network devices inside local net not explicitly

addressable, visible by outside world (a security plus).

Page 38: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-38

NAT: Network Address TranslationImplementation: NAT router must:

outgoing datagrams: replace (source IP address, port #) of every outgoing datagram to (NAT IP address, new port #). . . remote clients/servers will respond using

(NAT IP address, new port #) as destination addr.

remember (in NAT translation table) every (source IP address, port #) to (NAT IP address, new port #) translation pair

incoming datagrams: replace (NAT IP address, new port #) in dest fields of every incoming datagram with corresponding (source IP address, port #) stored in NAT table

Page 39: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-39

NAT: Network Address Translation

10.0.0.1

10.0.0.2

10.0.0.3

S: 10.0.0.1, 3345D: 128.119.40.186, 80

1

10.0.0.4

138.76.29.7

1: host 10.0.0.1 sends datagram to 128.119.40.186, 80

NAT translation tableWAN side addr LAN side addr

138.76.29.7, 5001 10.0.0.1, 3345…… ……

S: 128.119.40.186, 80 D: 10.0.0.1, 3345

4

S: 138.76.29.7, 5001D: 128.119.40.186, 80

2

2: NAT routerchanges datagramsource addr from10.0.0.1, 3345 to138.76.29.7, 5001,updates table

S: 128.119.40.186, 80 D: 138.76.29.7, 5001

3

3: Reply arrives dest. address: 138.76.29.7, 5001

4: NAT routerchanges datagramdest addr from138.76.29.7, 5001 to 10.0.0.1, 3345

Page 40: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-40

NAT: Network Address Translation

16-bit port-number field: 60,000 simultaneous connections with a

single LAN-side address! NAT is controversial:

routers should only process up to layer 3 violates end-to-end argument

• NAT possibility must be taken into account by app designers, e.g., P2P applications

address shortage should instead be solved by IPv6

Page 41: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-41

Chapter 4: Network Layer

4. 1 Introduction4.2 Virtual circuit and datagram networks4.3 What’s inside a router4.4 IP: Internet Protocol

Datagram format IPv4 addressing ICMP IPv6

4.5 Routing algorithms Link state Distance Vector Hierarchical routing

4.6 Routing in the Internet RIP OSPF BGP

4.7 Broadcast and multicast routing

Page 42: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-42

ICMP: Internet Control Message Protocol

used by hosts & routers to communicate network-level information error reporting: unreachable host, network, port, protocol echo request/reply (used by ping)

network-layer “above” IP: ICMP msgs carried in IP datagrams

ICMP message: type, code plus first 8 bytes of IP datagram causing error

Type Code description0 0 echo reply (ping)3 0 dest. network unreachable3 1 dest host unreachable3 2 dest protocol unreachable3 3 dest port unreachable3 6 dest network unknown3 7 dest host unknown4 0 source quench (congestion control - not used)8 0 echo request (ping)9 0 route advertisement10 0 router discovery11 0 TTL expired12 0 bad IP header

Page 43: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-43

Chapter 4: Network Layer

4. 1 Introduction4.2 Virtual circuit and datagram networks4.3 What’s inside a router4.4 IP: Internet Protocol

Datagram format IPv4 addressing ICMP IPv6

4.5 Routing algorithms Link state Distance Vector Hierarchical routing

4.6 Routing in the Internet RIP OSPF BGP

4.7 Broadcast and multicast routing

Page 44: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-44

IPv6 Initial motivation: 32-bit address space

soon to be completely allocated. Additional motivation:

header format helps speed processing/forwarding

header changes to facilitate QoS IPv6 datagram format: fixed-length 40 byte header no fragmentation allowed

Page 45: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-45

IPv6 Header (Cont)Priority: identify priority among datagrams in flowFlow Label: identify datagrams in same “flow.” (concept of“flow” not well defined).Next header: identify upper layer protocol for data

data

destination address(128 bits)

source address(128 bits)

payload len next hdr hop limitflow labelpriver

32 bits

Page 46: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-46

Other Changes from IPv4

Checksum: removed entirely to reduce processing time at each hop

Options: allowed, but outside of header, indicated by “Next Header” field

ICMPv6: new version of ICMP additional message types, e.g. “Packet Too

Big” multicast group management functions

Page 47: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-47

Transition From IPv4 To IPv6

Not all routers can be upgraded simultaneous no “flag days” How will the network operate with mixed IPv4

and IPv6 routers? Tunneling: IPv6 carried as payload in IPv4

datagram among IPv4 routers

Page 48: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-48

TunnelingA B E F

IPv6 IPv6 IPv6 IPv6

tunnelLogical view:

Physical view:A B E F

IPv6 IPv6 IPv6 IPv6IPv4 IPv4

Page 49: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-49

TunnelingA B E F

IPv6 IPv6 IPv6 IPv6

tunnelLogical view:

Physical view:A B E F

IPv6 IPv6 IPv6 IPv6

C D

IPv4 IPv4

Flow: XSrc: ADest: F

data

Flow: XSrc: ADest: F

data

Flow: XSrc: ADest: F

data

Src:BDest: E

Flow: XSrc: ADest: F

data

Src:BDest: E

A-to-B:IPv6

E-to-F:IPv6

B-to-C:IPv6 inside

IPv4

B-to-C:IPv6 inside

IPv4

Page 50: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-50

Chapter 4: Network Layer

4. 1 Introduction4.2 Virtual circuit and datagram networks4.3 What’s inside a router4.4 IP: Internet Protocol

Datagram format IPv4 addressing ICMP IPv6

4.5 Routing algorithms Link state Distance Vector Hierarchical routing

4.6 Routing in the Internet RIP OSPF BGP

4.7 Broadcast and multicast routing

Page 51: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-51

Chapter 4: Network Layer

4. 1 Introduction4.2 Virtual circuit and datagram networks4.3 What’s inside a router4.4 IP: Internet Protocol

Datagram format IPv4 addressing ICMP IPv6

4.5 Routing algorithms Link state Distance Vector Hierarchical routing

4.6 Routing in the Internet RIP OSPF BGP

4.7 Broadcast and multicast routing

Page 52: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-52

1

23

0111

value in arrivingpacket’s header

routing algorithm

local forwarding tableheader value output link

0100010101111001

3221

Interplay between routing, forwarding

Page 53: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-53

u

yx

wv

z2

2

13

1

1

2

53

5

Graph: G = (N,E)

N = set of routers = { u, v, w, x, y, z }

E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) }

Graph abstraction

Remark: Graph abstraction is useful in other network contexts

Example: P2P, where N is set of peers and E is set of TCP connections

Page 54: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-54

Graph abstraction: costs

u

yx

wv

z2

2

13

1

1

2

53

5 • c(x,x’) = cost of link (x,x’)

- e.g., c(w,z) = 5

• cost could always be 1, or inversely related to bandwidth,or inversely related to congestion

Cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp)

Question: What’s the least-cost path between u and z ?

Routing algorithm: algorithm that finds least-cost path

Page 55: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-55

Routing Algorithm classification

Global or decentralized information?

Global: all routers have complete

topology, link cost info “link state” algorithmsDecentralized: router knows physically-

connected neighbors, link costs to neighbors

iterative process of computation, exchange of info with neighbors

“distance vector” algorithms

Static or dynamic?Static: routes change slowly

over timeDynamic: routes change more

quickly periodic update in response to link

cost changes

Page 56: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-56

Comparison of LS and DV algorithms

Message complexity LS: with n nodes, E links,

O(nE) msgs sent DV: exchange between

neighbors only convergence time

varies

Speed of Convergence LS: O(n2) algorithm

requires O(nE) msgs may have oscillations

DV: convergence time varies may be routing loops count-to-infinity

problem

Robustness: what happens if router malfunctions?

LS: node can advertise

incorrect link cost each node computes

only its own table

DV: DV node can advertise

incorrect path cost each node’s table used

by others • error propagate thru

network

Page 57: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-57

Hierarchical Routing

scale: with 200 million destinations:

can’t store all dest’s in routing tables!

routing table exchange would swamp links!

administrative autonomy

internet = network of networks

each network admin may want to control routing in its own network

Our routing study thus far - idealization all routers identical network “flat”… not true in practice

Page 58: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-58

Hierarchical Routing

aggregate routers into regions, “autonomous systems” (AS)

routers in same AS run same routing protocol “intra-AS” routing

protocol routers in different AS

can run different intra-AS routing protocol

gateway router at “edge” of its own

AS has link to router in

another AS

Page 59: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-59

3b

1d

3a

1c2aAS3

AS1

AS21a

2c2b

1b

Intra-ASRouting algorithm

Inter-ASRouting algorithm

Forwardingtable

3c

Interconnected ASes

forwarding table configured by both intra- and inter-AS routing algorithm intra-AS sets entries

for internal dests inter-AS & intra-As

sets entries for external dests

Page 60: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-60

Chapter 4: Network Layer

4. 1 Introduction4.2 Virtual circuit and datagram networks4.3 What’s inside a router4.4 IP: Internet Protocol

Datagram format IPv4 addressing ICMP IPv6

4.5 Routing algorithms Link state Distance Vector Hierarchical routing

4.6 Routing in the Internet RIP OSPF BGP

4.7 Broadcast and multicast routing

Page 61: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-61

Intra-AS Routing

also known as Interior Gateway Protocols (IGP) most common Intra-AS routing protocols:

RIP: Routing Information Protocol

OSPF: Open Shortest Path First

IGRP: Interior Gateway Routing Protocol (Cisco proprietary)

Page 62: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-62

RIP ( Routing Information Protocol) included in BSD-UNIX distribution in 1982 distance vector algorithm

distance metric: # hops (max = 15 hops), each link has cost 1

DVs exchanged with neighbors every 30 sec in response message (aka advertisement)

each advertisement: list of up to 25 destination subnets (in IP addressing sense)

DC

BA

u vw

x

yz

subnet hops u 1 v 2 w 2 x 3 y 3 z 2

from router A to destination subnets:

Page 63: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-63

OSPF (Open Shortest Path First)

“open”: publicly available uses Link State algorithm

LS packet dissemination topology map at each node route computation using Dijkstra’s algorithm

OSPF advertisement carries one entry per neighbor router

advertisements disseminated to entire AS (via flooding) carried in OSPF messages directly over IP (rather than

TCP or UDP

Page 64: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-64

OSPF “advanced” features (not in RIP) security: all OSPF messages authenticated (to

prevent malicious intrusion) multiple same-cost paths allowed (only one path

in RIP) for each link, multiple cost metrics for different

TOS (e.g., satellite link cost set “low” for best effort ToS; high for real time ToS)

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

data base as OSPF hierarchical OSPF in large domains.

Page 65: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-65

Hierarchical OSPFboundary router

backbone router

Area 1

Area 2

Area 3

backbone

areaborderrouters

internalrouters

Page 66: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-66

Hierarchical OSPF

two-level hierarchy: local area, backbone. link-state advertisements only in area each nodes has detailed area topology; only

know direction (shortest path) to nets in other areas.

area border routers: “summarize” distances to nets in own area, advertise to other Area Border routers.

backbone routers: run OSPF routing limited to backbone.

boundary routers: connect to other AS’s.

Page 67: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-67

Internet inter-AS routing: BGP

BGP (Border Gateway Protocol): the de facto inter-domain routing protocol “glue that holds the Internet together”

BGP provides each AS a means to: obtain subnet reachability information from

neighboring ASs. propagate reachability information to all AS-internal

routers. determine “good” routes to other networks based on

reachability information and policy. allows subnet to advertise its existence to rest

of Internet: “I am here”

Page 68: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-68

BGP routing policy

A,B,C are provider networks X,W,Y are customer (of provider networks) X is dual-homed: attached to two networks

X does not want to route from B via X to C .. so X will not advertise to B a route to C

A

B

C

W X

Y

legend:

customer network:

provider network

Page 69: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-69

BGP routing policy (2)

A advertises path AW to B B advertises path BAW to X Should B advertise path BAW to C?

No way! B gets no “revenue” for routing CBAW since neither W nor C are B’s customers

B wants to force C to route to w via A B wants to route only to/from its customers!

A

B

C

W X

Y

legend:

customer network:

provider network

Page 70: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-70

Why different Intra- and Inter-AS routing ?

Policy: Inter-AS: admin wants control over how its traffic

routed, who routes through its net. Intra-AS: single admin, so no policy decisions

needed

Scale: hierarchical routing saves table size, reduced

update trafficPerformance: Intra-AS: can focus on performance Inter-AS: policy may dominate over performance

Page 71: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-71

Chapter 4: Network Layer

4. 1 Introduction4.2 Virtual circuit and

datagram networks4.3 What’s inside a

router4.4 IP: Internet Protocol

Datagram format IPv4 addressing ICMP IPv6

4.5 Routing algorithms Link state Distance Vector Hierarchical routing

4.6 Routing in the Internet RIP OSPF BGP

4.7 Broadcast and multicast routing

Page 72: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-72

R1

R2

R3 R4

sourceduplication

R1

R2

R3 R4

in-networkduplication

duplicatecreation/transmissionduplicate

duplicate

Broadcast Routing deliver packets from source to all other

nodes source duplication is inefficient:

source duplication: how does source determine recipient addresses?

Page 73: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-73

In-network duplication

flooding: when node receives broadcast packet, sends copy to all neighbors problems: cycles & broadcast storm

controlled flooding: node only broadcasts pkt if it hasn’t broadcast same packet before node keeps track of packet ids already

broadcasted or reverse path forwarding (RPF): only

forward packet if it arrived on shortest path between node and source

spanning tree No redundant packets received by any node

Page 74: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Multicast Routing: Problem Statement Goal: find a tree (or trees) connecting

routers having local mcast group members tree: not all paths between routers used source-based: different tree from each sender to rcvrs shared-tree: same tree used by all group members

Shared tree Source-based trees

Page 75: CSCI 3335: C OMPUTER N ETWORKS C HAPTER 4 N ETWORK L AYER Vamsi Paruchuri University of Central Arkansas  Some

Network Layer 4-75

Chapter 4: summary

4. 1 Introduction4.2 Virtual circuit and datagram networks4.3 What’s inside a router4.4 IP: Internet Protocol

Datagram format IPv4 addressing ICMP IPv6

4.5 Routing algorithms Link state Distance Vector Hierarchical routing

4.6 Routing in the Internet RIP OSPF BGP

4.7 Broadcast and multicast routing