Types of Service (TOS) The IPv4 Datagram. Fragmentation. Fragmentation Example

The IPv4 Datagram 4 bits 4 bits vers 8 bits HLen 32 bits 3 bits TOS (x32b) ID Hop count TTL Types of Service (TOS) 13 bits Offset within or...
Author: Hugh Allison
261 downloads 0 Views 464KB Size
The IPv4 Datagram 4 bits 4 bits vers

8 bits

HLen

32 bits 3 bits

TOS

(x32b)

ID

Hop count

TTL

Types of Service (TOS)

13 bits

Offset within original packet

Datagram Length (bytes) FRAG Offset

Flags

Protocol

checksum

source IP Address

255 hosts. But there are only 16K Class B network IDs.  Wastage and shortage of addresses!

 Organizations with internal routers need to have a separate network ID for each link.  Every router must know about every network ID in every organization  large address tables.

Patt-Shamir Lecture 9 16

Patt-Shamir Lecture 9 15

IP Addressing Hence, two solutions: Subnetting: subdivide a network ID hierarchically (used within an organization). A hack on top of the class system Classless Interdomain Routing (CIDR, “supernetting”): Forget classes. Network ID can be any prefix of the IP address. Patt-Shamir Lecture 9 17

Subnetting CLASS “B” e.g. Company

e.g. Site

2

10

2

• Representation: an address + a bitmask.

Host-ID

Net ID

– Mask 0xffff0000 (or 255.255.0.0): the first 16 bits are the subnet ID, and the last 16 bits are the host ID. 16

14

Net ID

• Subnetting is a form of hierarchical routing.

16

14

10

Subnetting

0000

Subnet ID (20)

2

Host-ID

16

14

10

1111

Net ID

Subnet ID (20)

Subnet Host ID (12)

Host-ID Subnet Host ID (12)

• Advantage: allows for the flexible partition of large networks (typically, type B). • Shortcoming:

e.g. Dept

2

10

16

14

Net ID

Subnet ID (22)

000000

2

Subnet Host ID (10)

– must be configured in each host with its IP address

16

14

10

Host-ID

Net ID

1111011011

Subnet ID (26)

Host-ID Subnet Host ID (6)

– subnet is still part of its parent network: switching ISP  IP addresses will change.

Patt-Shamir Lecture 9 18

Patt-Shamir Lecture 9 19

CIDR Addressing

CIDR Addressing

Classless InterDomain Routing  IP address space broken into intervals of length 2k for an integer k≥0, aligned.  Representation: the common prefix. Denoted x/y, meaning y first bits of x.  Example: 128.9/16 represents the addresses in the interval [128.9.0.0 … 128.9.255.255]. 128.9.0.0 65/8

0

128.9.16.14

142.12/19

128.9.25/24 128.9.16/20 128.9.176/20 128.9/16

0

232-1

128.9.16.14

128.9/16

216

128.9.19/24

Intervals may overlap! Rule: prefer the “longest matching prefix”

232-1

Patt-Shamir Lecture 9 20

Patt-Shamir Lecture 9 21

IPv6 addresses

CIDR Addressing Prefix aggregation: If a service provider serves two organizations with prefixes, it can aggregate them to form a larger prefix (when?).  Reduces size of routing tables.  E.g. ISP serves 128.9.14.0/24 and 128.9.15.0/24, it can tell other routers to send it all packets belonging to the prefix 128.9.14.0/23.

ISP Choice:  In principle, an organization can keep its prefix if it changes service providers.

• Motivation: too few 32-bit addresses, more functionality required. • new addresses: 128 bits (!) – X:X:X:X:X:X:X:X where X is 4 hexadecimals – structured hierarchy: 13, 24, 16, 64 bits (last is interface ID). 3 bits identify type, 8 reserved – new “anycast” address: route to “best” of several replicated servers – Can embed IPv4 addresses

• Penetration is slow... but used in China! Patt-Shamir Lecture 9 22

Patt-Shamir Lecture 9 23

Inside a Router 1.

Forwarding in Routers

Forwarding Table

2.

3. Output Scheduling

Interconnect

Forwarding Decision Forwarding Table

Forwarding Decision Forwarding Table

Forwarding Decision Patt-Shamir Lecture 8 24

Patt-Shamir Lecture 8 25

Forwarding in an IP Router

Routing Tables at a router 128.17.20.1

• Lookup packet DA in forwarding table.

e.g. 128.9.16.14 => Port 2 R2

– If known, forward to correct port. – If unknown (in particular: no default router), drop packet.

• Decrement TTL, update header Checksum. • Forward packet to outgoing interface. • Transmit packet onto link.

1 R1 2 3

