50
1 The Network Layer

The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

  • Upload
    dotu

  • View
    218

  • Download
    2

Embed Size (px)

Citation preview

Page 1: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

1

The Network Layer

Page 2: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

2

Network Layer

Recall:The network layer is responsible for the routing of packetsThe network layer is responsible for congestion control

Page 3: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

3

Contents

Connection-Oriented (virtual circuit) and Connectionless Service (datagram service)The IP ProtocolIP-Support ProtocolsRouting AlgorithmsCongestion Control

Page 4: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

4

4.1.1 Connection-Oriented and Connectionless Service

Network layers can offer two types of service to the transport layer:

Connection-oriented service (virtual circuit)– Connection setup required before communication begins– Network layer provides the Transport layer with a reliable

service: in-sequence delivery, flow control

Connectionless service (datagram service)– No prior connection setup required– Packets are stored and forwarded one at a time by IMPs

Page 5: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

5

4.1.1 Connection-Oriented Service

How to provide connection-oriented service:Set up a route (virtual circuit) between source and destinationThat route is used for all traffic flowing over the virtual circuitSwitch maintains an internal table to tell which outgoing line to forward packet on for each active virtual circuitPackets must contain a virtual circuit number so that the switch can figure out how to forward them

Page 6: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

6

Connection-Oriented Service: Analogy

Public Telephone NetworkSet up a virtual circuit (dial a number)Transmit data on the circuit (conversation)Close down the virtual circuit (hang up)

Two users are provided with the illusion of a dedicated point-to-point channelInformation is delivered to the receiver in the same order in which it is transmitted by the sender

Page 7: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

7

Connectionless Service

How to provide connectionless service:Send the packet into the network and allow the network to forward it however it likesSwitches maintain routing tables to look up the next switch for each arriving packetEach packet must contain a destination address so the switches can make routing decisions

Page 8: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

8

Connectionless Service: An Analogy

Postal service:Each packet (letter) is transported as an individual entityEach packet (letter) must carry the complete destination addressIf a packet (letter) is lost, error control is the user’s responsibilityPackets (letters) do not necessarily arrive in the order sent

Page 9: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

9

4.1.2 Comparison between Connectionless and Connection-Oriented Services

Connection Setup Procedure:Connection-oriented service

– Explicit setup and tear-down required– For short transaction oriented communication,

the delay of connection setup may be expensiveConnectionless service

– No setup or tear-down required– For long continuous communication, the

overhead of packet headers may be expensive

Page 10: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

10

Comparison (cont’d)

Header OverheadConnection-oriented service

– Only the virtual circuit numberConnectionless service

– The full destination address is required

Page 11: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

11

Comparison (cont’d)

Message Sequence:Connection-oriented service

– Sequence of packets automatically maintainedConnectionless service

– Destination may have to re-sequence out-of-order packets

Page 12: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

12

Comparison (cont’d)

RobustnessConnection-oriented service

– Vulnerable: If a switch crashes, all virtual circuits passing through it have to be aborted and re-established

Connectionless service– Robust: If a router goes down, only hosts

whose packets were queued at the time of the crash are lost. Other packets will be rerouted dynamically.

Page 13: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

13

Comparison (cont’d)

Guaranteed service:Connection-oriented service

– Can provide guarantees on the delays and throughput of packets being sent

Connectionless service– It is very difficult to provide guarantees for

timely packet delivery

Page 14: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

14

Summary

Connection-oriented service– Is useful for applications which prefer in-

sequence delivery of packets. It is also preferable for applications that require guaranteed service

Connectionless service– Provides flexibility in the routing and handling of

individual packets and is robust in the face of router crashes

Page 15: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

15

4.4 The Internet Protocol (IP)

Provides delivery of packets from one host in the Internet to any other host in the Internet, even if the hosts are on different networksInternet packets are called “datagrams” and may be up to 64 kilobytes in length (although they are typically much smaller)Internet IMPs are known as “routers” and they operate in a connectionless mode

Page 16: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

16

Identification

4.4.1 IP Packet Format

Ver. IHL

Fragment OffsetDF

MF

Time to Live Protocol Header checksum

Source address

Destination address

