Chapter 4 Network Layer

Computer Networking: A Top Down Approach , 6th edition. Jim Kurose, Keith Ross Addison-Wesley

Network Layer

4-1

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 o o o o

Datagram format IPv4 addressing ICMP IPv6

 4.5 Routing algorithms o Link state o Distance Vector o Hierarchical routing  4.6 Routing in the

Internet o o o

RIP OSPF BGP

 4.7 Broadcast and

multicast routing

Network Layer

4-2

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 o o o o

Datagram format IPv4 addressing ICMP IPv6

 4.5 Routing algorithms o Link state o Distance Vector o Hierarchical routing  4.6 Routing in the

Internet o o o

RIP OSPF BGP

 4.7 Broadcast and

multicast routing

Network Layer

4-3

Router Architecture Overview Two key router functions:  run routing algorithms/protocol (e.g. RIP, OSPF, BGP) 

forwarding datagrams from incoming to outgoing link

forwarding tables computed, pushed to input ports

routing, management control plane (software)

routing processor

forwarding data plane (hardware)

high-speed switching fabric

router input ports

router output ports

Network Layer

4-4

Input Port Functions line termination

Physical layer: bit-level reception Data link layer: e.g., Ethernet; see chapter 5

link layer protocol (receive)

lookup, forwarding

switch fabric

queueing

Decentralized switching:

 given datagram dest., lookup output port

using forwarding table in input port memory  goal: complete input port processing at ‘line speed’  queuing if datagrams arrive faster than forwarding rate into switch fabric Network Layer

4-5

Switching fabrics  

transfer packet from input buffer to appropriate output buffer switching rate: rate at which packets can be transfered from inputs to outputs  often measured as multiple of input/output line rate  N inputs: switching rate N times line rate desirable



three typical types of switching fabrics memory

memory

bus

crossbar

Network Layer 4-6

Switching Via Memory First generation routers:  traditional computers with switching under direct control of CPU  packet copied to system’s memory  speed limited by memory bandwidth (2 bus crossings per datagram) input port (e.g., Ethernet)

memory

output port (e.g., Ethernet) system bus

Network Layer

4-7

Switching Via a Bus  datagram from input port memory

to output port memory via a shared bus  bus contention: switching speed limited by bus bandwidth (ideally N times the input port speed, where N is number of input ports)

bus

 example: 32 Gbps bus, Cisco 5600:

sufficient speed for access and enterprise routers

Network Layer

4-8

Switching Via a Crossbar  datagram from input port memory

to output port memory via a crossbar  Possible to have multiple crossconnections via cross bar, without contention (e.g B to X, A to Y)

crossbar

Network Layer

4-9

More advance architectures: Switching Via An Interconnection Network

 overcome bus bandwidth limitations  Banyan networks, other interconnection nets initially

developed to connect processors in multiprocessor  advanced design: fragmenting datagram into fixed length cells (small packets-fixed length), switch cells through the fabric.  Example: Cisco 12000- switches 60 Gbps through the interconnection network

Network Layer 4-10

Banyan and Batcher-banyan Switch Banyan switch routes all packets to the correct output without collisions if the packets are presented in ascending order • Complexity is n x log2 n (lower than crossbar) – log2 n stages, n/2 elements in each stage • However, the banyan switch is not non-blocking

To improve the banyan switch, we need to sort packets into ascending order before routing them in the banyan network – this is done by the batcher network in front of a banyan network Network Layer

4-11

Output Ports



Buffering required when datagrams arrive from

fabric faster than the transmission rate  Scheduling discipline chooses among queued datagrams for transmission

Network Layer 4-12

Output port queueing

switch fabric

at t, packets move from input to output

switch fabric

one packet time later

 buffering when arrival rate via switch exceeds

output line speed



queuing (delay) and loss possible due to output port buffer overflow! Network Layer 4-13

How much buffering?  RFC 3439 rule of thumb: average buffering

equal to “typical” RTT (say 250 msec) times link capacity C o

e.g., C = 10 Gps link: 2.5 Gbit buffer!!!!

 Recent recommendation: with

