IP Service IP Addressing Datagram Format Routing (Forwarding) Subnetting Fragmentation

41
© Jörg Liebeherr (modified by M. Veeraraghavan) 1 • IP Service • IP Addressing • Datagram Format • Routing (Forwarding) • Subnetting • Fragmentation

description

IP - Internet Protocol. IP Service IP Addressing Datagram Format Routing (Forwarding) Subnetting Fragmentation. Orientation. IP (Internet Protocol) is a Network Layer Protocol. IP’s current version is Version 4 (IPv4). It is specified in RFC 891. Orientation. - PowerPoint PPT Presentation

Transcript of IP Service IP Addressing Datagram Format Routing (Forwarding) Subnetting Fragmentation

Page 1: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan) 1

• IP Service

• IP Addressing

• Datagram Format

• Routing (Forwarding)

• Subnetting

• Fragmentation

Page 2: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)2

• IP (Internet Protocol) is a Network Layer Protocol.

• IP’s current version is Version 4 (IPv4). It is specified in RFC 891.

NetworkLayer

Link Layer

IP

ARPNetworkAccess

RARP

Media

ICMP IGMP

TransportLayer

TCP UDP

Orientation

Page 3: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)3

Orientation

• IP layer processing occurs at both routers and hosts:

Application

TCP

IP

NetworkAccess

Application

TCP

IP

NetworkAccess

Application protocol

TCP protocol

IP protocol IP protocol

DataLink

NetworkAccess

IP

NetworkAccess

NetworkAccess

IP

NetworkAccess

DataLink

DataLink

IP protocol

RouterRouter HostHost

Page 4: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)4

IP Service

• IP provides an unreliable and connectionless service (“datagram service”).

Unreliable: IP does not guarantee that a transmitted packet will be delivered.

Connectionless: Each packet (“datagram”) is handled independently. IP is not aware

that packets between hosts may be sent in a logical sequence.

• Consequences of an unreliable, connectionless service– Lost packets– Packets delivered out-of-sequence– Can have duplicate packets because of TCP layer resends*

• e.g. if packet is delivered but ACK is lost, TCP sender will resend packet buffered at the end host.

*: The audio file says duplicate packets could occur because of router-buffered packets; this is not commonplace in today’s networks because common link-layer protocols do not have retransmissions, but if they did, this could be another cause of duplicate packets; for example, 802.11 wireless link layer has retransmissions.

Page 5: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)5

IP Service

• IP offers a best effort * service;i.e., IP does not make performance guarantees on:

• the time until a packet is delivered• the packet loss rate• the throughput of traffic between two hosts• etc.

• Performance guarantees are also called Quality-of-Service or QoS guarantees.

• IP provides limited QoS support. This is done via the Type-of-Service (TOS) field.

* “Best effort” may mean different things to different people.

Page 6: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)6

• IP supports the following services:• one-to-one (unicast)• one-to-many (multicast)• one-to-all (broadcast)

• IP multicast actually supports a many-to-many service.

• IP multicast requires support of other protocols (IGMP, multicast routing).

IP Service

Unicast Broadcast Multicast

Page 7: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)7

Internet Addresses

• Each network interface on the Internet as a unique global address, called the IP address.

• An IP address:

- is 32 bits long.

- encodes a network number and a host number

• IP addresses are written in a dotted decimal notation :

- 128.238.42.112 means 10000000 in 1st Byte11101110 in 2nd Byte00101010 in 3rd Byte 01110000 in 4th Byte

Page 8: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)8

Internet Address Classes

• IP distinguishes 5 classes of addresses.

1

Class A

1 1 1 0

0 network id

7 bits

host

24 bits

Class B 1 network id

14 bits

host

16 bits

0

Class C 1 network id

21 bits

01 host

8 bits

Class D 1 multicast group id28 bits

01 1

Class E (reserved for future use)27 bits

Page 9: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)9

IP Addresses

• The end points of each range are not allowed because all zeros and all ones are disallowed for netid, subnetid and hostid (see pg. 42 of text and RFC791).

Class From To

A 0.0.0.0 127.255.255.255

B 128.0.0.0 191.255.255.255

C 192.0.0.0 223.255.255.255

D 224.0.0.0 239.255.255.255

E 240.0.0.0 247.255.255.255

Page 10: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)10

Trade-off of Address Classes

• There are a total of 232 = 4,294,967,296 IP addresses

Class A: 7 bits for netid

only 128 Class A networkseach net can have about 16 million (224-2) hosts.

Class B:14 bits for netid

about 16,000 networksAbout 65,000 (216 -2) hosts per network

Class C:21 bits for netid

