1 network layer ipv4 addresses types of ipv4 addresses ipv4

19
1 Network Layer 2 IPv4 Addresses q 32 bits long q Identifier for host, router interface q Notation: v Each byte is written in decimal in MSB order, separated by dots v Example: 128.195.1.80 3 Types of IPv4 Addresses q Unicast Address v Destination is a single host q Multicast address v Destination is a group of hosts q Broadcast address v 255.255.255.255 v Destination is all hosts 4 IPv4 Address Classes (old) 0 Net 32 bits Host 10 Net Host 110 Net Host 1110 Multicast address 11110 Reserved A B C D E Class

Upload: trannhi

Post on 02-Jan-2017

359 views

Category:

Documents


9 download

TRANSCRIPT

1

Network Layer

2

IPv4 Addresses q 32 bits long q Identifier for host, router interface q Notation:

v  Each byte is written in decimal in MSB order, separated by dots

v  Example: 128.195.1.80

3

Types of IPv4 Addresses q Unicast Address

v Destination is a single host q Multicast address

v Destination is a group of hosts q Broadcast address

v 255.255.255.255 v Destination is all hosts

4

IPv4 Address Classes (old)

0 Net

32 bits

Type of Serv. Host

10 Net Host

110 Net Host

1110 Multicast address

11110 Reserved

A

B

C

D

E

Class

2

5

IP Address Classes q  Class A:

v  For very large organizations v  16 million hosts allowed

q  Class B: v  For large organizations v  65 thousand hosts allowed

q  Class C v  For small organizations v  255 hosts allowed

q  Class D v  Multicast addresses v  No network/host hierarchy

6

IP Address Hierarchy q Class A, B, C addresses support two levels

of hierarchy q However, the host portion can be further

split into “subnets” by the address class owner v  more than 2 levels of hierarchy

7

Subnetting

Host id Subnet id Network id

Example: Class B address with 8-bit subnetting

165.230 .24 .8

16 bits 8 bits 8 bits

Example Address:

8

Subnet Masks

Subnet masks allow hosts to determine if another IP address is on the same subnet or the same network

Host id Subnet id Network id 16 bits 8 bits 8 bits

1111111111111111 11111111 00000000 Mask:

255.255 .255 .0

3

9

Subnet Masks (cont’d)

Are IP addresses A and B on the same subnet?

1. Compute (A and M). 2. Compute (B and M). 3. If (A and M) = (B and M) then A and B are on the same subnet.

Assume IP addresses A and B share subnet mask M.

Example: A and B are class B addresses A = 165.230.82.52 B = 165.230.24.93 M = 255.255.255.0

Same network? Same subnet?

10

IP Addressing in network

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.2 223.1.3.1

223.1.3.27

11

Problems with Class-based Routing

q  Too many small networks requiring multiple class C addresses

q  Running out of class B addresses, not enough nets in class A

q  Addressing strategy must allow for greater diversity of network sizes

12

IP addressing: CIDR

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

subnet portion of address

11001000 00010111 00010000 00000000

subnet part

host part

200.23.16.0/23

4

13

CIDR

q  An ISP can obtain a block of addresses and partition this further to its customers v  Say an ISP has 200.8.4.24/24 address (256

addresses). He has another customer who needs only 4 addresses from 200.8.4.24 then that block can be specified as 200.8.4.24/30

14

Reducing Routing Table Size

service provider

200.71.0.0 200.71.1.0 200.71.2.0 ….. 200.71.255.0

200.71.0.0 200.71.1.0 200.71.2.0 ….. 200.71.255.0

Routing table

Without CIDR:

service provider

200.71.0.0 200.71.1.0 200.71.2.0 ….. 200.71.255.0

Routing table

With CIDR:

200.71.0.0/16

15

Hierarchical addressing: route aggregation

“Send me anything with addresses beginning 200.23.16.0/20”

200.23.16.0/23

200.23.18.0/23

200.23.30.0/23

Fly-By-Night-ISP

Organization 0

Organization 7 Internet

Organization 1

ISPs-R-Us “Send me anything with addresses beginning 199.31.0.0/16”

200.23.20.0/23 Organization 2

. . .

. . .

Hierarchical addressing allows efficient advertisement of routing information:

16

Hierarchical addressing: more specific routes

ISPs-R-Us has a more specific route to Organization 1 Longest prefix match will be used to route IP packets

