1 of 257

UNIT-3

2 of 257

Network Layer

It is majorly focused on getting packets from the source to the destination, routing error handling and congestion control.

Functions:-

  • Addressing:

Maintains the address at the frame header of both source and destination and performs addressing to detect various devices in network.

  • Packeting:

This is performed by Internet Protocol. The network layer converts the packets from its upper layer.

  • Routing:

It is the most important functionality. The network layer chooses the most relevant and best path for the data transmission from source to destination.

  • Inter-networking:

It works to deliver a logical connection across multiple devices.

3 of 257

Network layer design issues:

The network layer comes with some design issues they are described as follows:

1. Store and Forward packet switching:

The host sends the packet to the nearest router. This packet is stored there until it has fully arrived once the link is fully processed by verifying the checksum then it is forwarded to the next router till it reaches the destination. This mechanism is called “Store and Forward packet switching.”

2. Services provided to Transport Layer:

Through the network/transport layer interface, the network layer transfers it’s services to the transport layer. These services are described below.

But before providing these services to the transfer layer following goals must be kept in mind :-

  • Offering services must not depend on router technology.
  • The transport layer needs to be protected from the type, number and topology of the available router.
  • The network addresses for the transport layer should use uniform numbering pattern also at LAN and WAN connections.

Based on the connections there are 2 types of services provided :

  • Connectionless – The routing and insertion of packets into subnet is done individually. No added setup is required.
  • Connection-Oriented – Subnet must offer reliable service and all the packets must be transmitted over a

single route.

4 of 257

  1. Implementation of Connectionless Service:

Packet are termed as “datagrams” and corresponding subnet as “datagram subnets”. When the message size that has to be transmitted is 4 times the size of the packet, then the network layer divides into 4 packets and transmits each packet to router via. a few protocol. Each data packet has destination address and is routed independently irrespective of the packets.

  1. Implementation of Connection Oriented service:

To use a connection-oriented service, first we establishes a connection, use it and then release it. In connection-oriented services, the data packets are delivered to the receiver in the same order in which they have been sent by the sender.

It can be done in either two ways :

    • Circuit Switched Connection – A dedicated physical path or a circuit is established between

the communicating nodes and then data stream is transferred.

    • Virtual Circuit Switched Connection – The data stream is transferred over a packet switched network, in such a way that it seems to the user that there is a dedicated path from the sender to the receiver. A virtual path is established here. While, other connections may also be using the same path.

5 of 257

ROUTING ALGORITHMS

6 of 257

Introduction

A packet travels from source to destination through multiple paths or sometimes a single path. So when a packet finds multiple paths to reach the destination, it has no judging methods available to find a right path.

A router with the help of certain algorithms calculates the best path for the packet to reach the destination. These algorithms are called routing algorithms.

The path with the lowest cost is considered the best.

If cost of each link is known, a router can find optimal combination for any transmission.

Several routing algorithms exist for this calculation

Two most popular are: Distance vector routing Link state routing

7 of 257

Types of Routing Algorithms

Routing algorithms can be divided into 2 classes: Non-adaptive or static:

Routing decisions are predetermined and not based on measurements (or estimates) of the current network topology and traffic load.

Adaptive or Dynamic:

Routing decisions may be changed when network topology and/or

traffic load changes.

  • Extreme case: select a new route for each Packet
  • May get information just from neighboring routers, or from all routers.
  • May re-determine routes periodically, or when topology changes, or when traffic load changes more than a threshold percentage.

8 of 257

Figure 22.13 Popular routing protocols

22.8

9 of 257

Distance vector routing

Uses distance and direction to find the best path to reach the destination.

The distance is the number of hops (Router) a packet crosses to reach the destination.

Each Router periodically shares knowledge about the entire network with its

neighbors.

10 of 257

Continues….

Working of this distance vector algorithm in three steps as follows: Step 1: The information about every router connected directly and routing updates will be gathered by every single router. This information about the whole network will be sent periodically to all the neighboring routers connected to it. Every router updates the information in its routing table.

Step 2: All information collected by single router about the whole network will be sent only to its neighbors and not to all other routers in the routing table. If there is any change in the hop count or disabled paths it will updated only to its neighbors which passes to its neighbors.

Step 3: The above explained sharing of information will take place in a period of 30 seconds. If there is a change in the network (Network fails or router is added) the changed information will be updated.

Examples:

RIP and IGRP uses distance vector routing algorithm.

11 of 257

Sharing Information: Example of an Internet

12 of 257

Sharing Information

Cloud represents LANs with its LAN’s Network ID.

A, ,B, C, D,E and F are routers

Assumes a cost of one unit for every link

Efficiency of transmission is function of number of links required to reach a destination.

In DVR, the cost is based on hop count.

Each node adds its knowledge and sends the updated table to its neighbors

and so on.

13 of 257

The Concept of Distance Vector Routing

Figure 21-18

14 of 257

Routing Table

Creation of Table

-Router only knows about its neighbors

-Table has at least 3 types of information network ID, the cost and ID of next

router

  • Network id: final destination of packet
  • Cost: number of in between hops

15 of 257

Distance Vector Routing Table

Figure 21-19

16 of 257

Figure 22.14 Distance vector routing tables

22.16

17 of 257

Figure 22.15 Initialization of tables in distance vector routing

22.17

18 of 257

Note

22.18

In distance vector routing, each node shares its routing table with its immediate neighbors periodically and when there is a change.

19 of 257

Figure 22.16 Updating in distance vector routing

22.19

20 of 257

Link state Routing

In LSR, each router shares its knowledge of its neighborhood

with every other router in the internetwork.

LSR includes:

a) Knowledge about the neighborhood: Instead of sending its entire routing table. A router sends information about its neighborhood only.

b) To all routers(with flooding):Each router sends this

information to every other router on the internetwork.

c) Information sharing when there is a change

Example:

OSPF routing protocol which uses link state algorithm alone.

21 of 257

Concept of Link State Routing

Figure 21-24

22 of 257

Packet cost

In LSR cost is weighted value based on variety of factors as security levels, traffic, state of link etc.

Cost is applied only by routers.

Cost is applied as packet leaves the router rather than as it enters.

23 of 257

Cost in Link State Routing

Figure 21-25

24 of 257

Link state Packet

The basis of advertising is a short packet called a link state packet(LSP)

Four fields:

ID of advertiser

ID of destination network

The cost

Id of neighbor router

25 of 257

Link State Packet

Figure 21-26

26 of 257

Figure 22.20 Concept of link state routing

22.26

27 of 257

Figure 22.21 Link state knowledge

22.27

28 of 257

Figure 22.22 Dijkstra algorithm

22.28

29 of 257

Figure 22.23 Example of formation of shortest path tree

22.29

30 of 257

Table 22.2 Routing table for node A

22.30

31 of 257

Flooding of A’s LSP

Figure 21-27

32 of 257

Link State Database(same for all routers)

33 of 257

Dijkstra Algorithm

Each router applies this algorithm to link state database.

Algorithm calculates the shortest path between two points on a network using a graph made up of nodes and arcs.

Nodes: networks and routers

Cost is applied to arc from router to network

Cost of arc from network to router is always zero

34 of 257

Costs in the Dijkstra Algorithm

Figure 21-29

35 of 257

Shortest Path tree

Following four steps are followed:

  1. Identify one router as its root
  2. Identify the arc with the lowest cumulative cost This arc and node are now permanent
  3. The algorithm examines database and identifies every node that can be reached from its chosen node. These nodes & arcs added temporarily to tree
  4. Last two steps are repeated until every node in the network has become a permanent part of tree.