buffering equal to

N flows,

RTT. C N

o

for 100,000 flows = 2.5 Gbit/100 = 25 Mbit!!! Network Layer 4-14

Input Port Queuing  Fabric slower than input ports combined -> queueing

may occur at input queues o

queueing delay and loss due to input buffer overflow!

 Head-of-the-Line (HOL) blocking: queued datagram

at front of queue prevents others in queue from moving forward

switch fabric

output port contention: only one red datagram can be transferred. lower red packet is blocked

switch fabric

one packet time later: green packet experiences HOL blocking Network Layer

4-15

Router examples Cisco 12816 Port density examples • 30xOC-192 (10 Gb/s) ports • 120xOC-48 (2.5 Gb/s) ports • 15x10 Gigabit Ethernet ports • 60x1 Gigabit Ethernet ports

M-series – 8xOC-192 or 32xOC-48

Network Layer 4-16

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 o o o o

Datagram format IPv4 addressing ICMP IPv6

 4.5 Routing algorithms o Link state o Distance Vector o Hierarchical routing  4.6 Routing in the

Internet o o o

RIP OSPF BGP

 4.7 Broadcast and

multicast routing

Network Layer 4-17

The Internet Network layer Host, router network layer functions: Transport layer: TCP, UDP

Network layer

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

Routing protocols •path selection •RIP, OSPF, BGP

forwarding table

ICMP protocol •error reporting •router “signaling”

Link layer physical layer

Network Layer 4-18

IP datagram format IP protocol version number header length (bytes) “type” of data max number remaining hops (decremented at each router) upper layer protocol to deliver payload to

how much overhead?  20 bytes of TCP  20 bytes of IP  = 40 bytes + app layer overhead

32 bits head. type of length ver len service fragment 16-bit identifier flgs offset upper time to header layer live checksum

total datagram length (bytes) for fragmentation/ reassembly

32 bit source IP address 32 bit destination IP address options (if any)

data (variable length, typically a TCP or UDP segment)

e.g. timestamp, record route taken, specify list of routers to visit.

Network Layer

4-19

IP Addressing: introduction  IP address: 32-bit

identifier for host/ router interface 223.1.1.2  interface: connection between host/router and physical link o

o

o

223.1.1.1 223.1.2.1

223.1.1.4

223.1.2.9

223.1.3.27

223.1.1.3

223.1.2.2

router’s typically have multiple interfaces 223.1.3.2 223.1.3.1 host typically has one interface IP addresses associated with each 223.1.1.1 = 11011111 00000001 00000001 00000001 interface 223

Dotted decimal format

1

1

1

Network Layer 4-20

IP addressing: introduction 223.1.1.1 Q: how are interfaces actually 223.1.1.2 connected? A: we’ll learn about that in chapter 5, 6. 223.1.1.3

223.1.2.1

223.1.1.4

223.1.2.9

223.1.3.27 223.1.2.2

A: e.g. wired Ethernet interfaces connected by Ethernet switches 223.1.3.1

For now: don’t need to worry about how one interface is connected to another (with no intervening router)

223.1.3.2

A: e.g. wireless WiFi interfaces connected by WiFi base station Network Layer

4-21

IP address: Subnets  IP address: o subnet part (high order bits) o host part (low order bits) 

What’s a subnet ? o

o

o

device interfaces with same subnet part of IP address can physically reach each other without intervening router – hence faster routing (Layer-2 switching; more later)

223.1.1.1 223.1.1.2 223.1.1.4

223.1.2.1 223.1.2.9 223.1.2.2

223.1.1.3

223.1.3.27

subnet 223.1.3.1

223.1.3.2

network consisting of 3 subnets

Network Layer 4-22

Subnets

223.1.1.0/24 223.1.2.0/24

How many subnets? Recipe  To determine the subnets, detach each interface from its host or router, creating islands of isolated networks.  Each isolated network is called a subnet.

223.1.1.1 223.1.1.2 223.1.1.4

223.1.2.1 223.1.2.9 223.1.2.2

223.1.1.3

223.1.3.27