“Send me anything with addresses beginning 200.23.16.0/20”

200.23.16.0/23

200.23.18.0/23

200.23.30.0/23

Fly-By-Night-ISP

Organization 0

Organization 7 Internet

Organization 1

ISPs-R-Us “Send me anything with addresses beginning 199.31.0.0/16 or 200.23.18.0/23”

200.23.20.0/23 Organization 2

. . .

. . .

5

What’s inside a router

18

What do routers look like?

Access routers e.g. ISDN, ADSL

Core router e.g. OC48c POS

Core ATM switch

19

Basic Components

Control Plane

Datapath” per-packet processing Switching Forwarding

Table

Routing Table

Routing Protocols

20

Forwarding Engine

header payload Packet

Router

Destination Address

Outgoing Port

Dest-network Port Forwarding Table

Routing Lookup Data Structure

65.0.0.0/8 128.9.0.0/16

149.12.0.0/19

3 1

7

6

21

Router Architecture Overview

22

Input Port Functions

Decentralized switching: q queuing: if datagrams arrive

faster than forwarding rate into switch fabric

Physical layer: bit-level reception

Data link layer: e.g., Ethernet see chapter 5

23

Three types of switching fabrics

24

Output Ports

q  Buffering required when datagrams arrive from fabric faster than the transmission rate

q  Scheduling discipline chooses among queued datagrams for transmission

7

25

0 224 232-1

128.9.0.0/16

65.0.0.0

142.12.0.0/19

65.0.0.0/8

65.255.255.255

Example Forwarding Table

Destination IP Prefix Outgoing Port65.0.0.0/8 3

128.9.0.0/16 1

65.0.0.128/25 4

142.12.0.0/19 7

IP prefix: 0-32 bits Longest prefix match

Prefix length

128.9.16.14

26

Longest prefix match q  With CIDR, route entries are prefixes <prefix, CIDR mask> q  Can be aggregated q  We need to find the longest matching prefix that matches

the destination address q  Need to search all prefixes of all length (in order) and

among prefixes of the same length

128.8.0/16

128.8.2/24

192.2.0/16

128.8.0.24128.8.2.128

192.2.2.128

27

Prefixes can Overlap

128.9.16.0/21 128.9.172.0/21

128.9.176.0/24

Routing lookup: Find the longest matching prefix (the most specific route) among all prefixes that match the destination address.

0 232-1

128.9.0.0/16 142.12.0.0/19 65.0.0.0/8

128.9.16.14

Longest matching prefix

28

Key Network-Layer Functions

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

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

v  Routing algorithms

analogy:

q routing: process of planning trip from source to destination

q forwarding: process of getting through single interchange

8

29

1

2 3

0111

value in arriving packet’s header

routing algorithm

local forwarding table header value output link

0100 0101 0111 1001

3 2 2 1

Interplay between routing and forwarding

30

The Internet Network layer

forwarding table

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

Network layer

31

The Internet Protocol (IP) q  Provides delivery of packets from one host to any

other host in the Internet q  Internet packets are called “datagrams” and may

be up to 64 kilobytes in length v  although they are typically much smaller

32

IP datagram format

ver length

32 bits

data (variable length, typically a TCP

or UDP segment)

16-bit identifier header

checksum time to

live

32 bit source IP address

IP protocol version number

header length (bytes)

max number remaining hops

(decremented at each router)

for fragmentation/ reassembly

total datagram length (bytes)

upper layer protocol to deliver payload to

head. len

type of service

“type” of data flgs fragment offset

upper layer

32 bit destination IP address Options (if any) E.g. timestamp,

record route taken, specify list of routers to visit.

how much overhead with TCP?

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

layer overhead

9

33

IP Fragmentation & Reassembly q  network links have MTU

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

different MTUs q  large IP datagram divided

(“fragmented”) within net v  one datagram becomes

several datagrams v  “reassembled” only at final

destination v  IP header bits used to

identify, order related fragments

fragmentation: in: one large datagram out: 3 smaller datagrams

reassembly

34

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 becomes several smaller datagrams

Example q  4000 byte

datagram q  MTU = 1500 bytes

1480 bytes in data field

offset = 1480/8

35

IP Support Protocols q ARP q RARP q ICMP

36

ARP q Address Resolution Protocol q Returns a MAC sublayer address or link