36 of 257

Shortest Path Calculation, Part I

Figure 21-30, Part I

37 of 257

Shortest Path Calculation, Part II

Figure 21-30, Part II

38 of 257

Shortest Path Calculation, Part III

Figure 21-30, Part III

39 of 257

Shortest Path Calculation, Part IV

Figure 21-30, Part IV

40 of 257

Shortest Path Calculation, Part V

Figure 21-30, Part V

41 of 257

Shortest Path Calculation, Part VI

Figure 21-30, Part VI

42 of 257

Shortest Path Calculation, Part VII

Figure 21-31, Part VII

43 of 257

Shortest Path Calculation, Part VIII

Figure 21-31, Part I

44 of 257

Shortest Path Calculation, Part IX

Figure 21-31, Part II

45 of 257

Shortest Path Calculation, Part X

Figure 21-31, Part III

46 of 257

Shortest Path Calculation, Part XI

Figure 21-31, Part IV

47 of 257

Shortest Path Calculation, Part XII

Figure 21-31, Part V

48 of 257

Shortest Path Calculation, Part XIII

Figure 21-31, Part VI

49 of 257

Routing Table for Router A

Figure 21-32

Each router uses the shortest path tree to construct its routing table

50 of 257

Congestion Control

Congestion is the situation in which too many packets present in the network causes packet delay and loss that degrades performance of the network. The network transport layer handles the responsibility of congestion. The network layer have to determine what to do with the excess packets, because it directly experiences it.

51 of 257

Congestion is an important issue that can arise in packet switched network.

Congestion is a situation in communication networks in which too many packets are present in a part of the subnet, performance degrades.

Congestion in a network may occur when the load on the network (i.e. the number of packets sent to the network) is greater than the capacity of the network (i.e. the number of packets a network can handle).

In other words, when too much traffic is offered, congestion sets-in and performance degrades sharply.

52 of 257

53 of 257

Causing of Congestion :

The various causes of congestion in a subnet are as follows:

1. The input traffic rate exceeds the capacity of the output lines. If suddenly, a stream of packet start arriving on three or four input lines and all need the same output line. In this case a queue will be built up.

If there is insufficient memory to hold all the packets, the packet will be lost.

Increasing the memory to unlimited size does not solve the problem. This is because, by the time packets reach front of the queue, they have already timed out (as they waited the queue).

When timer goes off source transmits duplicate packet that are also added to the queue. Thus, same packets are added again and again, increasing the load all the way to the destination.

54 of 257

55 of 257

  1. The routers are too slow to perform bookkeeping tasks (queuing buffers, updating tables etc).
  2. The routers' buffer is too limited.
  3. Congestion in a subnet can occur if the processors are slow. Slow speed CPU at routers will perform the routine tasks (such as queuing buffers, updating table etc.) slowly. As a result of this, queues are built-up even though there is excess line capacity.
  4. Congestion is also caused by slow links. This problem will be solved when high speed links are used.

But it is not always the case. Sometimes increase in link bandwidth can further deteriorate the

congestion problem as higher speed links may make the network more unbalanced.

Congestion can make itself worse. If a router" does not have free buffers, it start ignoring/discarding the newly arriving packets.

When these packets are discarded. the sender may retransmit them after the timer goes off. Such

packets are transmitted by the sender again and again until the source gets the acknowledgement of these packets.

Therefore multiple transmission of packets will force the congestion to take place at the sending end.

56 of 257

congestion control algorithm :

1. Leaky Bucket Algorithm :

The leaky bucket implementation is used to control the rate at which traffic is sent to the network. Leaky bucket implementation is same as bucket having a hole at the bottom such as,

Imagine a bucket with a small hole in the bottom, as illustrated in Fig. (a). No matter the rate at which water enters the bucket, the outflow is at a constant rate,r, when there is any water in the bucket and zero when the bucket is empty. Also, once the bucket is full, any additional water entering it spills over the sides and is lost (i.e. does not appear in the output under the hole).

57 of 257

The same idea can be applied to packets, as shown in Fig (b). Conceptually, each host is connected to the network by an interface containing a leaky bucket, that is, a finite internal queue. If a packet arrives at the queue when it is full, the packet is discarded.

58 of 257

In other words, if one or more processes within the host try to send a packet when the maximum number is already queued, the new packet is unceremoniously discarded.

The host is allowed to put one packet per clock tick onto the network. Again, this can be enforced by the interface card. This mechanism turns an uneven flow of packets from the user processes inside the host into an even flow of packets onto the network, smoothing out bursts and greatly reducing the chances of congestion.

The following steps are performed:

Step 1. When the host has to send a packet, the packet is thrown into the bucket.

Step 2. The bucket leaks at a constant rate, meaning the network interface transmits packets at a constant rate.

Step 3. Bursty traffic is converted to a uniform traffic by the leaky bucket.

Step 4. In practice the bucket is a finite queue that outputs at a finite rate.

Step 5. If the traffic consists of variable length packets, the fixed output rate must be based on the number of bytes or bits.

The following is an algorithm for variable-length packets:

  1. Initialise a counter to n at the tick of the clock.
  2. It n is greater than the size of the packet, send the packet and decrement the counter by the packet size. Repeat this step until n is smaller than the packet size.
  3. Reset the counter and go to step 1.

59 of 257

Token Bucket Algorithm:

As we know that, leaky bucket algorithm enforces a rigid pattern at the output stream, irrespective of the pattern of the input.

For many applications, it is better to allow the output to speed up somewhat when a larger bursts arrives than to loose the data.

The token bucket algorithm allows idle hosts to accumulate credit for the future in the form of tokens. For each tick of the clock, the system sends n tokens to the bucket. The system removes one token for every cell (or byte) of data sent. The token bucket can easily be implemented with a counter. The token is initialized to zero.

Each time a token is added, the counter is incremented by 1. Each time a unit of data is sent, the counter is decremented by 1.

When the counter is zero the host cannot send data.

This algorithm follows the following steps:

Step 1. In regular intervals tokens are thrown into the bucket.

Step 2. The bucket has a maximum capacity.

Step 3. If there is a ready packet, a token is removed from the bucket and the packet can be send.

Step 4. If there is no token in the bucket, the packet cannot be send.

In Fig. (a), token bucket holding two tokens, before packets are send out.

60 of 257

61 of 257

When token bucket after two packets are send. One packet still remains as no token is left. As shown in Fig(b).

62 of 257

Now, if the host wants to send bursty data, it can consume all 10,000 tokens at once for sending 10,000 cells or bytes. Thus, a host can send bursty data as long as bucket is not empty. As shown in Fig(c).

63 of 257

Congestion control involves two factors that measure the performance of the network.

1. Delay :

It can be measure, when the load is much less than the capacity of the network, the delay will be minimum and composed of propagation delay and processing delay. Note that the delay becomes infinite when the load is greater than the capacity.

Throughput :

It can define in a network as the number of packets passing through the network in a unit of time. When the load is below the capacity of the network, the throughput increases.

Note that, when the load is below the capacity of the network, the throughput increases

proportionally with the node.

64 of 257

Basics

Flow Control

Congestion Control

Operator

Done by server machine or sender machine.

Done by router.

Buffering

Process buffering.

Does not process.

Bandwidth

It cannot block the bandwidth medium.

It block the bandwidth medium.

Packet lost

Packet is lost between sender and server.

Other users packet is lost.

Performance

Affect less on network performance.

Affects the network performance.

65 of 257

66 of 257

Logical Addressing

Communication at network layer is host-to-host.

Packets sent may pass through several LANs & WANs.