Options (0 or more 32-bit words)

Data (0 to 65,515 bytes)

32 bits

Type of Serv. Total Length

Page 17: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

17

IP Packet Fields

VersionThe IP version number (currently 4)

IHLIP Header Length in 32-bit words

Type of ServiceContains priority information, rarely used

Total LengthThe total length of the datagram in bytesIncludes header

Page 18: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

18

IP Packet Fields (cont’d)

IdentificationWhen an IP packet is segmented into multiple fragments, each fragment is given the same identificationThis field is used to reassembly fragments

DFDon’t Fragment

MFMore FragmentsWhen a packet is fragmented, all fragments except the last one have this bit set

Page 19: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

19

IP Packet Fields (cont’d)

Fragment offsetThe fragment’s position within the original packet

Time to LiveHop count, decremented each time the packet reaches a new routerWhen hop count = 0, packet is discarded

ProtocolIdentifies which transport layer protocol is being used for thispacket

Header ChecksumVerifies the contents of the IP headerNot polynomial-based

Page 20: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

20

IP Packet Fields (cont’d)

Source and Destination AddressesUniquely identify sender and receiver of the packet

OptionsUp to 40 bytes in lengthUsed to extend functionality of IPExamples: source routing, security, record route

Page 21: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

21

IP Addresses

32 bits longNotation:

Each byte is written in decimal in MSB order, separated by decimalsExample: 128.195.1.80

Address ClassesClass A, B, C, D, ELoopbackBroadcast

Page 22: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

22

IP Address Classes

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

24 bit

16 bit

8 bit

Page 23: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

23

IP Address ClassesClass A:

For very large organizations16 million hosts allowed

Class B:For large organizations65 thousand hosts allowed

Class CFor small organizations255 hosts allowed

Class DMulticast addressesNo network/host hierarchy

Page 24: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

24

Example

Class A 1.0.0.0 to 126.0.0.0Class B 128.1.0.0 191.255.0.0Class C 192.0.1.0 223.2555.255.0Class D 224.0.0.0 239.255.255.255Class E 240.0.0.0 to 255.255.255.254All 0s, (this host) all 0 s for the network partAll 1s, limited broadcastNet.id, host id all 1s directed broadcast for the network 127.x.y.z (often 1s) is used for loopback within the same host

Page 25: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

25

IP Address Hierarchy

Note that Class A, Class B, and Class C addresses only support two levels of hierarchyEach address contains a network and a host portion, meaning two levels of hierarchyHowever, the host portion can be further split into “subnets” by the address class ownerThis allows for more than 2 levels of hierarchy

Page 26: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

26

Subnetting

Host idSubnet idNetwork id

Example: Class B address with 8-bit subnetting

165.230 .24 .8

16 bits 8 bits 8 bits

ExampleAddress:

Page 27: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

27

Subnet Masks

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

Host idSubnet idNetwork id16 bits 8 bits 8 bits

1111111111111111 11111111 00000000Mask:

255.255 .255 .0

Page 28: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

28

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 addressesA = 165.230.82.52B = 165.230.24.93M = 255.255.255.0

Same network?Same subnet?

Page 29: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

29

Example

Default netmasksClass A 98.0.0.0 (16 M hosts for each address)

255.0.0.0 net mask Class B 140.14.0.0 (64K hosts for each address)

255.255.0.0 net maskClass C address 192.6.8.0 (256 hosts for each address)

255.255.255.0

Page 30: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

30

Example

Subnetting allows subdivision of a networkA rotorouter company is given 201.70.64.0 wants 8 subnetsWhat is the subnet mask?How many host per subnet?

Page 31: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

31

Example

A bachelorette company is granted an address 181.56.0.0 The company needs 1000 subnetsWhat is the subnet maskHow many host per subnet

Page 32: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

32

Variable length subnetting

Assume a company wants to have five subnets with 60, 60, 60, 30, 30 hostsSubnet masks allow power of 2 subnetsUse a hierarchy of routers to allow subnets to be divided with different subnet masksAnother approach:Variable length subnet masks or use two different subnet masks255.255.255.192 for the first three and the fourth is subdividedinto 2 more with 255.255.255.224

