Chapters 4,5: Network Layermckinley/422/F19/Lectures/set4-2.pdf · CSE 422 -McKinley Network Layer...
Transcript of Chapters 4,5: Network Layermckinley/422/F19/Lectures/set4-2.pdf · CSE 422 -McKinley Network Layer...
CSE 422 - McKinley Network Layer
Chapters 4,5: Network Layerr Introduction (forwarding and routing)r Review of queueing theoryr Router design and operationr IP: Internet Protocol
m IPv4 (datagram format, addressing, NAT, ICMP)m IPv6
r Routing algorithms m Link state, Distance Vector
r Routing in the Internetm Autonomous Systemsm Routing protocols (OSPF, BGP)
r Generalized Forwarding & SDN
CSE 422 - McKinley Network Layer
Router Architecture Overview
Two key router functions:r run routing algorithms/protocol (RIP, OSPF, BGP)r forwarding datagrams from incoming to outgoing link
CSE 422 - McKinley Network Layer
Input Port Functions
Decentralized switching:r given datagram destination, lookup output
port using forwarding table in input port memory
r goal: complete input port processing at �line speed�
r queueing: if datagrams arrive faster than forwarding rate into switch fabric
Physical layer:bit-level reception
Data link layer:e.g., Ethernetsee chapter 5
CSE 422 - McKinley Network Layer
Three types of switching fabrics
(or, more generally, aninterconnection network)
CSE 422 - McKinley Network Layer
Switching Via MemoryFirst generation routers:r were simply computers, with “switching” under direct control of CPUr packet copied to system�s memory, routed, then copied outr speed limited by memory bandwidth (2 bus crossings per datagram)
InputPort
OutputPort
Memory
System Bus
CSE 422 - McKinley Network Layer
Switching Via a Busr datagram from input port
memoryto output port memory via a shared bus
r bus contention: switching speed limited by bus bandwidth
r 32 Gbps bus, Cisco 5600: sufficient speed for access and enterprise routers
CSE 422 - McKinley Network Layer
Switching Via Interconnection Network
r overcome bus bandwidth limitationsr Banyan networks, other interconnection networks
initially developed to connect processors in multiprocessor
r advanced design: fragmenting datagram into fixed length cells, switch cells through the fabric.
r Cisco 12000: switches 60 Gbps through the interconnection network
CSE 422 - McKinley Network Layer
Output port queueing
r buffering when arrival rate via switch exceeds output line speed
r queueing (delay) and loss due to output port buffer overflow!
CSE 422 - McKinley Network Layer
Input Port Queueingr if the switching fabric is slower than input ports
combined speed, queueing may occur at input queues r Head-of-the-Line (HOL) blocking: queued datagram
at front of queue prevents others in queue from moving forward
r queueing delay and loss due to input buffer overflow!
CSE 422 - McKinley Network Layer
Chapters 4,5: Network Layerr Introduction (forwarding and routing)r Review of queueing theoryr Router design and operationr IP: Internet Protocol
m IPv4 (datagram format, addressing, NAT, ICMP)m IPv6
r Routing algorithms m Link state, Distance Vector
r Routing in the Internetm Autonomous Systemsm Routing protocols (OSPF, BGP)
r Generalized Forwarding & SDN
CSE 422 - McKinley
Internet Protocol (IP)r IP is a DoD standard, designed from the
beginning with internetworking in mindr IP features
m unreliable -delivery of packets is not guaranteed
m connectionless -packets are routed and handled independently, even if part of the same message
m best-effort delivery -packets are only discarded when underlying components fail or an overload condition occurs
r Defines basic unit of data transfer, the IP datagram
Network Layer
CSE 422 - McKinley Network Layer
The Internet Network layerThe picture can't be displayed.
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
CSE 422 - McKinley Network Layer
IP (v4) datagram format
ver length
32 bits
data (variable length,typically a TCP
or UDP segment)
16-bit identifierheader
checksumtime to
live32 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 flgs fragmentoffset
upperlayer
32 bit destination IP address
Options (if any) E.g. timestamp,record routetaken, specifylist of routers to visit.
how much overhead with TCP?r 20 bytes of TCPr 20 bytes of IPr = 40 bytes + app layer
overhead
CSE 422 - McKinley
Internet Addressing
r To support a universal communication service, a globally accepted addressing method is required.
r IPv4 address properties m unique 32-bit number for each host m an IP address comprises two components m netid identifies a network (subnet) m hostid identifies a host on that network
Network Layer
CSE 422 - McKinley Network Layer
IP Address Allocation
Q: How does an ISP get block of addresses?A: ICANN: Internet Corporation for Assigned
Names and Numbers Non-profit organization that:
m allocates addressesm manages DNSm assigns domain names, resolves disputes
CSE 422 - McKinley
Traditional IPv4 Addressing
32 Bits
Range of host addresses
1.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 247.255.255.255
Class
0 Network Host
10 Network Host
110 Network Host
1110 Multicast address
11110 Reserved for future use
A
B
C
D
E
Network Layer
CSE 422 - McKinley
Addressing Conventionsr Normally, the 32-bit IP addresses are written as
four decimal numbers separated by decimal points m 10000000 00001010 00000010 00011110 m Is written as 128.10.2.30
r A network address with hostid = 0...0 refers to a network.
r A network address with hostid = 1...1 is a (directed) broadcast address, referring to all hosts on a specified network. Where possible (e.g., Ethernet), IP broadcasting takes advantage of a hardware broadcast facility.
Network Layer
CSE 422 - McKinley
Addressing Conventionsr A network address with netid = 1...1 and
hostid =1...1 is a broadcast address for the local network. Local broadcast is used in startup before a host knows its IP address or the IP address of the local network.
r 127.0.0.0 is reserved for loopback. Using this network address, a packet will not get to the network.
r Question: If an IP address identifies a host, how do we assign a single IP address to a gateway/router node, which by definition belongs to multiple networks?
Network Layer
CSE 422 - McKinley Network Layer
IPv4 Addressingr IP address: 32-bit
identifier for host or router interface
r interface: connection between host/router and physical linkm router�s typically have
multiple interfacesm host typically has one
interfacem 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
CSE 422 - McKinley
Subnetting (traditional)r Some bits in the hostid part of the IP
address are actually used to specify a particular physical network, such as a LAN on a campus
Network Layer
CSE 422 - McKinley
Subnetting (traditional)r All gateways on rest of the Internet route
packets as if there were one physical network behind G
r The partitioning of the local address part is an autonomous decision
r A subnet mask indicates which bits in the hostid are to be used for network addressing
r 11111111 11111111 11111111 00000000 11111111 11111111 00011000 01000000
r Although not required to do so, managers would usually select contiguous bits for the subnetwork and use the same mask for all physical networks at a particular site.
Network Layer
CSE 422 - McKinley Network Layer
Subnetting (generalized)r IP address:
m subnet part (high order bits)
m host part (low order bits)
r What�s a subnet ?m device interfaces with
same subnet part of IP address
m 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
CSE 422 - McKinley Network Layer
Subnets 223.1.1.0/24 223.1.2.0/24
223.1.3.0/24
Procedurer To determine the
subnets, detach each interface from its host or router, creating islands of isolated networks. Each isolated network is called a subnet.
Subnet mask notation: address/#bits
CSE 422 - McKinley
Traditional Addressing Problem
Network Layer
CSE 422 - McKinley Network Layer
IP addressing: CIDRCIDR: Classless InterDomain Routing
m subnet portion of address of arbitrary lengthm 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
CSE 422 - McKinley Network Layer
IP addresses: how to get one?Q: How does a host get IP address?
r Static IP: hard-coded by system admin in a filem Windows:
• control-panel->network->configuration->tcp/ip->propertiesm Traditional UNIX:
• /etc/rc.configm Linux:
• /etc/network/interfacesr DHCP: Dynamic Host Configuration Protocol:
dynamically get address from as serverm �plug-and-play�
CSE 422 - McKinley Network Layer
DHCP: Dynamic Host Configuration ProtocolGoal: 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 and �on�)
Support for mobile users who want to join network (more shortly)DHCP overview:
m host broadcasts �DHCP discover� msg [optional]m DHCP server responds with �DHCP offer� msg
[optional]m host requests IP address: �DHCP request� msgm DHCP server sends address: �DHCP ack� msg
CSE 422 - McKinley Network Layer
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
CSE 422 - McKinley Network Layer
DHCP client-server scenarioDHCP server: 223.1.2.5 arriving
client
time
DHCP discover
src : 0.0.0.0, 68 dest.: 255.255.255.255,67yiaddr: 0.0.0.0transaction ID: 654
DHCP offersrc: 223.1.2.5, 67 dest: 255.255.255.255, 68yiaddrr: 223.1.2.4transaction ID: 654Lifetime: 3600 secs
DHCP requestsrc: 0.0.0.0, 68 dest:: 255.255.255.255, 67yiaddrr: 223.1.2.4transaction ID: 655Lifetime: 3600 secs
DHCP ACKsrc: 223.1.2.5, 67 dest: 255.255.255.255, 68yiaddrr: 223.1.2.4transaction ID: 655Lifetime: 3600 secs
CSE 422 - McKinley Network Layer
Other DHCP functionality
DHCP can return more than just allocated IP address on subnet:m address of first-hop router for clientm name and IP address of DNS severm network mask (indicating network versus host
portion of address)
CSE 422 - McKinley Network Layer
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
CSE 422 - McKinley Network Layer
NAT: Network Address Translation
r Motivation: local network uses just one IP address as far as outside world is concerned:m range of addresses not needed from ISP: just one IP
address for all devicesm can change addresses of devices in local network
without notifying outside worldm can change ISP without changing addresses of
devices in local networkm devices inside local net not explicitly addressable,
visible by outside world (a security plus).
CSE 422 - McKinley Network Layer
NAT: Network Address TranslationImplementation: NAT router must:
m 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.
m remember (in NAT translation table) every (source IP address, port #) to (NAT IP address, new port #) translation pair
m 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
CSE 422 - McKinley Network Layer
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
110.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 addr138.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, 802
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 arrivesdest. address:138.76.29.7, 5001
4: NAT routerchanges datagramdest addr from138.76.29.7, 5001 to 10.0.0.1, 3345
CSE 422 - McKinley Network Layer
NAT: Network Address Translation
r 16-bit port-number field: m 60,000 simultaneous connections with a single LAN-
side address!r Problem with this approach???r NAT is controversial:
m routers should only process up to layer 3m violates end-to-end argument
• NAT possibility must be taken into account by app designers, eg, P2P applications
m address shortage should instead be solved by IPv6
CSE 422 - McKinley Network Layer
NAT traversal problemr client wants to connect to
server with address 10.0.0.1m server address 10.0.0.1 local
to LAN (client can�t use it as destination addr)
m only one externally visible NATted address: 138.76.29.7
r One solution: statically configure NAT to forward incoming connection requests at given port to serverm e.g., (123.76.29.7, port 2500)
always forwarded to 10.0.0.1 port 25000
10.0.0.1
10.0.0.4
NAT router
138.76.29.7
Client ?
CSE 422 - McKinley Network Layer
NAT traversal problemr Yet another: relaying (used in Skype)
m NATed client establishes connection to relaym External client connects to relaym relay bridges packets between to connections
138.76.29.7Client
10.0.0.1
NAT router
1. connection torelay initiatedby NATted host
2. connection torelay initiatedby client
3. relaying established
CSE 422 - McKinley Network Layer
IP Fragmentation & Reassemblyr network links have MTU
(max.transfer size) - largest possible link-level frame.m different link types,
different MTUs r large IP datagram divided
(�fragmented�) within netm one datagram becomes
several datagramsm �reassembled� only at
final destinationm IP header bits used to
identify, order related fragments
fragmentation: in: one large datagramout: 3 smaller datagrams
reassembly
CSE 422 - McKinley Network Layer
IP Fragmentation and ReassemblyID=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
Exampler 4000 byte
datagramr MTU = 1500 bytes
1480 bytes in data field
offset =1480/8
CSE 422 - McKinley
ICMP: Internet Control Message Protocol
r IP is actually a large distributed systemr ICMP isused by hosts & routers to
communicate network-level informationmerror reporting: unreachable host,
network, port, protocolmecho request/reply (used by ping)
r Technically a network-layer �above� IP:mICMP msgs carried in IP datagrams
Network Layer
CSE 422 - McKinley Network Layer
ICMP CodesType 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
CSE 422 - McKinley
ICMP message content
r ICMP message: type, code plus IP header and first 8 bytes of payload in datagram causing error. Why the payload???
Network Layer
CSE 422 - McKinley Network Layer
Traceroute and ICMP
r Source sends series of UDP segments to destm First has TTL =1m Second has TTL=2, etc.m Unlikely port number
r When nth datagram arrives to nth router:m Router discards datagramm And sends to source an
ICMP message (type 11, code 0)
m Message includes name of router& IP address
r When ICMP message arrives, source calculates RTT
r Traceroute does this 3 times
Stopping criterionr UDP segment eventually
arrives at destination host with bogus port number
r Destination returns ICMP �host unreachable� packet (type 3, code 3)
r When source gets this ICMP, stops.