about 2 million networksOnly 254 hosts per network

Page 11: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)11

Special case IP addresses (not complete)

• 0: all zeros (means “this host” or “this net”); -1: all ones (this is reserved for broadcasts); netid, subnetid, hostid: anything else

IP address Can appear as

netID subnetID hostID Source? Destination?

Description

0 0 OK never This host on this net

0 hostid OK never Specified host on this net

127 anything OK OK Loopback address

-1 -1 never OK Limited broadcast

netid -1 never OK Net-directed broadcast tonetid

netid subnetid -1 never OK Subnet-directed broadcastto netid, subnetid

netid -1 -1 never OK All-subnets-directedbroadcast to netid

Page 12: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)12

• 20 bytes Header Size 24 * 32 bit-words = 60 bytes

• 20 bytes Total Length 216 bytes = 65536 bytes

IP Datagram Format

version(4 bits)

headerlength

Type of Service/TOS(8 bits)

Total Length (in bytes)(16 bits)

Identification (16 bits)flags

(3 bits)Fragment Offset (13 bits)

Source IP address (32 bits)

Destination IP address (32 bits)

Options (if any, <=40 bytes)

DATA

>= five 32-bit words

32-bit word0 31

TTL Time-to-Live(8 bits)

Protocol(8 bits)

Header Checksum (16 bits)

Page 13: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)13

IP Datagram Transmission

• Question: If you measure an IP datagram on the network, in which order are the fields transmitted?

• Answer: • Transmission is row by row• For each row:

1. Transmit bits 0-72. Transmit bits 8-153. Transmit bits 16-234. Transmit bits 24-31

• This is called network byte order or big endian byte ordering.

• Note: some computers store 32-bit words in little endian format. Which

ones?

Page 14: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)14

Fields of the IP Header

• Version: current version is 4, next version will be 6.

• Header length (4 bits): Number of 32-bit words in the IP header

• Type of Service (TOS): contains 4 TOS bits, where each bit indicates a desired service.

• minimize delay • maximize throughput• maximize reliability• minimize cost

– Only one bit can be set! Not supported in all applications.

Page 15: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)15

IP Header Fields Contd.

• Total Length: Number of bytes in the IP datagram (header+payload)

• Identification: unique identification of a datagram from a host. Incremented whenever a datagram is transmitted.

• Flags and Fragment Offset: Associated with fragmentation

• Time To Live (TTL): specifies longest path before datagram is dropped.– Used to prevent infinite looping of packets– TTL field is set at sending host and is decremented by 1 at each router– If a router gets a datagram whose TTL is either 0 or 1, the router will

drop the packet.– If a destination host gets a datagram whose TTL is 1, the host will

deliver the datagram to the higher layer.

Page 16: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)16

Fields of the IP Header

• Protocol: Specifies the higher-layer protocol.Used for demultiplexing to higher layers.

• Header checksum: verifies correctness of header.

IP

ICMP IGMP

TCP UDP

Application

Page 17: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)17

Fields of the IP Header

• Source and Destination Addresses: identify the interfaces on the sending and receiving hosts

• Options: • Security restrictions• Record Route: each router that processes the packet adds its IP

address to the header. • Timestamp: each router that processes the packet adds its IP

address and time to the header. • (loose) Source Routing: specifies a list of routers that must be

traversed.

• (strict) Source Routing: specifies a list of the only routers that can be traversed.

• Padding: ensures that header ends on a 4-byte boundary

Page 18: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)18

Routing

• The routing functions at the network layer must be able to deliver a packet from a source host to a destination host.

• There are two parts to the routing problem:

1. How to pass a packet from an input interface to the output interface of a router (“packet forwar-

ding”) ?

2. How to create routing tables?

• In this lecture, we only discuss the packet forwarding part. The other function is discussed in Lecture 6.

Page 19: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)19

Major Tenets for Datagram Forwarding

• Every IP datagram contains the IP address of an interface of a destination host.

• The network id of an IP address uniquely identifies a single physical network that is part of the larger Internet.

• All hosts and routers that have the same network id are connected to the same physical network and can directly communicate by sending MAC layer frames.

• Every physical network of the Internet has at least one router, which is also connected to at least one other physical network.

Page 20: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)20

• A packet is typically forwarded to a large number of routers before reaching the destination host.

• IP forwarding is done on a hop-by-hop basis, i.e., no one knows the complete route. The goal of forwarding is to bring the IP datagram closer to the destination.

IP Forwarding

Page 21: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)21

IP Forwarding

• IP forwarding is performed by both hosts and routers.