R3

R4

Prefix

Next-hop

Port

65/8 128.9/16 128.9.16/20 128.9.19/24 128.9.25/24 128.9.176/20 142.12/19

128.17.16.1 128.17.14.1 128.17.14.1 128.17.10.1 128.17.14.1 128.17.20.1 128.17.16.1

3 2 2 7 2 1 3

128.17.16.1 Forwarding/routing table

Question: How is the address looked up in a real router?

Routing table must know next hop for every network on the Internet!

Patt-Shamir Lecture 8 26

Core Router Table Size

Patt-Shamir Lecture 8 27

Required Lookup Performance Line

Line Rate

Pktsize=40B

Pktsize=240B

T1

1.5Mbps

4.68 Kpps

0.78 Kpps

OC3

155Mbps

480 Kpps

80 Kpps

OC12

622Mbps

1.94 Mpps

323 Kpps

OC48

2.5Gbps

7.81 Mpps

1.3 Mpps

OC192

10 Gbps

31.25 Mpps

5.21 Mpps

source: http://bgp.potaroo.net/

Patt-Shamir Lecture 8 28

Patt-Shamir Lecture 8 29

Finding next hop in Class-based addressing

Routing table Structure

IP Address Space Class A

Class B

Class C

Class A Class B

212.17.9.4

Class C

D

Routing Table: Exact Match

212.17.9.0

212.17.9.0 Port 4

Exact Match: There are many well-known ways to find an exact match in a table. Patt-Shamir Lecture 8 30

Patt-Shamir Lecture 8 31

Associative Lookups

Direct Lookup

“Contents addressable memory” (CAM)

Advantages: IP Address

Memory

• Simple

Associative Memory or CAM

Next-hop, Port Search Data 32

Network Address

Port Number

Disadvantages Port Number

Hit?

• High Power • Small • Expensive

Problem: With 232 addresses, the memory would require 4 billion entries. Patt-Shamir Lecture 8 32

Patt-Shamir Lecture 8 33

Lookups Using Hashing

Hashed Lookups

An example Memory

Hash Function

16

Memory

Data

32

#1

Associated Data

Address

Search Data

{

Search Data

Hit?

Address

Hashing Function

32

log2N

16

Linked list of entries with same hash key.

#2

#3

#4 Associated Data

#1

#2

#1

#2

Hit?

#3

Patt-Shamir Lecture 8 34

Patt-Shamir Lecture 8 35

Lookups Using Hashing

Classless Addressing: CIDR 128.9.19/24

Advantages:

128.9.25/24

• Simple

128.9.16/20 128.9.176/20

• Expected lookup time can be small

128.9/16

0

Disadvantage • Non-deterministic lookup time

128.9.16.14

232-1

Most specific route = “longest matching prefix”

Problem: How can we look up addresses if they are not an exact match? Patt-Shamir Lecture 8 36

Patt-Shamir Lecture 8 37

Trees and Tries

Ternary CAMs: CAMs with *’s Associative Memory Value

Binary Search Tree: Port

10.1.1.32

255.255.255.255

1

10.1.1.0

255.255.255.0

2

10.1.3.0

255.255.255.0

3

10.1.0.0

255.255.0.0

4

10.0.0.0

255.0.0.0

4







0

Patt-Shamir Lecture 8 38

16-ary Search Trie

0

1111, ptr 0000, 0

1

1111, ptr

f

d 000011110000

111

Longest prefix matches using Binary Tries

Multiway tries reduce the number of memory references

1111, ptr

1

Patt-Shamir Lecture 8 39

Search Tries

0000, 0

0

Requires 32 memory references, regardless of number of addresses.

Note: Most specific routes appear closest to top of table

0000, ptr

1

010

N entries

Priority Encoder

1

111111111111

e

• Each node has 16 children, but only children that lead to an existing leaf are non-NULL. • Why not keep increasing the degree of the trie?

g h

i

Example Prefixes: a) 00001 b) 00010 c) 00011 d) 001 e) 0101 f) 011 g) 100 h) 1010 i) 1100 j) 11110000

abc Patt-Shamir Lecture 8 40

j

Patt-Shamir Lecture 8 41

Patricia Tries 0

1

f

d e

g h

i

Example Prefixes: a) 00001 b) 00010 c) 00011 d) 001 Skip 5 e) 0101 f) 011 j g) 100 h) 1010 i) 1100 j) 11110000

IP helpers

abc Patt-Shamir Lecture 8 42

DHCP

NAT

Dynamic Host Configuration Protocol

Network Address Translation