Page 33: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

33

Variable length subnetting

L4255.255.255.22432 (60)

L3255.255.255.22432 (60)

L2255.255.255.19264(60)

L1255.255.255.19264 (60)

L0255.255.255.19264 (60)

Page 34: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

34

2.3 IP Routing

A B C D W X Y Z

?

How do you get a packet from one network to another?

Page 35: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

35

IP Routing (cont’d)

A B C D W X Y Z

R

Answer: with a router (or a series of routers)

A B C D W X Y Z

R RNetworkCloud

Case 1:Single hop

Case 2:Multi-hop

Page 36: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

36

Example

N2N2 N3N3 N4N4

Actual routing table contains IP addresses, Flags Actual routing table contains IP addresses, Flags indicating type of entries, net mask etc. (see Stevens pg. indicating type of entries, net mask etc. (see Stevens pg. 113, sect 9.2)113, sect 9.2)

Routing table @ R2Routing table @ R2

N1N1

R1 R2 R3

N1N2N3N4

R1Deliver directlyDeliver directlyR3

Dest Next hop

Page 37: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

37

Searching the routing table

First, search for a matching host address Flag H is set

Second, search for a matching network addressNeed to know the number of bits to use for network ID

Third, search for a default entry– Execute netstat -rn on your machine and find the contents of the

routing tableDefault entry allows for a single entry for a list of entries that have the same next-hop value

Page 38: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

38

IP Support Protocols

ARPRARPICMP

Page 39: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

39

ARP

Address Resolution ProtocolReturns a MAC sublayer address when given an Internet addressCommonly used in broadcast LANs so that two hosts can communicate using IP addresses instead of MAC sublayeraddresses

Page 40: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

40

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 packetcontaining “128.195.1.38?”

Ignored Answered

Page 41: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

41

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

Repl

ARP response packetcontaining “98:22:ee:f1:90:1a”

Page 42: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

42

RARP

Reverse Address Resolution ProtocolRARP performs the inverse action of ARPRARP returns an IP address for a given MAC sublayer addressOperationally, RARP is the same as ARP

Page 43: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

43

ICMP

Internet Control Message ProtocolHandles special Internet control functionsResponsibilities:

Reporting unreachable destinationsReporting IP packet header problemsReporting routing problemsReporting echoes (pings)

Page 44: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

44

ICMP

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

ICMP messages delivered in IP packetsICMP functions:

Announce network errorsAnnounce network congestionAssist trouble shootingAnnounce timeouts

Page 45: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

45

ICMP MSG

IP headerSource, Destination Address, TTL, ...

ICMP MSGMessage type, Code, Checksum,

Data

Message type examples (Figure 6.3 in Stevens book):0 (8) echo request (reply)3 destination unreachable4 source quench11 time exceeded

Page 46: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

46

Specific uses of ICMP

Echo request replyCan be used to check if a host is alive

Address mask request/replyLearn the subnet mask

Destination unreachableInvalid address and/or port

TTL expiredRouting loops, or too far away

Page 47: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

47

Ping

Uses ICMP echo request/replySource sends ICMP echo request message to the destination address

Echo request packet contains sequence number and timestamp

Destination replies with an ICMP echo reply message containing the data in the original echo requestmessageSource can calculate round trip time (RTT) of packetsIf no echo reply comes back then the destination is unreachable

Page 48: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

48

Ping (cont’d)

R1 R2 R3A B

Time

Echo request

Echo reply

Page 49: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

49

Traceroute

Traceroute records the route that packets takeA clever use of the TTL fieldWhen a router receives a packet, it decrements TTLIf TTL=0, it sends an ICMP time exceeded message back to the senderTo determine the route, progressively increase TTL

Every time an ICMP time exceeded message is received, record the sender’s (router’s) addressRepeat until the destination host is reached or an error message occurs

Page 50: The Network Layer - Computer Sciencebadri/352dir/Spring04/notes/...M = 255.255.255.0 Same network? Same subnet? 29 Example zDefault netmasks zClass A 98.0.0.0 (16 M hosts for each

50

Traceroute (cont’d)

R1 R2 R3A BTTL=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 exceededPu = Port unreachable