For this level of communication a global addressing scheme is needed called Logical addressing.

Internet addresses are 32 bits in length gives a maximum of 232addresses.These addresses are called IPv4 addresses or simply IP addresses.

For need of more addresses internet uses 128-bit addresses that give greater flexibility in address

allocation. These addresses are called IPv6 1a9d.6dresses

6

67 of 257

An IPv4 address is a 32-bit address that uniquely and universally defines the connection of a device (for example, a computer or a router) to the Internet.

19.67

19-1 IPv4 ADDRESSES

68 of 257

The IPv4 addresses are unique

19.68

and universal.

  • IP addresses are unique in the sense that each address defines only one connection to the internet.
  • Two devices on the internet can never have the same IP at the same time.
  • If a device operating at network layer has m connections to the internet it need to have m addresses. Eg. Router
  • IP addresses are unique in the sense that the addressing system must be accepted by any host that

want to connected to internet.

69 of 257

Address Space

19.69

The address space of IPv4 is

232

or 4,294,967,296.

  • An address space is the total number of addresses used by the protocol.
  • If protocol uses N bits to define an address, the address space is 2N.
  • The address space of IPv4 is more than four billion.

70 of 257

Notations

19.70

Binary Notation:

In this notation address is displayed as 32 bits.

Dotted Decimal Notation:

To make IP address more compact and easier to read this notation is used.

Each number in dotted decimal notation is a value ranging from 0 to 255.

71 of 257

Example 19.1

19.71

Change the following IPv4 addresses from binary notation to dotted-decimal notation.

Solution

We replace each group of 8 bits with its equivalent decimal number (see Appendix B) and add dots for separation.

72 of 257

Example 19.2

19.72

Change the following IPv4 addresses from dotted-decimal notation to binary notation.

number with its binary

Solution

We replace each decimal equivalent (see Appendix B).

73 of 257

Example 19.3

19.73

Find the error, if any, in the following IPv4 addresses.

Solution

  1. There must be no leading zero (045).
  2. There can be no more than four numbers.
  3. Each number needs to be less than or equal to 255.
  4. A mixture of binary notation and dotted-decimal notation is not allowed.

74 of 257

19.74

In classful addressing, the address space is divided into five classes:

A, B, C, D, and E.

Classful Addressing

IPv4 uses the concept of classes. The architecture is called Classful Addressing.

The class of an address can be find out if address is given in either binary or decimal form.

75 of 257

Figure 19.2 Finding the classes in binary and dotted-decimal notation

19.75

76 of 257

Example 19.4

19.76

Find the class of each address.

  1. 00000001 00001011 00001011 11101111
  2. 11000001 10000011 00011011 11111111
  3. 14.23.120.8
  4. 252.5.15.111

Solution

  1. The first bit is 0. This is a class A address.
  2. The first 2 bits are 1; the third bit is 0. This is a class C address.
  3. The first byte is 14; the class is A.
  4. The first byte is 252; the class is E.

77 of 257

Finding the address class

19.77

78 of 257

Table 19.1 Number of blocks and block size in classful IPv4 addressing

Classes and Blocks

Class A addresses were designed for large organizations with large number of hosts.

Class B addresses were designed for midsize organizations with tens of thousands of hosts.

Class C addresses were designed for small organizations with small number of hosts.

Class D addresses were designed for multicasting.19.78

Class E addresses were reserved for future use.

79 of 257

IP addresses in class A, B and C is divided into netid and hostid. This concept does not apply to class D and E.

19.79

Netid and Hostid

In classful addressing, a large part of the available addresses were wasted.

In class A one byte defines the netid and three byte define the hostid and so on.

80 of 257

19.80

Blocks in class A

81 of 257

19.81

Blocks in class B

82 of 257

19.82

Blocks in class C

83 of 257

19.83

Network Addresses

  • The network address is the first address.
  • The network address defines the network to the rest of the Internet.
  • Given the network address, we can find the class of the address, the block, and the range of the addresses in the block

84 of 257

Example 9

Given the network address 17.0.0.0, find the class, the

block, and the range of the addresses.

Solution

4-84

The class is A because the first byte is between 0 and 127. The block has a netid of 17.

The addresses range from 17.0.0.0 to 17.255.255.255.

85 of 257

Example 10

Given the network address 132.21.0.0, find the class, the

block, and the range of the addresses.

Solution

4-85

The class is B because the first byte is between 128 and 191. The block has a netid of

132.21. The addresses range from

132.21.0.0 to 132.21.255.255.

86 of 257

4-86

Example 11

Given the network address 220.34.76.0, find the class, the

block, and the range of the addresses.

Solution

The class is C because the first byte is between

192 and 223. The block has a netid of 220.34.76.

The addresses range from 220.34.76.0

87 of 257

Mask

4-87

A mask is a 32-bit binary number that gives the first address in the block (the network address) when bitwise ANDed with an address in the block.

88 of 257

Mask

  • Mask also called Default mask is a 32 bit number made of contiguous 1s followed by contiguous 0s.
  • Mask helps in finding netid and hostid.
  • Example: Mask for class A address has eight 1s

i.e. 8 bits of any address in class A define the netid and rest 24 bits define the hostid.

  • Mask in the form /n (where n= 8, 16, 24 in classful addressing) is also used.
  • This notation is called slash notation or Classless Interdomain Routing(CIDR) notation. This notation is used in classless addre1s9s.i8n8g.

89 of 257

Masking concept

Figure 4-10

4-89

90 of 257

AND operation

Figure 4-11

4-90

91 of 257

Table 19.2 Default masks for classful addressing

19.91

92 of 257

The network address is the beginning address of each block.

It can be found by applying the default mask to

any of the addresses in the block (including itself).

It retains the netid of the block and sets the hostid to zero.

4-92

93 of 257

Example 12

Given the address 23.56.7.91 and the default class A mask,

find the beginning address (network address).

Solution

4-93

The default mask is 255.0.0.0, which means that only the first byte is preserved

and the other 3 bytes are set to 0s. The network address is 23.0.0.0.

94 of 257

Example 13

Given the address 132.6.17.85 and the default class B

mask, find the beginning address (network address).

Solution

4-94

The default mask is 255.255.0.0, which means that the first 2 bytes are preserved

and the other 2 bytes are set to 0s. The network address is 132.6.0.0.

95 of 257

Given the address 201.180.56.5 and the class C default

mask, find the beginning address (network address).

Example 14

Solution

4-95

The default mask is 255.255.255.0, which means that the first 3 bytes are preserved and the last byte is set to 0. The network address is 201.180.56.0.

96 of 257

We must not apply the default mask

of one class to

an address belonging to another class.

4-96

97 of 257

Subnetting & Supernetting

  • If an organization was granted a large block in class A or B, it could divide the addresses into small groups called subnets.
  • Subnetting increases the number of 1s in mask(In classless addressing).
  • In supernetting, an organization can combine several class C blocks to create a larger range of addresses.
  • Several networks are combined to create a supernetwork or supernet.
  • Supernetting decreases the number of 1s in the mask(In classless addressing).

19.97

98 of 257

A network with two levels of hierarchy (not subnetted)

4-98

99 of 257

A network with three levels of hierarchy (subnetted)

4-99

100 of 257

Addresses in a network with and without subnetting

4-100

For making 4 subnets 2 bits are set to 1

101 of 257

Default mask and subnet mask

4-101

102 of 257

Finding the Subnet Address

Given an IP address, we can find the subnet address the same way we found the network address in the previous chapter. We apply the mask to the address. We can do this in two ways: straight or short-cut.

4-102

103 of 257

Straight Method