layer address when given an Internet address

q After a packet reaches a router, the link layer header needs to be added to reflect the destination host on that link

q Need IP à MAC address translation

Preamble S D 0x0806 ARP PACKET Type

10

ARP packet format

37

Protocol Type : IPv4 0x0800 Opcode ARP request:0 Opcode ARP reply:1

Source IP address Source MAC address

Destination IP address Destination MAC address

38

ARP (cont’d)

Ethernet Address: 05:23:f4:3d:e1:04

IP Address: 128.195.1.20

Ethernet Address: 98:22:ee:f1:90:1a

IP Address: 128.195.1.38

Ethernet Address: 12:04:2c:6e:11:9c

IP Address: 128.195.1.122

Wants to transmit to 128.195.1.38

ARP

ARP packet containing “128.195.1.38?”

Ignored Answered

Proto=IPv4 0x0800

Sender H/W address Sender IP address

Target H/W address target IP address

Oper=1

39

RARP q Reverse Address Resolution Protocol q RARP performs the inverse action of ARP q RARP returns an IP address for a given

MAC sublayer address q Need MAC address à IP address q Host have no permanent storage q On reboot? Need to figure IP address q Operationally, RARP is the same as ARP

40

ICMP

q Protocol for error detection and reporting •  tightly coupled with IP, unreliable

q ICMP messages delivered in IP packets q ICMP functions:

v Announce network errors v Announce network congestion v Assist trouble shooting v Announce timeouts

11

41

ICMP MSG

IP header Source, Destination Address, TTL, ...

ICMP MSG Message type, Code, Checksum,

Data

IPV4 Header for ICMP

42

1

ICMP header Protocol Field value=1

43 44

ICMP: Internet Control Message Protocol Type Code description 0 0 echo reply (ping) 3 0 dest. network unreachable 3 1 dest host unreachable 3 2 dest protocol unreachable 3 3 dest port unreachable 3 6 dest network unknown 3 7 dest host unknown 4 0 source quench (congestion control - not used) 8 0 echo request (ping) 9 0 route advertisement 10 0 router discovery 11 0 TTL expired 12 0 bad IP header

12

45

Specific uses of ICMP

q Echo request reply v Can be used to check if a host is alive

q Destination unreachable v  Invalid address and/or port

q TTL expired v Routing loops, or too far away

46

Ping q  Uses ICMP echo request/reply q  Source sends ICMP echo request message to the destination

address q  Destination replies with an ICMP echo reply message

containing the data in the original echo request message q  Source can calculate round trip time (RTT) of packets q  If no echo reply comes back then the destination is

unreachable

47

Ping (cont’d)

R1 R2 R3 A B Tim

e

Echo request

Echo reply

48

Traceroute q  Traceroute records the route that packets take q  A clever use of the TTL field q  When a router receives a packet, it decrements TTL q  If TTL=0, it sends an ICMP time exceeded message back to

the sender q  To determine the route, progressively increase TTL

v  Every time an ICMP time exceeded message is received, record the sender’s (router’s) address

v  Repeat until the destination host is reached or an error message occurs

13

49

Traceroute (cont’d)

R1 R2 R3 A B TTL=1, Dest = B, port = invalid

TTL=2, Dest = B

TTL=3, Dest = B

TTL=4, Dest = B

Te (R1)

Te (R2)

Te (R3)

Pu (B)

Time

Te = Time exceeded Pu = Port unreachable

50