subnet 223.1.3.1

223.1.3.2

223.1.3.0/24

Subnet mask: /24 Network Layer 4-23

Subnets

223.1.1.2

How many?

223.1.1.1

223.1.1.4 223.1.1.3

223.1.9.2

223.1.7.0

223.1.9.1

223.1.7.1 223.1.8.1

223.1.8.0

223.1.2.6 223.1.2.1

223.1.3.27 223.1.2.2

223.1.3.1

223.1.3.2

Network Layer 4-24

IP addressing: CIDR CIDR: Classless InterDomain Routing o

o

subnet portion of address of arbitrary length denoted by x in a.b.c.d/x address format: a.b.c.d/x, where x is # bits in subnet portion of address host part

subnet part

11001000 00010111 00010000 00000000 200.23.16.0/23 32-23=9 bits for host part = 29=512 unique IPs in this subnet Network Layer 4-25

Classful Addressing (historical)

What was wrong, if anything, with this addressing model? Network Layer 4-26

Subnetting/Netmask • process of subnetting involves separation of network and subnet portion of an address from host identifier. • performed by a bitwise AND operation between the IP address and the subnet prefix or bit mask. • result yields the network address, and the remainder is the host identifier. following example is based on IPv4 networking. The operation may be visualized in a table using binary address formats. Dot-decimal notation

Binary form

IP address

192.168.5.130

11000000.10101000.00000101.10000010

Subnet Mask

255.255.255.0

11111111.11111111.11111111.00000000

Network Portion

192.168.5.0

11000000.10101000.00000101.00000000

Host Portion

0.0.0.130

00000000.00000000.00000000.10000010

Network Layer 4-27

Subnetting / Netmask Another example:  Consider the IP address 192.168.40.3 that is part of Class C

network 192.168.40.0. o

o

o

o

A subnet or sub-network is defined through a network mask boundary using the specified number of significant bits as 1s. Since Class C defines networks with a 24-bit boundary, we can then consider that the most significant 24 bits are 1s, and the lower 8 bits are 0s. This translates to the dotted decimal notation 255.255.255.0, which is also compactly written as “/24” to indicate how many most significant bits are 1s. bit-wise logical “AND” operation between host address and netmask to obtain the Class C network address as shown below: 11000000 10101000 00101000 00000011 → 192.168.40.3 11111111 11111111 11111111 00000000 → netmask (/24) 11000000 10101000 00101000 00000000 → 192.168.40.0 ----netid

Network Layer 4-28

Subnetting/Netmask Another example (cont.):  Now consider that we want to change the netmask

explicitly to /21

to identify a network larger than a 24-bit subnet boundary. If we now do the bit-wise operation o o o

11000000 10101000 00101000 00000011 → 192.168.40.3 11111111 11111111 11111000 00000000 → netmask (/21) 11000000 10101000 00101000 00000000 → 192.168.40.0 netid

 note that the network address is again 192.168.40.0. However, in

the latter case, the network boundary is 21 bits. Thus, to be able to clearly distinguish between the first and the second one, it is necessary to explicitly mention the netmask.

 commonly written for second example as 192.168.40.0/21, where

first part is the netid and the second part is the mask boundary indicator.

Network Layer 4-29

Basic Subnetting for given address block  Subnetting allows for creating multiple logical networks from a

single address block  Subnets are created using one or more of the host bits as network bits o

done by extending the mask to borrow some of the bits from the host portion to create additional network bits

Notes taken from Cisco Systems, Inc. Part of the CCNA Exploration Course “Network Fundamentals”

30

Calculating Subnets and Hosts  The number of subnets is calculated using 2n, where n is the

number of bits borrowed o o

21 = 2 subnets the more bits borrowed, the more subnets can be defined

 The number of useable hosts per subnet is calculated using 2h -

2 where h is the number of host bits left o o

27 – 2 = 126 useable hosts per subnet with each bit borrowed, fewer host addresses are available per subnet

31

Subnetting Example 1  Need to borrow a minimum of 2 host bits to cater for 3

subnets o

22 = 4 subnets