In the straight method, we use binary notation for both the address and the mask and then apply the AND operation to find the subnet address.

4-103

104 of 257

Example 1

4-104

What is the subnetwork address if the destination address is 200.45.34.56 and the subnet mask is 255.255.240.0?

105 of 257

11001000 00101101 00100010

00111000

Solution

4-105

11111111 11111111 11110000

00000000

11001000 00101101 00100000

00000000

The subnetwork address is 200.45.32.0.

106 of 257

Short-Cut Method

** If the byte in the mask is 255, copy the byte in the address.

** If the byte in the mask is 0, replace the byte in the address with 0.

** If the byte in the mask is neither 255 nor 0, we write the mask and the address in binary and apply the AND operation.

4-106

107 of 257

Example 2

What is the subnetwork address if the destination address is 19.30.80.5 and the mask is 255.255.192.0?

Solution

4-107

See Figure 5.6

108 of 257

Example 2

4-108

109 of 257

Comparison of a default mask and a subnet mask

4-109

110 of 257

The number of subnets must be a power of 2.

4-110

111 of 257

A company is granted the site address 201.70.64.0 (class C). The company needs six subnets. Design the subnets.

Example 3

Solution

4-111

The number mask is 24 (class C).

of

1s

in

the

default

112 of 257

Solution (Continued)

4-112

The company needs six subnets. This number 6 is not3 a power of 2. The next number that is a power of 2 is 8 (2 ). We need 3 more 1s in the subnet mask. The total number of 1s in the subnet mask is 27 (24 + 3).

The total number of 0s is 5 (32 27). The mask is

113 of 257

11111111 11111111 11111111 11100000

or

Solution (Continued)

4-113

255.255.255.224

The number of subnets is 8.

5

The number of addresses in each subnet is 2 (5 is the number of 0s) or 32.

See Figure 5.8

114 of 257

Example 3

4-114

115 of 257

Example 4

A company is granted the site address 181.56.0.0 (class B). The company needs 1000 subnets. Design the subnets.

Solution

4-115

The number of 1s in the default mask is 16 (class B).

116 of 257

The company needs 1000 subnets. This number is not a

Solution (Continued)

4-116

po1w0er of 2. The next number that is a power of 2 is 1024 (2 ). We need 10 more 1s in the subnet mask.

The total number of 1s in the subnet mask is 26 (16 + 10). The total number of 0s is 6 (32 26).

117 of 257

The mask is

Solution (Continued)

4-117

11111111 11111111 11111111 11000000

or

255.255.255.192.

The number of subnets is 1024.

6

(6 is the

The number of addresses in each subnet is 2 number of 0s) or 64.

See Figure 5.9

118 of 257

Example 4

4-118

119 of 257

Variable-length subnetting

4-119

120 of 257

In subnetting,

we need the first address of the subnet and the subnet mask to define the range of addresses.

4-120

121 of 257

A supernetwork

Figure 4.26

121

122 of 257

Note:

In subnetting, we need the first address of the subnet and

the subnet mask to define the range of addresses.

In supernetting, we need the first address of the supernet and the supernet mask to define the range of addresses.

122

123 of 257

Figure 4.27

TCP/IP

Protocol Suite

123

Comparison of subnet, default, and supernet

masks

124 of 257

Note:

124

The idea of subnetting and supernetting of classful addresses is almost obsolete.

125 of 257

Note

19.12

5

Classful addressing, which is almost obsolete, is replaced with classless addressing.

126 of 257

19.12

6

Classless Addressing

  • To overcome address depletion and give more organizations access to internet classless addressing were designed and implemented.
  • There are no classes but the addresses are granted in blocks.

Address Block: An entity is granted a block(range) of addresses.

Restriction:

  1. Address in block must be contiguous, one after another.
  2. Number of addresses in a block must be in power of 2.
  3. The first address must be evenly divisible by the number of addresses.

127 of 257

Example 19.5

19.12

7

Figure 19.3 shows a block of addresses, in both binary and dotted-decimal notation, granted to a small business that needs 16 addresses.

Restrictions: We can see that the restrictions are applied to this block.

The addresses are contiguous.

The number of addresses is a power of 2 (16 = 24).

The first address is divisible by 16. The first address, when converted to a decimal number, is 3,440,387,360, which when divided by 16 results in 215,024,210.

128 of 257

Figure 19.3 A block of 16 addresses granted to a small organization

19.12

8

129 of 257

19.12

9