Traceroute Examle 1 lcsr-gw (128.6.13.21) 1.206 ms 0.973 ms 0.782 ms 2 rucs-gw (165.230.212.129) 0.697 ms 0.569 ms 0.571 ms 3 transition2-gw (165.230.12.145) 2.786 ms 0.994 ms 0.769 ms 4 rutgers-gw.Rutgers.EDU (198.151.130.209) 1.726 ms 2.048 ms Vl1000-sr02-hil l012-svcs.Rutgers.EDU (198.151.130.14) 1.278 ms 5 rutgers-gw.Rutgers.EDU (198.151.130.209) 1.755 ms 1.241 ms 1.828 ms 6 198.151.130.226 (198.151.130.226) 2.748 ms 3.070 ms 2.640 ms 7 clev-nycm.abilene.ucaid.edu (198.32.8.29) 15.162 ms 14.619 ms 14.663 ms 8 ipls-clev.abilene.ucaid.edu (198.32.8.25) 21.220 ms 22.497 ms 21.450 ms 9 kscy-ipls.abilene.ucaid.edu (198.32.8.5) 30.257 ms 30.604 ms 30.969 ms 10 dnvr-kscy.abilene.ucaid.edu (198.32.8.13) 40.823 ms 41.181 ms 41.076 ms 11 snva-dnvr.abilene.ucaid.edu (198.32.8.1) 65.436 ms 66.068 ms 65.569 ms 12 198.32.249.161 (198.32.249.161) 65.673 ms 65.771 ms 66.006 ms 13 BERK--SUNV.POS.calren2.net (198.32.249.13) 67.183 ms 67.131 ms 66.858 ms 14 pos1-0.inr-000-eva.Berkeley.EDU (128.32.0.89) 67.192 ms 66.749 ms 67.720 ms 15 vlan198.inr-201-eva.Berkeley.EDU (128.32.0.194) 67.373 ms 67.067 ms 67.82 1 ms 16 fast8-0-0.inr-210-cory.Berkeley.EDU (128.32.255.122) 67.634 ms 68.735 ms 68.413 ms 17 GE.cory-gw.EECS.Berkeley.EDU (169.229.1.46) 67.575 ms 68.222 ms 67.772 ms 18 gig8-1.snr1.CS.Berkeley.EDU (169.229.3.66) 67.454 ms 67.988 ms 67.177 ms

19 now.CS.Berkeley.EDU (128.32.44.96) 67.892 ms * 67.818 ms

IP bootstrap & NAT

52

IP addresses: bootStrap?

Q: How does host get IP address? q  hard-coded by system admin in a file

v Wintel: control-panel->network->configuration->tcp/ip->properties

v UNIX: /etc/rc.config q  DHCP: Dynamic Host Configuration Protocol:

dynamically get address from as server v  “plug-and-play”

14

More Internet Protocols DHCP, NAT, IPv6

54

DHCP (Ch 4.4) q  DHCP stands for dynamic host configuration protocol q  DHCP is client-server q  DHCP offers a number of more features

v  Dynamic IP address allocation v  IP addresses can be leased for a certain time v  Useful where there are a limited number of IP addresses v  Useful for temporary connections (testing, laptops, mobile

networks)

55

DHCP (cont’d)

q DHCP has two components: v A protocol for delivering bootstrap information

from the server to the clients v An algorithm for dynamically assigning

addresses to clients

56

Address Allocation Modes

q  DHCP supports three modes of allocation v  Automatic allocation: Server assigns a permanent address

to a host v  Dynamic allocation: Server assigns a host an IP address

with a finite “lease” v  Manual allocation: Server assigns host an IP address

chosen by the network administrator

15

IPV4 Header for DHCP

57

17

Source Port Destination port=67

DHCP PACKET

58

DHCP Packets (cont’d)

Number of seconds Flags

Transaction ID

Request/Reply Hardware type Hardware address length in bytes Hop count

Client hardware address (16 bytes)

Your IP address

Server IP address

Gateway IP address

Server hostname (64 bytes)

Boot filename (128 bytes)

Options (312+ bytes)

Client IP address

0 7 8 15 16 23 24 31

Request=1 Reply=2

59

Definitions of address fields

q  ciaddr Client IP address; only filled in if client is in BOUND, RENEW or REBINDING state and can respond to ARP requests.

q  yiaddr 'your' (client) IP address. The IP address, server is assigning to client

q  siaddr IP address of server to use in the netx step of the bootstrap process; returned in DHCPOFFER, DHCPACK by server.

q  giaddr Relay agent IP address, used in booting via a relay agent.

q  chaddr Client hardware address used for identification.

60

DHCP Packet Fields q  All fields are same as BOOTP except:

v  Flags: One flag currently defined •  Broadcast (bit 0): Clients can request that all DHCP server

messages be broadcast to it v  Options:

•  All DHCP packets must use the “DHCP message type” option, which defines the “type” of DHCP message being sent:

–  1= DHCPDISCOVER –  2= DHCPOFFER –  3= DHCPREQUEST –  4= DHCPDECLINE –  5=DHCPACK –  6=DHCPNACK –  7=DHCP RELEASE –  8=DHCP INFORM