• The difference between IP forwarding in a host and in a router is that a host’s IP module does not forward packets received on an interface to another interface (if it does then it is behaving as a router). In a host, IP forwarding is from the higher layers to an interface or vice versa

• Both routers and hosts have a routing table. Routing table entries look like this and is looked up for each datagram:

DestinationIP address

IP address ofNext-Hop-Router

Flags Specificationof an interface

Whole IPaddress ornetwork ID ofIP address

Address of routerinterface or directlyconnected network

Interface to whichthe datagram ispassed

Page 22: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)22

Flags

• H: Whether the destination address is the network ID of an IP address (H=0) or the complete IP address of a host interface (H=1).

• G: Whether the next-hop router field is really a next-hop router (G=1) or a directly connected interface (G=0)

Page 23: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)23

Forwarding Functions at Host

• Forwarding an IP datagram at a host:DestNet = Network id in destination IP address If (DestNet == my Network id)

Deliver datagram to destination directly;else

Send datagram to default router;

• Reception of an IP datagram at a host:Datagram is received on an interfaceIf (Destination IP address == (my IP address || broadcast address))

Deliver datagram to higher layer;else

Discard the datagram;

Page 24: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)24

Forwarding Functions at Router

• Reception of an IP datagram at a router:Packet is received on an interfaceIf (Destination IP address != my IP address)

Perform datagram forwarding;

• Forwarding an IP datagram at a router:DestNet = Network id in destination IP addressDestIP = destination IP addressIf (DestIP == Destination IP address in my routing table)

Deliver datagram to the next-hop-router in the table;elseif (DestNet == Network id in my routing table)

Deliver datagram to destination of the interface;else

deliver packet to default router;

Page 25: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)25

Example (from Textbook)

Gateway netb

modem modem

sun bsdi

140.252.13.0140.252.1.0

ftp.uu.net192.48.96.9

140.252.13.33140.252.1.183140.252.13.35140.252.1.29

140.252.1.4140.252.104.1

• Scenario 1: bsdi sends a datagram to sun

• Scenario 2: bsdi sends a datagram to ftp.uu.net

Page 26: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)26

Scenario 1

• Bsdi looks up its routing table and finds sun as being located on the same network. • How ? The network address of sun and bsdi match.•Bsdi issues an ARP request for 140.252.13.33•Sun replies with the MAC address for its interface•Bsdi can then send the IP datagram encapsulated in an ethernet frame

sun bsdi

140.252.13.0

140.252.13.33 140.252.13.35

Page 27: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)27

Scenario 2

• bsdi sends a datagram to ftp.uu.net.

1. bsdi sees that its network ID differs from that of the destination address

2. So it sends the datagram to its default router (sun) (by using the MAC address of the 140.252.13.33 interface on sun - obtained by ARP)

Gateway netb

modem modem

sun bsdi

140.252.13.0140.252.1.0

ftp.uu.net192.48.96.9

140.252.13.33140.252.1.183140.252.13.35140.252.1.29

140.252.1.4140.252.104.1

Page 28: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)28

Scenario 2, Part II

3. sun (is configured as router) forwards the packet to its default router (which is set to netb).

4. netb forwards the datagram to its default next-hop-router, set to Gateway (140.252.1.4).

5. Gateway forwards the packet to somewhere else (not known).

Gateway netb

modem modem

sun bsdi

140.252.13.0140.252.1.0

ftp.uu.net192.48.96.9

140.252.13.33140.252.1.183140.252.13.35140.252.1.29

140.252.1.4140.252.104.1

Page 29: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)29

Subnetting

• The address classes makes Class A and B addresses very attractive and Class C addresses not attractive:

- The number of network id’s relates to the size of the routing table in IP routers.

- The number of hosts on a network is limited to 255.

- Organization must contact IANA for each new LAN.

- Management of a large number of Class C addresses is cumbersome.

• But: There are only few Class A and B addresses!

• Solution: Subnetting

Page 30: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)30

Subnetting

• Goal: Reduce the need for a large number of network ids.

• Basic Idea:

- Split the host id portion of an IP address into a subnet id and a host id.

- Assign one subnet id to each physical network.

• Then: • Subnets can be freely assigned and be used for many

physical networks.• Distant routers need not be aware of subnet id’s.

Page 31: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)31

• Routers and hosts use a subnet mask to separate the subnetwork id from the host id.

Class B 1 network id

14 bits

host

16 bits

0

withsubnetting 1

8 bits

0 host8 bits

Subnetmask(255.255.255.0)

24 bits

network id14 bits

subnet id

00000000111111111111111111111111

8 bits

Subnet Masks

