UNIT-3
Network Layer
It is majorly focused on getting packets from the source to the destination, routing error handling and congestion control.
Functions:-
Maintains the address at the frame header of both source and destination and performs addressing to detect various devices in network.
This is performed by Internet Protocol. The network layer converts the packets from its upper layer.
It is the most important functionality. The network layer chooses the most relevant and best path for the data transmission from source to destination.
It works to deliver a logical connection across multiple devices.
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 :-
Based on the connections there are 2 types of services provided :
single route.
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.
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 :
the communicating nodes and then data stream is transferred.
ROUTING ALGORITHMS
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
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.
Figure 22.13 Popular routing protocols
22.8
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.
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.
Sharing Information: Example of an Internet
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.
The Concept of Distance Vector Routing
Figure 21-18
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
Distance Vector Routing Table
Figure 21-19
Figure 22.14 Distance vector routing tables
22.16
Figure 22.15 Initialization of tables in distance vector routing
22.17
Note
22.18
In distance vector routing, each node shares its routing table with its immediate neighbors periodically and when there is a change.
Figure 22.16 Updating in distance vector routing
22.19
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.
Concept of Link State Routing
Figure 21-24
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.
Cost in Link State Routing
Figure 21-25
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
Link State Packet
Figure 21-26
Figure 22.20 Concept of link state routing
22.26
Figure 22.21 Link state knowledge
22.27
Figure 22.22 Dijkstra algorithm
22.28
Figure 22.23 Example of formation of shortest path tree
22.29
Table 22.2 Routing table for node A
22.30
Flooding of A’s LSP
Figure 21-27
Link State Database(same for all routers)
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
Costs in the Dijkstra Algorithm
Figure 21-29
Shortest Path tree
▶ Following four steps are followed:
Shortest Path Calculation, Part I
Figure 21-30, Part I
Shortest Path Calculation, Part II
Figure 21-30, Part II
Shortest Path Calculation, Part III
Figure 21-30, Part III
Shortest Path Calculation, Part IV
Figure 21-30, Part IV
Shortest Path Calculation, Part V
Figure 21-30, Part V
Shortest Path Calculation, Part VI
Figure 21-30, Part VI
Shortest Path Calculation, Part VII
Figure 21-31, Part VII
Shortest Path Calculation, Part VIII
Figure 21-31, Part I
Shortest Path Calculation, Part IX
Figure 21-31, Part II
Shortest Path Calculation, Part X
Figure 21-31, Part III
Shortest Path Calculation, Part XI
Figure 21-31, Part IV
Shortest Path Calculation, Part XII
Figure 21-31, Part V
Shortest Path Calculation, Part XIII
Figure 21-31, Part VI
Routing Table for Router A
Figure 21-32
Each router uses the shortest path tree to construct its routing table
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.
▶ 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.
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.
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.
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).
▶ 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.
▶
▶ 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:
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.
▶ When token bucket after two packets are send. One packet still remains as no token is left. As shown in Fig(b).
▶ 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).
▶ 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.
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. |
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
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
The IPv4 addresses are unique
19.68
and universal.
want to connected to internet.
Address Space
19.69
The address space of IPv4 is
232
or 4,294,967,296.
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.
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.
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).
Example 19.3
19.73
Find the error, if any, in the following IPv4 addresses.
Solution
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.
Figure 19.2 Finding the classes in binary and dotted-decimal notation
19.75
Example 19.4
19.76
Find the class of each address.
Solution
Finding the address class
19.77
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.
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.
19.80
Blocks in class A
19.81
Blocks in class B
19.82
Blocks in class C
19.83
Network Addresses
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.
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.
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
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.
Mask
i.e. 8 bits of any address in class A define the netid and rest 24 bits define the hostid.
Masking concept
Figure 4-10
4-89
AND operation
Figure 4-11
4-90
Table 19.2 Default masks for classful addressing
19.91
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
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.
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.
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.
We must not apply the default mask
of one class to
an address belonging to another class.
4-96
Subnetting & Supernetting
19.97
A network with two levels of hierarchy (not subnetted)
4-98
A network with three levels of hierarchy (subnetted)
4-99
Addresses in a network with and without subnetting
4-100
For making 4 subnets 2 bits are set to 1
Default mask and subnet mask
4-101
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
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
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?
11001000 00101101 00100010
00111000
Solution
4-105
11111111 11111111 11110000
00000000
11001000 00101101 00100000
00000000
The subnetwork address is 200.45.32.0.
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
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
Example 2
4-108
Comparison of a default mask and a subnet mask
4-109
The number of subnets must be a power of 2.
4-110
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
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
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
Example 3
4-114
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).
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).
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
Example 4
4-118
Variable-length subnetting
4-119
In subnetting,
we need the first address of the subnet and the subnet mask to define the range of addresses.
4-120
A supernetwork
Figure 4.26
121
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
Figure 4.27
TCP/IP
Protocol Suite
123
Comparison of subnet, default, and supernet
masks
Note:
124
The idea of subnetting and supernetting of classful addresses is almost obsolete.
Note
19.12
5
Classful addressing, which is almost obsolete, is replaced with classless addressing.
19.12
6
Classless Addressing
Address Block: An entity is granted a block(range) of addresses.
Restriction:
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.
Figure 19.3 A block of 16 addresses granted to a small organization
19.12
8
19.12
9
Mask
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.
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.
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.
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.
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.
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
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.
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.
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.
Figure 19.4 A network configuration for the block 205.16.37.32/28
19.13
8
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.
Figure 19.5 Two levels of hierarchy in an IPv4 address
19.14
0
Figure 19.6 A frame in a character-oriented protocol
19.14
1
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.
Figure 19.7 Configuration and addresses in a subnetted network
19.14
3
Figure 19.8 Three-level hierarchy in an IPv4 address
19.14
4
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:
Design the subblocks and find out how many addresses are still available after these allocations.
5
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
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
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
Figure 19.9 An example of address allocation and distribution by an ISP
19.14
9
Table 19.3 Addresses for private networks
19.15
9
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
Note
19.15
2
An IPv6 address is 128 bits long.
Figure 19.14 IPv6 address in binary and hexadecimal colon notation
19.15
3
Figure 19.15 Abbreviated IPv6 addresses
19.15
4
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.
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
20.15
8
20-1 INTERNETWORKING
Figure 20.1 Links between two hosts
20.15
9
Need of Network Layer
20.16
0
Figure 20.2 Network layer in an internetwork
20.16
1
Figure 20.3 Network layer at the source, router, and destination
20.16
2
Figure 20.3 Network layer at the source, router, and destination (continued)
20.16
3
20.16
4
Switching at the network layer in the Internet uses the datagram approach to packet switching.
Internet as a Datagram Network
5
20.16
Switching at the network layer in the Internet uses the datagram approach to packet switching.
Internet as a Connectionless Network
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
20.16
7
approach.
Packets in the IPv4 layer are called datagrams. Figure 20.5 IPv4 datagram format
20.16
8
Datagram
Datagram continues…..
20.16
9
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).
differential services.
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.
Table 20.1 Types of service
20.17
0
Differential services:
20.17
1
First 6 bits make up the codepoint subfield and the last 2 bits are not used.
priority assignment by the internet or local authorities.
Table 20.3 Values for codepoints
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.
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.
Table 20.5 MTUs for some networks
20.17
3
20.17
Fields Related to Fragmentation
5. Identification:
to all fragments. All fragments have the same identification number, the same
as the original datagram.
6. Flags:
20.17
5
Figure 20.10 Flags used in fragmentation
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.
20.17
7
Figure 20.12 fragmentation example
7. Time to live:
20.17
8
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.
datagram is delivered.
Figure 20.8 Protocol field and encapsulated data
20.17
9
Table 20.4 Protocol values
used for network testing and debugging.
20.18
0
Figure 20.14 Taxonomy of options in IPv4
20.18
1
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.
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.
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).
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.
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
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).
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
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
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
20-3 IPv6
generation), was proposed and is now a standard. 1
IPv6 Continues…
Advantages:
functionalities.
20.19
2
20.19
3
Packet Format
Figure 20.15 IPv6 datagram header and payload
Base Header
Figure 20.16 Format of an IPv6 datagram
20.19
4
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.
the length of the IP datagram excluding20t.h19e base header.
5
20.19
6
Table 20.6 Next header codes for IPv6
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.
20.19
7
Table 20.9 Comparison between IPv4 and IPv6 packet headers
20.19
8
20-4 TRANSITION FROM IPv4 TO IPv6
20.19
9
transition
Figure 20.18 Three transition strategies
20.20
0
Dual Stack
must run IPv4 and IPv6 simultaneously until all the Internet uses IPv6.
Figure 20.19 Dual stack
1
20.20
Tunneling
Figure 20.20 Tunneling strategy
20.20
2
Header Translation
moved to IPv6 but some systems still use IPv4.
header translation.
Figure 20.21 Header translation strategy
20.20
3
Table 20.11 Header translation
There are some rules used in transforming an IPv6 packet header to an IPv4 packet header.
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
Figure 21.1 ARP operation
21.205
Figure 21.2 ARP packet
21.206
Figure 21.3 Encapsulation of ARP packet
21.207
Figure 21.4 Four cases using ARP
21.208
Note
21.209
An ARP request is broadcast; an ARP reply is unicast.
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
Figure 21.5 Example 21.1, an ARP request and reply
21.211
Figure 21.6 Proxy ARP
21.212
Figure 21.7 BOOTP client and server on the same and different networks
21.213
Note
21.214
DHCP provides static and dynamic address allocation that can be manual or automatic.
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
Figure 21.8 General format of ICMP messages
21.216
Note
21.217
ICMP always reports error messages to the original source.
Figure 21.9 Error-reporting messages
21.218
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.
Figure 21.10 Contents of data field for the error messages
21.220
Figure 21.11 Redirection concept
21.221
Figure 21.12 Query messages
21.222
Figure 21.13 Encapsulation of ICMP query messages
21.223
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.
Figure 21.14 Example of checksum calculation
21.225
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
21.227
Example 21.3 (continued)
Figure 21.15 The traceroute program operation
21.228
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.
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.
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.
21.232
Example 21.5 (continued)
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
Figure 21.16 IGMP message types
21.234
Figure 21.17 IGMP message format
21.235
Table 21.1 IGMP type field
21.236
Figure 21.18 IGMP operation
21.237
Note
21.238
In IGMP, a membership report is sent twice, one after the other.
Note
21.239
The general query message does not define a particular group.
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.
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.
Figure 21.19 Example 21.6
21.242
Figure 21.20 Encapsulation of IGMP packet
21.243
Note
21.244
The IP packet that carries an IGMP packet has a value of 1 in its TTL field.
Table 21.2 Destination IP addresses
21.245
Figure 21.21 Mapping class D to Ethernet physical address
21.246
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.
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
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
Change the
21.250
multicast IP address 238.212.24.9 to an
Example 21.8
Ethernet multicast address.
Solution
Figure 21.22 Tunneling
21.251
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
21.253
Example 21.9 (continued)
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
Figure 21.23 Comparison of network layers in version 4 and version 6
21.255
Table 21.3 Comparison of error-reporting messages in ICMPv4 and ICMPv6
21.256
Table 21.4 Comparison of query messages in ICMPv4 and ICMPv6
21.257