32

Subnetting Example 1 (cont.)  6 host bits are left in the last octet  26 – 2 = 62 hosts per subnet

33

Subnetting Example 2  Need to borrow a minimum of 3 host bits to cater for 6

subnets o

23 = 8 subnets

34

Subnetting Example 2 (cont.)  5 host bits are left in the last octet  25 – 2 = 30 hosts per subnet

35

Fixed Length Subnet Mask (FLSM)  Using traditional subnetting or FLSM, each subnet is allocated

the same number of host addresses o

these fixed size address block would be efficient if all subnets have the same requirements for the number of hosts

25 – 2 = 30 hosts per subnet

36

Variable Length Subnet Mask (VLSM)  VLSM was designed to maximize addressing efficiency o

E.g. each WAN link requires 2 host addresses

 Breaks up a subnet into a smaller subnet

37

IP addresses: how to get one? Q: How does host get IP address?  hard-coded by system admin in a file

Wintel: control-panel->network>configuration->tcp/ip->properties o UNIX: /etc/rc.config  DHCP: Dynamic Host Configuration Protocol: dynamically get address from as server o “plug-and-play” o

Network Layer 4-38

IP addresses: how to get one?  Beyond the IP address a device also needs

to know: Subnet mask, Default gateway, and DNS IP address

Manual entry via e.g. windows interface

Network Layer 4-39