Question: In the IP address 152.164.9.10 with subnet mask 255.255.255.128, what class does this IP address belong to and what are the 14 bits netid, subnet id and hostid? How many bits are in the subnet id and in the hostid?Answer: Class B; 14 bits netid = 24.164, subnet id (9 bits) = 9.0 hostid (7 bits) = 10

Page 32: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)32

Subnetting: Host Processing

• Each host has to know the IP address and the subnet mask of its interface

• For each IP datagram received from the application, the IP layer at the host peforms:

if ((Destination IP address & Subnet Mask) == (My IP address & Subnet Mask))

Deliver datagram directly (perform ARP if shared medium LAN);

else Forward datagram to default router;

Page 33: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)33

Subnetting: Router Processing

• A router has a table:

< SubnetNumber, SubnetMask, NextHop> » SubnetNumber is the <network id, subnet id>» SubnetMask is the subnet mask» NextHop is the IP address of a router.

• The router perfoms the following algorithm: – Reception of an IP datagram at a router:

Packet is received on an interface whose IP address is IP1.

dest = destination IP address; If (dest == IP1)

Deliver datagram to TL/application in router ;

Page 34: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)34

Subnetting: Router processing Contd.

Else for each entry <SubnetNumber, SubnetMask, NextHop>

sub1 = dest & SubnetMask;if (sub1 == SubnetNumber) Forward datagram to NextHop;

else Go to next entry in routing table;

Page 35: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)35

Advantages of Subnetting

• Improves efficiency of IP address usage by not consuming an entire Class B or Class C address for each physical network.

• Reduces routing table sizes. Since external routers do not know about subnetting, the size of routing tables is reduced.

• Networks become easier to manage.

• Note that there are three levels of aggregation:• Network• Subnet• Host

Page 36: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)36

IP Fragmentation

FDDIRing

RouterHost A Host B

Ethernet

• Host A sends a large IP datagram to Host B.

• Any Problem with that?

MTUs: FDDI: 4352 Ethernet: 1500

• IP router splits the datagram into several fragments• Fragmentation requires that the data portion of every fragment except the last be a multiple of 8 bytes.

Page 37: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)37

Where is Fragmentation done?

• Fragmentation can be done at the sender or at intermediate routers.

• The same datagram can be fragmented several times.• Reassembly of original datagram is only done at

destination hosts.

Router

IP datagram H Fragment 1 H1Fragment 2 H2

Page 38: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)38

What’s involved in Fragmentation?

• The following fields in the IP header are involved:

version(4 bits)

headerlength

Type of Service/TOS Total Length (in bytes)

Identificationflags

Fragment Offset

......

TTL Time-to-Live(8 bits)

Protocol(8 bits)

Header Checksum (16 bits)

Identification is the same in all fragments.Flags contains a “more fragments” bit.

(There is also a “don’t fragment bit” that can be set).

Fragment offset contains the offset (in 8-byte units) ofcurrent fragment in the original datagram.

Total length is changed to be the size of the fragment.

Page 39: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)39

Multiple links

• The ID field stays the same for all fragments of a datagram sent by a sender to allow for reassembly

• The fragment offset is relative to the datagram sent by the sender.

• Two fragments created on X.25 link (offsets 0, 69)– 576 – 20 (IP header) = 556; 552 divides by 8 as 69.

• Each is fragmented further on the PPP link– ID stays the same on all fragments– Fragment offset on the second set of fragments is relative to the

original (0, 34, 68, 69, 103)• 296-20=276; 272/8 = 34

Router1

Router2

X.25(MTU=576)

PPP(MTU=296)

IP datagram sent has apayload of 1000 bytes

Page 40: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)40

Configuring a Network Interface

• The ifconfig command is used for setting and testing network interfaces (in Unix systems) that run TCP/IP

• Ifconfig must be run at boot time to initialize the network interfaces.

• Ifconfig -a plots a report on all interfaces.

: aida:/ ; ifconfig -aed1: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX, MULTICAST> mtu 1500 inet 128.238.42.114 netmask 0xffffff00 broadcast

128.238.42.255lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 inet 127.0.0.1 netmask 0xff000000

Page 41: IP Service  IP Addressing  Datagram Format  Routing (Forwarding)  Subnetting  Fragmentation

© Jörg Liebeherr (modified by M. Veeraraghavan)41

Configuring a Network Interface

• The netstat command plots (a lot of) network related data structures in the operating system.

• Netstat -i plots information on the network interfaces.

: aida:/ ; netstat -i Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Colled1 1500 128.238.42.114 aida 2394482 35664 346880 223 119591lo0 16384 your-net localhost 153 0 153 0 0