Mask

  • A mask is a 32 bit number in which n leftmost bits are 1s and the 32-n rightmost bits are 0s.
  • In classless addressing the mask for a block can take any value from 0 to 32.
  • The address and the /n notation completely defines the whole block(the first address, the last address and the number of addresses.

In IPv4 addressing, a block of addresses can be defined as

x.y.z.t /n

in which x.y.z.t defines one of the addresses and the

/n defines the mask.

130 of 257

19.13

The first address in the block can be found by setting the rightmost

32 − n bits to 0s.

0

The last address in the block can be found by setting the rightmost

32 − n bits to 1s.

The number of addresses in the block can be found by using the formula

232−n.

131 of 257

Example 19.6

1

19.13

A block of addresses is granted to a small organization. We know that one of the addresses is 205.16.37.39/28. What is the first address in the block?

Solution

The binary representation of the given address is 11001101 00010000 00100101 00100111

If we set 32−28 rightmost bits to 0, we get 11001101 00010000 00100101 0010000

or 205.16.37.32.

This is actually the block shown in Figure 19.3.

132 of 257

Example 19.7

19.13

2

Find the last address for the block in Example 19.6.

Solution

The binary representation of the given address is 11001101 00010000 00100101 00100111

If we set 32 − 28 rightmost bits to 1, we get 11001101 00010000 00100101 00101111

or 205.16.37.47

This is actually the block shown in Figure 19.3.

133 of 257

Example 19.8

19.13

3

Find the number of addresses in Example 19.6.

means

that

number

Solution

The value of n is 28, which of addresses is 2 32−28 or 16.

134 of 257

Example 19.9

19.13

4

Another way to find the first address, the last address, and the number of addresses is to represent the mask as a 32- bit binary (or 8-digit hexadecimal) number. This is particularly useful when we are writing a program to find these pieces of information. In Example 19.5 the /28 can be represented as

11111111 11111111 11111111 11110000

(twenty-eight 1s and four 0s).

Find

  1. The first address
  2. The last address
  3. The number of addresses.

135 of 257

Example 19.9 (continued)

19.13

5

Solution

a. The first address can be found by ANDing the given addresses with the mask. ANDing here is done bit by bit. The result of ANDing 2 bits is 1 if both bits are 1s; the result is 0 otherwise.

136 of 257

Example 19.9 (continued)

19.13

6

b. The last address can be found by ORing the given addresses with the complement of the mask. ORing here is done bit by bit. The result of ORing 2 bits is 0 if both bits are 0s; the result is 1 otherwise. The complement of a number is found by changing each 1 to 0 and each 0 to 1.

137 of 257

Example 19.9 (continued)

19.13

7

c. The number of addresses can be found by complementing the mask, interpreting it as a decimal number, and adding 1 to it.

138 of 257

Figure 19.4 A network configuration for the block 205.16.37.32/28

19.13

8

139 of 257

Note

19.13

9

The first address in a block is normally not assigned to any device; it is used as the network address that represents the organization

to the rest of the world.

140 of 257

Figure 19.5 Two levels of hierarchy in an IPv4 address

19.14

0

141 of 257

Figure 19.6 A frame in a character-oriented protocol

19.14

1

142 of 257

19.14

2

Note

Each address in the block can be considered as a two-level hierarchical structure:

the leftmost n bits (prefix) define the network;

the rightmost 32 − n bits define the host.

143 of 257

Figure 19.7 Configuration and addresses in a subnetted network

19.14

3

144 of 257

Figure 19.8 Three-level hierarchy in an IPv4 address

19.14

4

145 of 257

Example 19.10

19.14

An ISP is granted a block of addresses starting with 190.100.0.0/16 (65,536 addresses). The ISP needs to distribute these addresses to three groups of customers as follows:

  1. The first group has 64 customers; each needs 256 addresses.
  2. The second group has 128 customers; each needs 128 addresses.
  3. The third group has 128 customers; each needs 64 addresses.

Design the subblocks and find out how many addresses are still available after these allocations.

5

146 of 257

Example 19.10 (continued)

19.14

6

Solution

Figure 19.9 shows the situation.

Group 1

For this group, each customer needs 256 addresses. This means that 8 (log2256) bits are needed to define each host. The prefix length is then 32 − 8 = 24. The addresses are

147 of 257

Example 19.10 (continued)

19.14

7

Group 2

For this group, each customer needs 128 addresses. This means that 7 (log2128) bits are needed to define each host. The prefix length is then 32 − 7 = 25. The addresses are

148 of 257

Example 19.10 (continued)

8

Group 3

For this group, each customer needs 64 addresses. This means that 6 (log264) bits are needed to each host. The prefix length is then 32 − 6 = 26. The addresses are

Number of granted addresses to the ISP: 65,536 Number of allocated addresses by the ISP: 40,960

19.14

Number of available addresses: 24,576

149 of 257

Figure 19.9 An example of address allocation and distribution by an ISP

19.14

9

150 of 257

Table 19.3 Addresses for private networks

19.15

9

151 of 257

Despite all short-term solutions, address depletion is still a long-term problem for the Internet. This and other problems in the IP protocol itself have been the motivation for IPv6.

19.15

1

19-2 IPv6 ADDRESSES

Topics discussed in this section:

Structure Address Space

152 of 257

Note

19.15

2

An IPv6 address is 128 bits long.

153 of 257

Figure 19.14 IPv6 address in binary and hexadecimal colon notation

19.15

3

154 of 257

Figure 19.15 Abbreviated IPv6 addresses

19.15

4

155 of 257

Example 19.11

19.15

5

Expand the address 0:15::1:12:1213 to its original.

Solution

We first need to align the left side of the double colon to the left of the original pattern and the right side of the double colon to the right of the original pattern to find how many 0s we need to replace the double colon.

This means that the original address is.

156 of 257

157 of 257

Introduction

Main network protocol is Internet Protocol(IP).

Current version of IP is 4 or IPv4.

Next Generation of this protocol is IPv6 which may become the dominant protocol in the near future.

20.1

57

158 of 257

20.15

8

20-1 INTERNETWORKING

  • Physical and Data link layer of network operate locally.
  • These two layers are responsible for data delivery on network from one node to next.

Figure 20.1 Links between two hosts

159 of 257

20.15

9

  • Internetwork is made of five networks: Four LANs and one WAN.
  • If host A need to send a data packet to host D, the packet needs to go first from A to R1, then from R1 to R3 and finally from R3 to D.
  • Problem: When data arrives at interface f1 of R1, how does R1 know that interface f3 is the outgoing interface?
  • There is no provision in data link layer or physical layer to help R1 to make right decision. Also frame does no contain any routing information.

160 of 257

Need of Network Layer

20.16

0

  • To solve the problem of delivery through several links, the network layer was designed .
  • The network layer is responsible for host to host delivery and for routing the packets through routers or switches.

Figure 20.2 Network layer in an internetwork

161 of 257

20.16

1

  • The network layer is responsible for creating the packet from the data coming from transport layer.
  • The header contains the logical address of source and destination.
  • The network layer is responsible for checking its routing table to find the routing information(outgoing interface of packet etc.).
  • The network layer at the switch or router is responsible for routing the packet.
  • When packet arrives the router or switch consults its routing table and finds the interface from which the packet must be sent.

162 of 257

Figure 20.3 Network layer at the source, router, and destination

20.16

2

163 of 257

Figure 20.3 Network layer at the source, router, and destination (continued)

20.16

3

164 of 257

20.16

4

Switching at the network layer in the Internet uses the datagram approach to packet switching.

Internet as a Datagram Network

  • The internet at the network layer is a packet switched network.
  • Switching: Circuit, Packet & Message.
  • Packet Switching uses either Virtual circuit or datagram approach.

165 of 257

5

20.16

Switching at the network layer in the Internet uses the datagram approach to packet switching.

Internet as a Connectionless Network

  • Delivery of packet can be accomplished by using either connection-oriented or a connectionless network service.
  • In connection-oriented service a connection is setup before sending the packet. Packets are sent on the same path in sequential order.
  • In connectionless service, the network layer protocol treats each packet independently.

166 of 257

20-2 IPv4

20.16

6

The Internet Protocol version 4 (IPv4) is the delivery mechanism used by the TCP/IP protocols.

Figure 20.4 Position of IPv4 in TCP/IP protocol suite

167 of 257

20.16

7

  • IPv4 is unreliable and connectionless datagram protocol- a best delivery service.
  • Best effort means IPv4 provides no error and flow control.
  • For reliability IPv4 is paired with a reliable protocol such as TCP.
  • IPv4 uses connectionless protocol for a packet switching network that uses datagram

approach.

  • IPv4 relies on higher level protocol to take care of all these problems.

168 of 257

Packets in the IPv4 layer are called datagrams. Figure 20.5 IPv4 datagram format

20.16

8

Datagram

169 of 257

Datagram continues…..

20.16

9

  • Datagram is a variable length packet consisting of two parts: header and data.
  • Header is 20 to 60 bytes in length and contains routing and delivery information.
  • Description of each field:
  • Version(VER): 4-bit field defines the version of IPv4 protocol. Current version is 4.
  • Header Length(HLEN): 4-bit field defines the total length of the datagram

header in 4-byte words.

If there are no options the header length is 20 bytes and value of this field is 5 (5 X 4 =20).

When option field is at its maximum size, the value of this field is 15 (15X4=60).

  1. Services: This field previously called service type and now it is called

differential services.

170 of 257

Figure 20.6 Service type or differentiated services

Service type:

The first 3 bits are called precedence bits and next 4 bits are called type of

service and last bit is not used.

  1. Precedence is a 3-bit subfield ranging from 000 to 111. The precedence defines the priority of the datagram in issues such as congestion. If router is congested and needs to discard some datagrams, those datagrams with lowest precedence are discarded first. The precedence subfield was part of version 4, but never used.
  2. TOS bits is a 4-bit subfield with each bit having a special meaning.

Table 20.1 Types of service

20.17

0

171 of 257

Differential services:

20.17

1

First 6 bits make up the codepoint subfield and the last 2 bits are not used.

  1. When 3 rightmost bits are 0, the 3 leftmost bits are interpreted the same as the precedence bits.
  2. When 3 rightmost bits are not all 0, the 6 bits define 64 services based on

priority assignment by the internet or local authorities.

Table 20.3 Values for codepoints

172 of 257

the IPv4 datagrams in bytes.

20.17

2

4. Total Length: 16-bit field that defines the total length(header plus data) of

Length of data =Total length-header length

Since the field length is 16 bits, the total length of the IPv4 datagram is limited to 65,536 bytes of which 20 to 60 bytes are header and rest is data from upper layer.

  1. Identification: This field is used in fragmentation.
  2. Flags: This field is used in fragmentation.
  3. Fragmentation offset: This field is used in fragmentation.

Fragmentation

Maximum Transfer Unit (MTU)

Each data link layer protocol has its own frame format in most protocols. One field is the maximum size of the data field. When datagram is encapsulated in a frame, the total size of the datagram must be less than this maximum size, which is defined by the hardware and software used in the network.

173 of 257

Table 20.5 MTUs for some networks

20.17

3

174 of 257

20.17

  • To make the IPv4 protocol independent of the physical network, the designers decided to make the maximum length of the IPv4 datagram equal to 65,535 bytes.
  • For other physical networks, we must divide the datagram to make it possible to pass through these networks. This is called fragmentation.
  • When a datagram is fragmented, each fragment has its own header with most of the fields repeated, but with some changed. A fragmented datagram may itself be fragmented if it encounters a network with an even smaller MTU.
  • The reassembly of the datagram, is done only by the destination host because each fragment becomes an independent datagram.

Fields Related to Fragmentation

5. Identification:

  • This 16-bit field identifies a datagram originating from the source host. The combination of the identification and source IPv4 address must uniquely define a datagram as it leaves the source host.
  • When a datagram is fragmented, the value in the identification field is copied

to all fragments. All fragments have the same identification number, the same

as the original datagram.

  • The identification number helps the destination in reass4embling the datagram.

175 of 257

6. Flags:

20.17

5

  • This is a 3-bit field. The first bit is reserved.
  • The second bit is called the do not fragment bit.
    1. If its value is 1, the machine must not fragment the datagram. If it cannot pass the datagram through any available physical network, it discards the datagram and sends an ICMP error message to the source host.
    2. If its value is 0, the datagram can be fragmented if necessary.
  • The third bit is called the more fragment bit.
    • If its value is 1, it means the datagram is not the last fragment; there are more fragments after this one.
    • If its value is 0, it means this is the last or only fragment

Figure 20.10 Flags used in fragmentation

176 of 257

  1. Fragmentation Offset:
    • 13-bit field shows relative position of fragment with respect to whole datagram. It is the offset of the data in the original datagram measured in units of 8 bytes.
    • Figure 20.11 shows a datagram with a data size of 4000 bytes fragmented into three fragments.
  • The bytes in the original datagram are numbered 0 to 3999.
  • The first fragment carries bytes 0 to 1399. The offset is 0/8 =0.
  • The second fragment carries bytes 1400 to 2799; the offset is 1400/8 = 175.
  • Finally, the third fragment carries bytes 2800 to 3999. The offset is 2800/8 =350.
  • Remember that the value of the offset is measured in units of 8 bytes. This is done

because the length of the offset field is only 13 bits and cannot represent a sequence

of bytes greater than 8191. This forces hosts or rout2er0s.1th7at fragment datagrams to choose a fragment size so that the first byte number is divis6ible by 8.

177 of 257

20.17

7

  • Notice the value of the identification field is the same in all fragments. Notice the Value of the flags field with the more bit set for all fragments except the last. Also, the value of the offset field for each fragment is shown.

Figure 20.12 fragmentation example

178 of 257

7. Time to live:

20.17

8

  • A datagram has a limited lifetime in its travel through an internet.

This field was originally designed to hold a timestamp, which was decremented by each visited router. The datagram was discarded when the value became zero.

  • This field is needed because routing tables in the Internet can become corrupted. A datagram may travel between two or more routers for a long time without ever getting delivered to the destination host. This field limits the lifetime of a datagram.
  • Protocol:
    • This 8-bit field defines the higher-level protocol that uses the services of the IPv4 layer.
    • An IPv4 datagram can encapsulate data from several higher-level protocols such as TCP, UDP, ICMP, and IGMP.
    • This field specifies the final destination protocol to which the IPv4

datagram is delivered.

179 of 257

Figure 20.8 Protocol field and encapsulated data

20.17

9

Table 20.4 Protocol values

180 of 257

  1. Checksum:
    • First, the value of the checksum field is set to O. Then the entire header is divided into 16-bit sections and added together. The result (sum) is complemented and inserted into the checksum field.
  2. Source address:
    • This 32-bit field defines the IPv4 address of the source. This field must remain unchanged during the time the IPv4 datagram travels from the source host to the destination host.
  3. Destination address:
    • This 32-bit field defines the IPv4 address of the destination. This field must remain unchanged during the time the IPv4 datagram travels from the source host to the destination host.
  4. Options:
    • The header of the IPv4 datagram is made of two parts: a fixed part and a variable part. The fixed part is 20 bytes long and the variable part comprises the options that can be a maximum of 40 bytes.
    • Options, as the name implies, are not required for a datagram. They can be

used for network testing and debugging.

20.18

0

181 of 257

Figure 20.14 Taxonomy of options in IPv4

20.18

1

182 of 257

Example 20.1

20.18

2

An IPv4 packet has arrived with the first 8 bits as shown:

01000010

The receiver discards the packet. Why?

Solution

There is an error in this packet. The 4 leftmost bits (0100) show the version, which is correct. The next 4 bits (0010) show an invalid header length (2 × 4 = 8). The minimum number of bytes in the header must be

20. The packet has been corrupted in transmission.

183 of 257

Example 20.2

20.18

3

In an IPv4 packet, the value of HLEN is 1000 in binary. How many bytes of options are being carried by this packet?

Solution

The HLEN value is 8, which means the total number of bytes in the header is 8 × 4, or 32 bytes. The first 20 bytes are the base header, the next 12 bytes are the options.

184 of 257

Example 20.3

20.18

4

In an IPv4 packet, the value of HLEN is 5, and the value of the total length field is 0x0028. How many bytes of data are being carried by this packet?

Solution

The HLEN value is 5, which means the total number of bytes in the header is 5 × 4, or 20 bytes (no options). The total length is 40 bytes, which means the packet is carrying 20 bytes of data (40 − 20).

185 of 257

Example 20.4

20.18

5

An IPv4 packet has arrived with the first few hexadecimal digits as shown.

0x45000028000100000102 . . .

How many hops can this packet travel before being dropped? The data belong to what upper-layer protocol?

Solution

To find the time-to-live field, we skip 8 bytes. The time-to-live field is the ninth byte, which is 01. This means the packet can travel only one hop. The protocol field is the next byte (02), which means that

the upper-layer protocol is IGMP.

186 of 257

Example 20.5

A packet has arrived with an M bit value of 0. Is this the first fragment, the last fragment, or a middle fragment? Do we know if the packet was fragmented?

Solution

If the M bit is 0, it means that there are no more fragments; the fragment is the last one. However, we cannot say if the original packet was fragmented or not. A non-fragmented packet is considered the last fragment.

20.18

6

187 of 257

Example 20.6

20.18

7

A packet has arrived with an M bit value of 1. Is this the first fragment, the last fragment, or a middle fragment? Do we know if the packet was fragmented?

Solution

If the M bit is 1, it means that there is at least one more fragment. This fragment can be the first one or a middle one, but not the last one. We don’t know if it is the first one or a middle one; we need more information (the value of the fragmentation offset).

188 of 257

Example 20.7

A packet has arrived with an M bit value of 1 and a fragmentation offset value of 0. Is this the first fragment, the last fragment, or a middle fragment?

Solution

Because the M bit is 1, it is either the first fragment or a middle one. Because the offset value is 0, it is the first fragment.

20.18

8

189 of 257

Example 20.8

A packet has arrived in which the offset value is 100. What is the number of the first byte? Do we know the number of the last byte?

Solution

To find the number of the first byte, we multiply the offset value by 8. This means that the first byte number is 800.

We cannot determine the number of the last byte unless we know the length.

20.18

9

190 of 257

Example 20.9

A packet has arrived in which the offset value is 100, the value of HLEN is 5, and the value of the total length field is 100. What are the numbers of the first byte and the last byte?

Solution

The first byte number is 100 × 8 = 800. The total length is 100 bytes, and the header length is 20 bytes (5 × 4), which means that there are 80 bytes in this datagram. If the first byte number is 800, the last byte number must be 879.

20.19

0

191 of 257

20-3 IPv6

  • The network layer protocol in the TCP/IP protocol suite is currently IPv4. Although IPv4 is well designed, data communication has evolved since the inception of IPv4 in the 1970s.
  • IPv4 has some deficiencies that make it unsuitable for the fast- growing Internet.
  • Address depletion is a long-term problem in the Internet.
  • The Internet must accommodate real-time audio and video transmission. This type of transmission requires minimum delay strategies and reservation of resources not provided in the IPv4 design.
  • The Internet must accommodate encryption and authentication of data for some applications. No encryption or authentication is provided by IPv4.
    • To overcome these deficiencies, IPv6 (Internetworking Protocol, version 6), also known as IPng (Internetw2o0r.k19ing Protocol, next

generation), was proposed and is now a standard. 1

192 of 257

IPv6 Continues…

Advantages:

  • Larger address space. An IPv6 address is 128 bits long. Compared with the 32-bit address of IPv4, this is a huge the address space.
  • Better header format.
  • New options. IPv6 has new options to allow for additional

functionalities.

  • Allowance for extension. IPv6 is designed to allow the extension of the protocol if required by new technologies or applications.
  • Support for resource allocation.
  • Support for more security.

20.19

2

193 of 257

20.19

3

Packet Format

  • Each packet is composed of a mandatory base header followed by the payload.
  • The payload consists of two parts: optional extension headers and data from an upper layer.
  • The base header occupies 40 bytes, whereas the extension headers and data from the upper layer contain up to 65,535 bytes of information.

Figure 20.15 IPv6 datagram header and payload

194 of 257

Base Header

  • There are 8 fields in Base Header

Figure 20.16 Format of an IPv6 datagram

20.19

4

195 of 257

  • Version. This 4-bit field defines the version number of the IP. For IPv6, the value is 6.
  • Priority. The 4-bit priority field defines the priority of the packet with respect to traffic congestion.
  • Flow label. The flow label is a 3-byte (24-bit) field that is designed to provide special handling for a particular flow of data.

A sequence of packets, sent from a particular source to a particular destination, that needs special handling by

routers is called a flow of packets. The combination of the source address and the value of the flow label uniquely defines a flow of packets.

  • Payload length. The 2-byte payload length field defines

the length of the IP datagram excluding20t.h19e base header.

5

196 of 257

20.19

6

Table 20.6 Next header codes for IPv6

  • Next header. The next header is an 8-bit field defining the header that follows the base header in the datagram.

The next header is either one of the optional extension headers used by IP or the header of an encapsulated packet such as UDP or TCP. Note: This field in version 4 is called the protocol.

197 of 257

20.19

7

  • Hop limit. This 8-bit hop limit field serves the same purpose as the TTL field in IPv4.
  • Source address. The source address field is 16-byte (128-bit) Internet address that identifies original source of the datagram.
  • Destination address. The destination address field is a 16-byte (128-bit) Internet address that usually identifies the final destination of the datagram.

198 of 257

Table 20.9 Comparison between IPv4 and IPv6 packet headers

20.19

8

199 of 257

20-4 TRANSITION FROM IPv4 TO IPv6

20.19

9

  • Because of the huge number of systems on the Internet, the transition from IPv4 to IPv6 cannot happen suddenly. It takes a considerable amount of time before every system in the Internet can move from IPv4 to IPv6.
  • The transition must be smooth to prevent any problems between IPv4 and IPv6 systems.
  • Three strategies have been devised by the IETF to help the

transition

Figure 20.18 Three transition strategies

200 of 257

20.20

0

Dual Stack

  • It is recommended that all hosts, have a dual stack of protocols. A station

must run IPv4 and IPv6 simultaneously until all the Internet uses IPv6.

  • To determine which version to use when sending a packet to a destination, the source host queries the DNS. If the DNS returns an IPv4 address, the source host sends an IPv4 packet. If the DNS returns an IPv6 address, the source host sends an IPv6 packet.

Figure 20.19 Dual stack

201 of 257

1

20.20

Tunneling

  • Tunneling is a strategy used when two computers using IPv6 want to communicate with each other and the packet must pass through a region that uses IPv4.
  • To pass through this region, the packet must have an IPv4 address. So the IPv6 packet is encapsulated in an IPv4 packet when it enters the region, and it leaves its capsule when it exits the region.
  • To make it clear that the IPv4 packet is carrying an IPv6 Packet as data, the protocol value is set to 41.

Figure 20.20 Tunneling strategy

202 of 257

20.20

2

Header Translation

  • Header translation is necessary when the majority of the Internet has

moved to IPv6 but some systems still use IPv4.

  • The sender wants to use IPv6, but receiver does not understand IPv6.
  • In this case, the header format must be totally changed through

header translation.

  • The header of the IPv6 packet is converted to an IPv4 header.
  • Header translation uses the mapped address to translate an IPv6 address to an IPv4 address.

Figure 20.21 Header translation strategy

203 of 257

20.20

3

Table 20.11 Header translation

There are some rules used in transforming an IPv6 packet header to an IPv4 packet header.

204 of 257

21-1 ADDRESS MAPPING

21.204

The delivery of a packet to a host or a router requires two levels of addressing: logical and physical. We need to be able to map a logical address to its corresponding physical address and vice versa. This can be done by using either static or dynamic mapping.

Topics discussed in this section: Mapping Logical to Physical Address Mapping Physical to Logical Address

205 of 257

Figure 21.1 ARP operation

21.205

206 of 257

Figure 21.2 ARP packet

21.206

207 of 257

Figure 21.3 Encapsulation of ARP packet

21.207

208 of 257

Figure 21.4 Four cases using ARP

21.208

209 of 257

Note

21.209

An ARP request is broadcast; an ARP reply is unicast.

210 of 257

A host with IP address 130.23.43.20 and physical address

21.210

B2:34:55:10:22:10 has a packet to send to another host with IP address 130.23.43.25 and physical address A4:6E:F4:59:83:AB. The two hosts are on the same Ethernet network. Show the ARP request and reply packets encapsulated in Ethernet frames.

Solution

Figure 21.5 shows the ARP request and reply packets. Note that the ARP data field in this case is 28 bytes, and that the individual addresses do not fit in the 4-byte boundary. That is why we do not show the regular 4-byte boundaries for

these addresses.

Example 21.1

211 of 257

Figure 21.5 Example 21.1, an ARP request and reply

21.211

212 of 257

Figure 21.6 Proxy ARP

21.212

213 of 257

Figure 21.7 BOOTP client and server on the same and different networks

21.213

214 of 257

Note

21.214

DHCP provides static and dynamic address allocation that can be manual or automatic.

215 of 257

The IP protocol has no error-reporting or error-

21.215

21-2 ICMP

correcting mechanism. The IP protocol also lacks a mechanism for host and management queries. The Internet Control Message Protocol (ICMP) has been designed to compensate for the above two deficiencies. It is a companion to the IP protocol.

Topics discussed in this section:

Types of Messages Message Format

Error Reporting and Query Debugging Tools

216 of 257

Figure 21.8 General format of ICMP messages

21.216

217 of 257

Note

21.217

ICMP always reports error messages to the original source.

218 of 257

Figure 21.9 Error-reporting messages

21.218

219 of 257

Note

21.219

Important points about ICMP error messages:

No ICMP error message will be generated in response to a datagram carrying an ICMP error message.

No ICMP

error message will be generated for a

fragmented datagram that is not the first fragment.

No ICMP error

message will be generated for a

datagram having a multicast address.

No ICMP error message

will be generated

for a datagram having a special address such as

127.0.0.0 or 0.0.0.0.

220 of 257

Figure 21.10 Contents of data field for the error messages

21.220

221 of 257

Figure 21.11 Redirection concept

21.221

222 of 257

Figure 21.12 Query messages

21.222

223 of 257

Figure 21.13 Encapsulation of ICMP query messages

21.223

224 of 257

Example 21.2

21.224

Figure 21.14 shows an example of checksum calculation for a simple echo-request message. We randomly chose the identifier to be 1 and the sequence number to be 9. The message is divided into 16-bit (2-byte) words. The words are added and the sum is complemented. Now the sender can put this value in the checksum field.

225 of 257

Figure 21.14 Example of checksum calculation

21.225

226 of 257

We use the ping program to test the server fhda.edu. The

21.226

result is shown on the next slide. The ping program sends messages with sequence numbers starting from 0. For each probe it gives us the RTT time. The TTL (time to live) field in the IP datagram that encapsulates an ICMP

message has been set to 62. At the beginning, ping defines the number of data bytes as 56 and the total number of bytes as 84. It is obvious that if we add 8 bytes of ICMP header and 20 bytes of IP header to 56, the result is 84. However, note that in each probe ping defines the number of bytes as 64. This is the total number of bytes in the ICMP packet (56 + 8).

Example 21.3

227 of 257

21.227

Example 21.3 (continued)

228 of 257

Figure 21.15 The traceroute program operation

21.228

229 of 257

We use the traceroute program to find the route from the computer voyager.deanza.edu to the server fhda.edu. The following shows the result:

21.229

Example 21.4

The unnumbered line after the command shows that the destination is 153.18.8.1. The packet contains 38 bytes: 20 bytes of IP header, 8 bytes of UDP header, and 10 bytes of application data. The application data are used by

traceroute to keep track of the packets.

230 of 257

Example 21.4 (continued)

21.230

The first line shows the first router visited. The router is named Dcore.fhda.edu with IP address 153.18.31.254. The first round-trip time was 0.995 ms, the second was 0.899 ms, and the third was 0.878 ms. The second line shows the second router visited. The router is named Dbackup.fhda.edu with IP address 153.18.251.4. The three round-trip times are also shown. The third line shows the destination host. We know that this is the destination host because there are no more lines. The destination host is the server fhda.edu, but it is named tiptoe.fhda.edu with the IP address 153.18.8.1. The three round-trip times are also shown.

231 of 257

Example 21.5

21.231

In this example, we trace a longer route, the route to xerox.com (see next slide). Here there are 17 hops between source and destination. Note that some round-trip times look unusual. It could be that a router was too busy to process the packet immediately.

232 of 257

21.232

Example 21.5 (continued)

233 of 257

The IP protocol can be involved in two types of communication: unicasting and multicasting. The

21.233

21-3 IGMP

Netstat Utility

Internet Group Management Protocol (IGMP) is one of the necessary, but not sufficient, protocols that is involved in multicasting. IGMP is a companion to the IP protocol.

Topics discussed in this section:

Group Management

IGMP Messages and IGMP Operation

Encapsulation

234 of 257

Figure 21.16 IGMP message types

21.234

235 of 257

Figure 21.17 IGMP message format

21.235

236 of 257

Table 21.1 IGMP type field

21.236

237 of 257

Figure 21.18 IGMP operation

21.237

238 of 257

Note

21.238

In IGMP, a membership report is sent twice, one after the other.

239 of 257

Note

21.239

The general query message does not define a particular group.

240 of 257

Imagine there are three hosts in a network, as shown in Figure 21.19. A query message was received at time 0; the random delay time (in tenths of seconds) for each group is shown next to the group address. Show the sequence of report messages.

21.240

Example 21.6

Solution

The events occur in this sequence:

a. Time 12: The timer for 228.42.0.0 in host A expires, and a membership report is sent, which is received by the router and every host including host B which cancels its timer for 228.42.0.0.

241 of 257

b. Time 30: The timer for 225.14.0.0 in host A expires, and a membership report is sent which is received by the router and every host including host C which cancels its timer for 225.14.0.0.

21.241

Example 21.6 (continued)

c. Time 50: The timer for 238.71.0.0 in host B expires, and a membership report is sent, which is received by the router and every host.

d. Time 70: The timer for 230.43.0.0 in host C expires, and a membership report is sent, which is received by the router and every host including host A which cancels its timer for 230.43.0.0.

242 of 257

Figure 21.19 Example 21.6

21.242

243 of 257

Figure 21.20 Encapsulation of IGMP packet

21.243

244 of 257

Note

21.244

The IP packet that carries an IGMP packet has a value of 1 in its TTL field.

245 of 257

Table 21.2 Destination IP addresses

21.245

246 of 257

Figure 21.21 Mapping class D to Ethernet physical address

21.246

247 of 257

Note

21.247

An Ethernet multicast physical address is in the range 01:00:5E:00:00:00 to 01:00:5E:7F:FF:FF.

248 of 257

Change the multicast IP address 230.43.14.7 to an Ethernet multicast physical address.

21.248

Solution

We can do this in two steps:

a. We write the rightmost 23 bits of the IP address in hexadecimal. This can be done by changing the rightmost 3 bytes to hexadecimal and then subtracting 8 from the leftmost digit if it is greater than or equal to

8. In our example, the result is 2B:0E:07.

Example 21.7

249 of 257

Example 21.7 (continued)

21.249

b. We add the result of part a to the starting Ethernet multicast address, which is 01:00:5E:00:00:00. The result is

250 of 257

Change the

21.250

multicast IP address 238.212.24.9 to an

Example 21.8

Ethernet multicast address.

Solution

  1. The rightmost 3 bytes in hexadecimal is D4:18:09. We need to subtract 8 from the leftmost digit, resulting in 54:18:09.
  2. We add the result of part a to the Ethernet multicast starting address. The result is

251 of 257

Figure 21.22 Tunneling

21.251

252 of 257

We use netstat (see next slide) with three options: -n, -r, and

-a. The -n option gives the numeric versions of IP addresses, the -r option gives the routing table, and the -a option gives all addresses (unicast and multicast). Note that we show only the fields relative to our discussion. “Gateway” defines the router, “Iface” defines the interface.

21.252

Note that the multicast address is shown in color. Any packet with a multicast address from 224.0.0.0 to 239.255.255.255 is masked and delivered to the Ethernet

interface.

Example 21.9

253 of 257

21.253

Example 21.9 (continued)

254 of 257

We discussed IPv6 in Chapter 20. Another protocol that has been modified in version 6 of the TCP/IP protocol suite is ICMP (ICMPv6). This new version follows the same strategy and purposes of version 4.

21.254

21-4 ICMPv6

Topics discussed in this section:

Error Reporting Query

255 of 257

Figure 21.23 Comparison of network layers in version 4 and version 6

21.255

256 of 257

Table 21.3 Comparison of error-reporting messages in ICMPv4 and ICMPv6

21.256

257 of 257

Table 21.4 Comparison of query messages in ICMPv4 and ICMPv6

21.257