<<

The Network layer Host, router network layer functions:

Transport layer: TCP, UDP

Routing protocols IP protocol IP addressing and forwarding •addressing conventions •path selection •RIP, OSPF, BGP •datagram format Network •packet handling conventions

layer forwarding ICMP protocol table •error reporting •router “signaling”

Link layer

physical layer

IP datagram format

IP protocol version 32 bits IP datagram format number total datagram header length head. type of length (bytes) ver length (bytes) len service for “type” of data fragment 16-bit identifier flgs fragmentation/ offset reassembly max number time to upper header remaining hops live layer checksum (decremented at 32 bit source IP address each router) 32 bit destination IP address upper layer protocol to deliver payload to Options (if any) E.g. timestamp, record route how much overhead data taken, specify with TCP? (variable length, list of routers • 20 bytes of TCP typically a TCP to visit. • 20 bytes of IP or UDP segment) • = 40 bytes + app layer overhead

1 IP Fragmentation & Reassembly IP Fragmentation and Reassembly • Network links have MTU (max.transfer size) - largest length ID fragflag offset possible link-level frame. Example =4000 =x =0 =0 – different link types, • 4000 byte different MTUs One large datagram becomes several smaller datagrams • Large IP datagram divided datagram (“fragmented”) within net • MTU = 1500 length ID fragflag offset – one datagram becomes bytes =1500 =x =1 =0 several datagrams 1480 bytes in – “reassembled” only at data field length ID fragflag offset final destination =1500 =x =1 =185 – IP header bits used to offset = identify, order related 1480/8 length ID fragflag offset fragments =1040 =x =0 =370

IP Addressing Subnets • IP address: 32-bit 223.1.1.1 • IP address: 223.1.1.1 identifier for host, 223.1.2.1 223.1.2.1 223.1.1.2 – subnet part (high 223.1.1.2 router interface 223.1.1.4 223.1.2.9 order bits) 223.1.1.4 223.1.2.9 • interface: connection – host part (low order 223.1.2.2 223.1.2.2 between host/router 223.1.1.3 223.1.3.27 bits) 223.1.1.3 223.1.3.27 and physical link • What’s a subnet ? subnet – router’s typically have – device interfaces multiple interfaces 223.1.3.1 223.1.3.2 with same subnet 223.1.3.1 223.1.3.2 – host typically has one part of IP address interface – can physically reach – IP addresses associated each other without network consisting of 3 subnets with each interface 223.1.1.1 = 11011111 00000001 00000001 00000001 intervening router 223 1 1 1

2 Subnetworks How many subnets? 223.1.1.2 223.1.1.0/24 Recipe 223.1.2.0/24 223.1.1.1 223.1.1.4 • To determine the subnets, detach 223.1.1.3 each interface from 223.1.7.0 its host or router, 223.1.9.2 creating islands of isolated networks. 223.1.9.1 223.1.7.1 Each isolated 223.1.8.1 223.1.8.0 network is called a 223.1.2.6 223.1.3.27 subnet. 223.1.3.0/24 223.1.2.1 223.1.2.2 223.1.3.1 223.1.3.2 Subnet mask: /24

IP addressing: CIDR How do you get an IP address?

• Hard-coded by system admin in a file CIDR: Classless InterDomain Routing – Wintel: control-panel->network->configuration- – subnet portion of address of arbitrary length >tcp/ip->properties – UNIX: /etc/rc.config – address format: a.b.c.d/x, where x is # bits in • DHCP: Dynamic Host Configuration Protocol: subnet portion of address dynamically get address from as server – “plug-and-play”

subnet host part part 11001000 00010111 00010000 00000000

200.23.16.0/23

3 Hierarchical addressing: route How do you get an IP address? aggregation How does network get subnet part of IP addr? Hierarchical addressing allows efficient advertisement of routing information: 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

Hierarchical addressing: more specific How does an ISP get block of routes addresses? ISPs-R-Us has a more specific route to Organization 1 ICANN: Internet Corporation for Assigned Names and Numbers – allocates addresses – manages DNS – assigns domain names, resolves disputes

4 NAT: Network Address Translation NAT Motivation

rest of local network • Local network uses just one IP address as far as outside Internet (e.g., home network) world is concerned: 10.0.0/24 10.0.0.1 – range of addresses not needed from ISP: just one IP 10.0.0.4 10.0.0.2 address for all devices 138.76.29.7 – can change addresses of devices in local network without notifying outside world 10.0.0.3 – can change ISP without changing addresses of devices All datagrams leaving local Datagrams with source or in local network network have same single source destination in this network – devices inside local net not explicitly addressable, visible NAT IP address: 138.76.29.7, have 10.0.0/24 address for different source port numbers source, destination (as usual) by outside world (a security plus).

NAT router must NAT Example

• 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

5 NAT The Internet Network layer Host, router network layer functions: • 16-bit port-number field: : TCP, UDP – 60,000 simultaneous connections with a single LAN-side address! Routing protocols IP protocol •path selection •addressing conventions • NAT is controversial: •RIP, OSPF, BGP •datagram format – routers should only process up to layer 3 Network •packet handling conventions layer forwarding – violates end-to-end argument ICMP protocol table • NAT possibility must be taken into account by app •error reporting designers, eg, P2P applications •router “signaling”

– address shortage should instead be solved by IPv6 physical layer

ICMP: Internet Control Message Protocol Traceroute and ICMP

• used by hosts & routers to Type Code description • Source sends series of UDP • When ICMP message communicate network-level 0 0 echo reply (ping) segments to dest arrives, source calculates information 3 0 dest. network unreachable – First has TTL =1 RTT 3 1 dest host unreachable – error reporting: – Second has TTL=2, etc. • Traceroute does this 3 times unreachable host, 3 2 dest protocol unreachable network, port, protocol 3 3 dest port unreachable – Unlikely port number Stopping criterion – echo request/reply (used 3 6 dest network unknown • When nth datagram arrives • UDP segment eventually by ping) 3 7 dest host unknown to nth router: arrives at destination host 4 0 source quench (congestion – Router discards datagram • network-layer “above” IP: control - not used) • Destination returns ICMP – ICMP msgs carried in IP 8 0 echo request (ping) – And sends to source an “port unreachable” packet datagrams 9 0 route advertisement ICMP message (type 11, (type 3, code 3) code 0) • ICMP message: type, code 10 0 router discovery • When source gets this – Message includes name of plus first 8 bytes of IP 11 0 TTL expired ICMP, stops. datagram causing error 12 0 bad IP header router& IP address

6