16

61

DHCP Message types

q  DHCP message types v  DHCP Discover: Client broadcasts to locate a server v  DHCP Offer: Server responds with proposal of parameters v  DHCP Request: Client broadcasts its choice of server. All other

servers are implicitly declined. v  DHCP ACK: Selected server responds to client with address v  DHCP NAK: Selected server rejects the client’s request v  DHCP Decline: Client declines server’s parameters v  DHCP Release: Client releases its assigned address

62

DHCP Protocol Server 1 Server 2 Client

DHCPDISCOVER DHCPDISCOVER

DHCPOFFER

DHCPOFFER

DHCPREQUEST DHCPREQUEST

DHCPACK

Collects replies Selects server 2

63

DHCP Protocol (cont’d) q  DHCP client broadcasts a DHCP Discover message

v  Client may specify preference of a lease and/or IP address q  Many servers may respond with offers

v  Client chooses one server from them q  Client broadcasts DHCP request with id of chosen server q  Selected server sends DHCP ACK or NAK q  Client begins using offered IP address once it receives ACK q  If the client finds a problem, it sends a DHCP Decline message to

the server and starts over again q  Client may choose to release the address before lease expires by

sending a DHCP Release message to the server

64

DHCP Relay Agents q  Similar to BOOTP Relay Agents q  DHCP relay agents allow DHCP servers to handle requests

from other subnets

DHCP Relay Agent

Client IP

Gateway Router

IP Gateway Router

DHCP Server

17

65

Summary

q  DHCP allow “ignorant” hosts to receive IP addresses (and more) at start-up time

q  IP addresses don’t have to be manually configured into hosts

66

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 of Internet

All datagrams leaving local network have same single source

NAT IP address: 138.76.29.7, different source port numbers

67

NAT: Network Address Translation

10.0.0.1

10.0.0.2

10.0.0.3

S: 10.0.0.1, 3345 D: 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 table WAN 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, 5001 D: 128.119.40.186, 80 2

2: NAT router changes datagram source addr from 10.0.0.1, 3345 to 138.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 router changes datagram dest addr from 138.76.29.7, 5001 to 10.0.0.1, 3345

68

NAT: Network Address Translation

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

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

without notifying outside world v  can change ISP without changing addresses of

devices in local network v devices inside local net not explicitly addressable,

visible by outside world (a security plus).

18

69

NAT: Network Address Translation

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

LAN-side address! q NAT is controversial:

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

•  NAT possibility must be taken into account by app designers, eg, P2P applications

v  address shortage should instead be solved by IPv6

70

Recent Developments: IPv6

q IPv4 (the standard IP protocol) has limited address space

q Most importantly, IP is running out of addresses. 32 bits are not enough.

q Real-time traffic and mobile users are also becoming more common

IP version 6 (Also called IPng, or IP next generation)

71

IPv6: The Changes

l  Large address space: l  128-bit addresses (16 bytes) l  Allows up to

340,282,366,920,938,463,463,374,607,431,768,211,456 unique addresses (3.4 x 10 38 )

l  Fixed length headers (40 bytes) l  Improves the speed of packet processing in routers

72

IPv6 header

l  40 bytes header l  Version field set to 6 l  PayloadLen field gives the length in bytes of the packet

excluding the header l  Next Header value specifies the type of next header (if

any ) that follows the IPv6 header 6 Is TCP , 17 is UDP

Source Address

Version (4) Traffic Class (8) Flow Label (20)

PayloadLen (16) Next Header (8) Hop Limit (8)

Destination Address

4 bytes

4

16

16

19

73

IPv6: The Changes (cont’d)

q Support for “flows” v  Flows help support real-time service in the Internet v  A “flow” is a number in the IPv6 header that can be

used by routers to see which packets belong to the same stream

v  Guarantees can then be assigned to certain flows v  Example:

•  Packets from flow 10 should receive rapid delivery •  Packets from flow 12 should receive reliable

delivery

IPv6 Addresses l  Classless addressing/routing (similar to CIDR) l  Notation: x:x:x:x:x:x:x:x (x = 16-bit hex

number) l  contiguous 0s are compressed: 47CD::A456:0124 l  IPv6 compatible IPv4 address: ::128.64.18.87

l First 96 bits are 0 l  Global unicast addresses start with 001…. l  2000::/3 prefix