Goal: dynamically obtain an IP address from network server – Can renew its lease on address in use – Allows reuse of addresses – Support for mobile users DHCP overview: – host broadcasts “DHCP discover” msg – DHCP server responds with “DHCP offer” msg – host requests IP address: “DHCP request” msg – DHCP server sends address: “DHCP ack” msg

rest of Internet

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

10.0.0.4 138.76.29.7

10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 NAT reserved

10.0.0.1 10.0.0.2 10.0.0.3

All datagrams leaving local network have same single source NAT IP address: 138.76.29.7 and different source port numbers

Patt-Shamir Lecture 9 44

Datagrams with source or destination in this network have 10.0.0/24 address for source, destination (as usual)

Patt-Shamir Lecture 9 45

NAT idea

NAT properties

• Use one of three reserved blocks for all internal IP addresses – (10/8, 172.16/12, 192.168/16)

• Within internal network—all as before • Connections going outside are translated by the NAT server that keeps the translation table – Use transport level IDs (port numbers).

• Allow a complete IP network to have one external IP address • Can change internal addresses without notifying outside world • Can change external address (e.g., ISP) without notifying internal devices • devices inside local net not directly visible or reachable by outside world (good security, bad flexibility).

Patt-Shamir Lecture 9 46

Patt-Shamir Lecture 9 47

3 Addressing Schemes • Domain names: application level

DNS & ARP

• IP addresses: network level

• MAC: Data link (LAN) level

www.tau.ac.il

132.66.16.6

E6-E9-00-17-BB-4B Patt-Shamir Lecture 9 48

Patt-Shamir Lecture 9 49

Address Translation

DNS: Domain Name System

Hostname (bakara.eng.tau.ac.il)

• Distributed database: a hierarchy of many name servers.

DNS

– Supports both queries (domain name ↔ IP address), and updates. Hierarchical authority, hierarchical queries

IP address (132.66.48.12)

• Application-layer protocol: host, routers, name servers communicate to resolve names

ARP

– core Internet function implemented as application-layer protocol! – This is a function for users (not only humans, though)

MAC address (80:20:9A:3A:99)

Note: routers don’t maintain any DNS-related info Patt-Shamir Lecture 9 50

DNS: Root name servers • contacted by local name server when can’t resolve name • root name server: – contacts authoritative name server if name mapping not known – gets mapping – returns mapping to local name server • 13 root entities, ~300 servers

Patt-Shamir Lecture 9 51

Simplified DNS example root name server

source: root-servers.org

host surf.eurecom.fr wants IP address of gaia.cs.umass.edu 2 1. Contacts its local DNS server, 5 dns.eurecom.fr 2. dns.eurecom.fr contacts root name server, if necessary local name server 3. root name server contacts dns.eurecom.fr authoritative name server, 1 6 dns.umass.edu, if necessary requesting host

Patt-Shamir Lecture 9 52

surf.eurecom.fr

4 3

authorititive name server dns.umass.edu

gaia.cs.umass.edu Patt-Shamir Lecture 9 53

ARP

DNS: iterated queries recursive query: •



puts burden of name resolution on contacted name server heavy load?

iterated query: •



contacted server replies with name of server to contact “I don’t know this name, but ask this server”

Address Resolution Protocol root name server

iterated query 2

3 4 7

local name server dns.eurecom.fr

1

8

requesting host

intermediate name server dns.umass.edu

5

6

authoritative name server dns.cs.umass.edu

• MAC address ↔ IP address • Each IP node (Host, Router) on the LAN has ARP module and Table • ARP Table: IP/MAC address mappings for some LAN nodes < IP address; MAC address; TTL> < ………………………….. > • TTL (Time To Live): timer, typically 10’s of minutes

surf.eurecom.fr gaia.cs.umass.edu

Patt-Shamir Lecture 9 55

IP Forwarding Decision

ARP (more) Host A wants to send packet to destination IP addr XYZ on same LAN • By subnet mask, knows that on same LAN  go to local ARP • ARP looks in its cache for IP addr XYZ; if found  done. • Otherwise, ARP module broadcasts ARP pkt “who is XYZ?” • ALL nodes on the LAN accept and inspect the ARP pkt • Node XYZ responds with unicast ARP pkt to A: < XYZ, MAC (XYZ) > • All nodes store MAC address in their local ARP cache • Entries expire after a few minutes Patt-Shamir Lecture 9 56

1. Given a packet: determine the network prefix of the destination in the packet (CIDR!) 2. Is the destination is on the same network?  Decide by own IP address, destination IP address and subnet mask

3. If yes, immediate destination = final destination 4. Else, use routing table to find immediate destination ( which is a router) 5. Use ARP to find datalink (MAC) address 6. Send packet over to datalink immediate destination

Patt-Shamir Lecture 9 57