DHCP: Dynamic Host Configuration Protocol Goal: allow host to dynamically obtain its IP address from network server when it joins network Can renew its lease on address in use Allows reuse of addresses (only hold address while connected “on” Support for mobile users who want to join network (more shortly)

DHCP overview: o host broadcasts “DHCP discover” msg o DHCP server responds with “DHCP offer” msg o host requests IP address: “DHCP request” msg o DHCP server sends address: “DHCP ack” msg Network Layer 4-40

DHCP client-server scenario DHCP server

223.1.1.0/24

223.1.2.1

223.1.1.1

223.1.1.2 223.1.1.4

223.1.1.3

223.1.2.9

223.1.3.27

223.1.2.2

arriving DHCP client needs address in this network

223.1.2.0/24 223.1.3.2

223.1.3.1

223.1.3.0/24 Network Layer 4-41

RFC 2131 Dynamic Host Configuration Protocol March 1997 0 1 2 3 01234567890123456789012345678901 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | op (1) | htype (1) | hlen (1) | hops (1) | +---------------+---------------+---------------+---------------+ | xid (4) | +-------------------------------+-------------------------------+ | secs (2) | flags (2) | +-------------------------------+-------------------------------+ | ciaddr (4) | +---------------------------------------------------------------+ | yiaddr (4) | +---------------------------------------------------------------+ | siaddr (4) | +---------------------------------------------------------------+ | giaddr (4) | +---------------------------------------------------------------+ | | | chaddr (16) | | | | | +---------------------------------------------------------------+ | | | sname (64) | +---------------------------------------------------------------+ | | | file (128) | +---------------------------------------------------------------+ | | | options (variable) | +---------------------------------------------------------------+

Figure 1: Format of a DHCP message

http://www.ietf.org/rfc/rfc2131.txt

4-42

Table 1: Description of fields in a DHCP message FIELD -----

OCTETS DESCRIPTION ----------------

ciaddr

4 Client IP address; only filled in if client

is in BOUND, RENEW or REBINDING state and can op

htype

1 Message op code / message type.

respond to ARP requests.

1 = BOOTREQUEST, 2 = BOOTREPLY

yiaddr

4 'your' (client) IP address.

1 Hardware address type, see ARP

siaddr

4 IP address of next server to use in

section in "Assigned Numbers" RFC; e.g., '1' = 10mb

bootstrap; returned in DHCPOFFER, DHCPACK by

ethernet.

server.

hlen

1 Hardware address length (e.g. '6' for

10mb ethernet). hops

1 Client sets to zero, optionally used by

relay agents when booting via a relay agent. xid

4 Transaction ID, a random number chosen

by the client, used by the client and server to associate

giaddr

4 Relay agent IP address, used in booting

via a relay agent. chaddr

16 Client hardware address.

sname

64 Optional server host name, null

terminated string. file

128 Boot file name, null terminated string;

messages and responses between a client and a

"generic“ name or null in DHCPDISCOVER, fully

server.

qualified directory-path name in DHCPOFFER.

secs

2 Filled in by client, seconds elapsed since

client began address acquisition or renewal process. flags

options

var Optional parameters field. See the

options documents for a list of defined options.

2 Flags

Network Layer 4-43

DHCP client-server scenario (also see wireshark lab) DHCP server: 223.1.2.5

DHCP discover

arriving client

src : 0.0.0.0, 68 dest.: 255.255.255.255,67 yiaddr: 0.0.0.0 transaction ID: 654 DHCP offer src: 223.1.2.5, 67 dest: 255.255.255.255, 68 yiaddrr: 223.1.2.4 transaction ID: 654 Lifetime: 3600 secs DHCP request

time

src: 0.0.0.0, 68 dest:: 255.255.255.255, 67 yiaddrr: 223.1.2.4 transaction ID: 655 Lifetime: 3600 secs DHCP ACK

CIADDR (Client IP Address) YIADDR (Your IP Address) SIADDR (Server IP Address) GIADDR (Gateway IP Address) CHADDR (Client Hardware Address)

src: 223.1.2.5, 67 dest: 255.255.255.255, 68 yiaddrr: 223.1.2.4 transaction ID: 655 Lifetime: 3600 secs

Network Layer 4-44 also see http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol

DHCP: more than IP address DHCP can return more than just allocated IP address on subnet: o o o

address of first-hop router for client name and IP address of DNS sever network mask (indicating network versus host portion of address)

Network Layer 4-45

DHCP: example DHCP UDP IP Eth Phy

DHCP DHCP DHCP DHCP



DHCP

DHCP DHCP DHCP DHCP



DHCP UDP IP Eth Phy

168.1.1.1

router with DHCP server built into router





connecting laptop needs its IP address, addr of first-hop router, addr of DNS server: use DHCP 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 Network Layer 4-46

DHCP: example 

DHCP UDP IP Eth Phy

DHCP DHCP DHCP DHCP

 DHCP DHCP DHCP DHCP DHCP

DHCP UDP IP Eth Phy

router with DHCP server built into router



DHCP server formulates DHCP ACK containing client’s IP address, IP address of first-hop router for client, name & IP address of DNS server 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 DSN server, IP address of its first-hop router

Network Layer 4-47

DHCP: wireshark output (home LAN) Message type: Boot Request (1) Hardware type: Ethernet Hardware address length: 6 Hops: 0 Transaction ID: 0x6b3a11b7 Seconds elapsed: 0 Bootp flags: 0x0000 (Unicast) Client IP address: 0.0.0.0 (0.0.0.0) Your (client) IP address: 0.0.0.0 (0.0.0.0) Next server IP address: 0.0.0.0 (0.0.0.0) Relay agent IP address: 0.0.0.0 (0.0.0.0) Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Server host name not given Boot file name not given Magic cookie: (OK) Option: (t=53,l=1) DHCP Message Type = DHCP Request Option: (61) Client identifier Length: 7; Value: 010016D323688A; Hardware type: Ethernet Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Option: (t=50,l=4) Requested IP Address = 192.168.1.101 Option: (t=12,l=5) Host Name = "nomad" Option: (55) Parameter Request List Length: 11; Value: 010F03062C2E2F1F21F92B 1 = Subnet Mask; 15 = Domain Name 3 = Router; 6 = Domain Name Server 44 = NetBIOS over TCP/IP Name Server ……

request

reply

Message type: Boot Reply (2) Hardware type: Ethernet Hardware address length: 6 Hops: 0 Transaction ID: 0x6b3a11b7 Seconds elapsed: 0 Bootp flags: 0x0000 (Unicast) Client IP address: 192.168.1.101 (192.168.1.101) Your (client) IP address: 0.0.0.0 (0.0.0.0) Next server IP address: 192.168.1.1 (192.168.1.1) Relay agent IP address: 0.0.0.0 (0.0.0.0) Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Server host name not given Boot file name not given Magic cookie: (OK) Option: (t=53,l=1) DHCP Message Type = DHCP ACK Option: (t=54,l=4) Server Identifier = 192.168.1.1 Option: (t=1,l=4) Subnet Mask = 255.255.255.0 Option: (t=3,l=4) Router = 192.168.1.1 Option: (6) Domain Name Server Length: 12; Value: 445747E2445749F244574092; IP Address: 68.87.71.226; IP Address: 68.87.73.242; IP Address: 68.87.64.146 Option: (t=15,l=20) Domain Name = "hsd1.ma.comcast.net."

Network Layer 4-48

Assigning Addresses to Other Devices--Hints  Beyond the IP devices assigned IP addresses via DHCP:  Addresses for servers and peripherals o

should have a static address servers and peripherals are concentration points

for network traffic

 Addresses for hosts that are accessible from Internet o o

the addresses for these devices should be static must have a public space address associated with it

 Addresses for intermediary devices o

intermediary devices are also a concentration point for network traffic; may be used as hosts to configure, monitor, or troubleshoot network operation; addresses are assigned manually to these devices

Notes taken by Cisco Systems, Inc. Part of the CCNA Exploration Course “Network Fundamentals”

49

Assigning Addresses to Other Devices--Suggestions  Routers and firewalls o o

each interface is assigned an address manually these devices can also be used for packet filtering

Notes taken by Cisco Systems, Inc. Part of the CCNA Exploration Course “Network Fundamentals”

50

IP addresses: how to get one? Q: How does network get subnet part of IP addr? A: gets/buys allocated portion of its provider ISP’s address space, e.g. 2 ISP's block

12=4096

11001000 00010111 00010000 00000000

200.23.16.0/20

Organization 0 Organization 1 Organization 2 ...

11001000 00010111 00010000 00000000 11001000 00010111 00010010 00000000 11001000 00010111 00010100 00000000 ….. ….

200.23.16.0/23 200.23.18.0/23 200.23.20.0/23 ….

Organization 7

11001000 00010111 00011110 00000000

200.23.30.0/23

ISP allocates to:

29=512

Network Layer 4-51

Hierarchical addressing: route aggregation Hierarchical addressing allows efficient advertisement of routing information: Organization 0

200.23.16.0/23 Organization 1

200.23.18.0/23

Organization 2

200.23.20.0/23

Organization 7

. . .

. . .

Fly-By-Night-ISP

“Send me anything with addresses beginning 200.23.16.0/20” Internet

200.23.30.0/23 ISPs-R-Us

“Send me anything with addresses beginning 199.31.0.0/16” Network Layer 4-52

Hierarchical addressing: more specific routes ISPs-R-Us has a more specific route to Organization 1 Organization 0

“Send me anything with addresses beginning 200.23.16.0/23 200.23.20.0/23

200.23.16.0/23

Organization 2

200.23.20.0/23

Organization 7

. . .

. . .

Fly-By-Night-ISP

…”

Internet

200.23.30.0/23 ISPs-R-Us Organization 1

200.23.18.0/23

“Send me anything with addresses beginning 199.31.0.0/16 or 200.23.18.0/23”

Network Layer 4-53

IP addressing: the last word... Q: How does an ISP get block of addresses? A: ICANN: Internet Corporation for Assigned Names and Numbers http://www.icann.org/  allocates addresses  manages DNS  assigns domain names, resolves disputes

 Regional Internet Registries (RIR) 

remaining IPv4 address space is managed by RIR since mid 1990s

Network Layer 4-54

Private addressing (non-global IPs)  Why do we need private non-global addressing? o Reusability of addresses o Flexibility o Aids in security (internal addresses not visible to the internet)  Reserved address space

 Any drawback? Network Layer 4-55

Reserved IP addresses The Internet Engineering Task Force (IETF) has directed the Internet Assigned Numbers Authority (IANA) to reserve the following IPv4 address ranges for private networks, as published in RFC 1918

Network Layer 4-56

NAT: Network Address Translation Example: rest of Internet

local network (e.g., home network) 10.0.0/24

10.0.0.1

10.0.0.4 10.0.0.2 138.76.29.7 10.0.0.3

All datagrams leaving local

network can have same single source NAT IP address: 138.76.29.7, but different source port numbers

Datagrams with source or destination in this network have 10.0.0/24 address for source, destination (as usual) Addresses have only local meaning (private addresses)

Network Layer 4-57

NAT: Network Address Translation  Motivation: local network uses just one IP address as

far as outside world is concerned: o range of addresses not needed from ISP: just one IP address for all internal devices o can change addresses of devices in local network without notifying outside world o can change ISP without changing addresses of devices in local network o devices inside local net not explicitly addressable, visible by outside world (a security plus).

Network Layer 4-58

NAT: Network Address Translation Implementation: NAT router must: o

outgoing datagrams: replace (source IP address, port

o

remember (in NAT translation table) every (source

o

incoming datagrams: replace (NAT IP address, new

#) of every outgoing datagram to (NAT IP address, new port #) . . . remote clients/servers will respond using (NAT IP address, new port #) as destination addr.

IP address, port #) to (NAT IP address, new port #) translation pair

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

Network Layer 4-59

NAT: network address translation 2: NAT router changes datagram source addr from 10.0.0.1, 3345 to 138.76.29.7, 5001, updates table

NAT translation table WAN side addr LAN side addr

1: host 10.0.0.1, 3345 sends datagram to 128.119.40.186, 80

138.76.29.7, 5001 10.0.0.1, 3345 …… ……

S: 10.0.0.1, 3345 D: 128.119.40.186, 80

10.0.0.1

1 2

S: 138.76.29.7, 5001 D: 128.119.40.186, 80

138.76.29.7 S: 128.119.40.186, 80 D: 138.76.29.7, 5001

3: reply arrives dest. address: 138.76.29.7, 5001

3

10.0.0.4 S: 128.119.40.186, 80 D: 10.0.0.1, 3345

10.0.0.2

4

10.0.0.3 4: NAT router changes datagram dest addr from 138.76.29.7, 5001 to 10.0.0.1, 3345

Network Layer 4-60

NAT: Network Address Translation  16-bit port-number field: o 60,000 simultaneous connections with a single LAN-side address!  NAT is controversial: o routers should only process up to layer 3 o violates end-to-end argument  NAT possibility must be taken into account by app designers, eg, P2P applications o

address shortage should instead be solved by IPv6 Network Layer 4-61

NAT traversal problem  client want to connect to

server with address 10.0.0.1 o

o

server address 10.0.0.1 local client to LAN (client can’t use it as destination addr) only one externally visible NATted address: 138.76.29.7

 solution 1: statically

configure NAT to forward incoming connection requests at given port to server o

10.0.0.1

?

138.76.29.7

10.0.0.4

NAT router

e.g., (123.76.29.7, port 2500) always forwarded to 10.0.0.1 port 25000 Network Layer 4-62

NAT traversal problem  solution 2: Universal Plug and

Play (UPnP) Internet Gateway Device (IGD) Protocol. Allows NATted host to:  learn public IP address (138.76.29.7) 138.76.29.7  enumerate existing port mappings  add/remove port mappings (with lease times)

10.0.0.1

IGD

NAT router

i.e., automate static NAT port map configuration Network Layer 4-63

NAT traversal problem  solution 3: relaying (used in Skype) o o o

NATed server establishes connection to relay External client connects to relay relay bridges packets between to connections

2. connection to relay initiated by client client

3. relaying established

1. connection to relay initiated by NATed host

138.76.29.7

10.0.0.1

NAT router

Network Layer 4-64

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 o o o o

Datagram format IPv4 addressing ICMP IPv6

 4.5 Routing algorithms o Link state o Distance Vector o Hierarchical routing  4.6 Routing in the

Internet o o o

RIP OSPF BGP

 4.7 Broadcast and

multicast routing

Network Layer 4-65

ICMP: Internet Control Message Protocol  used by hosts & routers to

communicate network-level information o error reporting: unreachable host, network, port, protocol o echo request/reply (used by ping)  network-layer “above” IP: o ICMP msgs carried in IP datagrams  ICMP message: type, code, plus first 8 bytes of IP datagram causing error

Type 0 3 3 3 3 3 3 4

Code 0 0 1 2 3 6 7 0

8 9 10 11 12

0 0 0 0 0

description echo reply (ping) dest. network unreachable dest host unreachable dest protocol unreachable dest port unreachable dest network unknown dest host unknown source quench (congestion control - not used) echo request (ping) route advertisement router discovery TTL expired bad IP header Network Layer 4-66

Traceroute and ICMP  Source sends series of

UDP segments to dest o o o

First has TTL =1 Second has TTL=2, etc. Unlikely port number

 When nth datagram arrives

to nth router: o o

o

Router discards datagram and sends to source an ICMP message (type 11, code 0) Message includes name of router& IP address 3 probes 3 probes

 When ICMP message

arrives, source calculates RTT  Traceroute does this 3 times Stopping criterion  UDP segment eventually arrives at destination host  Destination returns ICMP “host unreachable” packet (type 3, code 3)  When source gets this ICMP, stops.

3 probes Network Layer 4-67

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 o o o o

Datagram format IPv4 addressing ICMP IPv6

 4.5 Routing algorithms o Link state o Distance Vector o Hierarchical routing  4.6 Routing in the

Internet o o o

RIP OSPF BGP

 4.7 Broadcast and

multicast routing

Network Layer 4-68

IPv6  Initial motivation: 32-bit address space soon

to be completely allocated. (address space 232)  Now: 128 bits (address space 2128)!!!! How many addresses are these????!!!!  Additional motivation: o header format helps speed processing/forwarding o header changes to facilitate QoS o Better security IPv6 datagram format: o fixed-length 40 byte header o no fragmentation allowed Network Layer 4-69

IPv6 Header (Cont) Priority: identify priority among datagrams in flow Flow Label: identify datagrams in same “flow.”

(concept of“flow” not well defined). Next header: identify upper layer protocol for data ver

pri flow label hop limit payload len next hdr source address (128 bits) destination address (128 bits) data 32 bits

Network Layer 4-70

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 o o

additional message types, e.g. “Packet Too Big” multicast group management functions

Network Layer 4-71

Transition From IPv4 To IPv6  Not all routers can be upgraded simultaneously o How will the network operate with mixed IPv4 and IPv6 routers?  Tunneling: IPv6 carried as payload in IPv4

datagram among IPv4 routers IPv4 header fields IPv4 source, dest addr

IPv6 header fields IPv6 source dest addr

IPv4 payload

UDP/TCP payload

IPv6 datagram IPv4 datagram

Network Layer 4-72

Tunneling IPv4 tunnel connecting IPv6 routers

A

B

IPv6

IPv6

A

B

C

IPv6

IPv6

IPv4

logical view:

E

F

IPv6

IPv6

D

E

F

IPv4

IPv6

IPv6

physical view:

Network Layer 4-73

Tunneling IPv4 tunnel connecting IPv6 routers

A

B

IPv6

IPv6

A

B

C

IPv6

IPv6

IPv4

logical view:

E

F

IPv6

IPv6

D

E

F

IPv4

IPv6

IPv6

physical view:

flow: X src: A dest: F

data

A-to-B: IPv6

src:B dest: E

src:B dest: E

Flow: X Src: A Dest: F

Flow: X Src: A Dest: F

data

data

B-to-C: IPv6 inside IPv4

B-to-C: IPv6 inside IPv4

flow: X src: A dest: F

data

E-to-F: IPv6 4-74

IPv6: adoption  US National Institutes of Standards

estimate [2013]: o o

~3% of industry IP routers ~11% of US gov’t routers

 Long (long!) time for deployment, use o 20 years and counting! o think of application-level changes in last 20 years: WWW, Facebook, … o

Why?

Network Layer

4-75