IT_210_Week07_Forouzan
IT_210_Week07_Forouzan
Introduction
to
Network
Layer
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 18: Outline
18.5
18.18.1 Packetizing
The first duty of the network layer is definitely packetizing:
encapsulating the payload in a network-layer packet at the
source and decapsulating the payload from the network-layer
packet at the destination.
In other words, one duty of the network layer is to carry a
payload from the source to the destination without changing
it or using it.
The network layer is doing the service of a carrier such as the
postal office, which is responsible for delivery of packages
from a sender to a receiver without changing or using the
contents.
18.6
18.18.2 Routing and Forwarding
Other duties of the network layer, which are as important as the first,
are routing and forwarding, which are directly related to each other.
Routing
This means that there is more than one route from the source to the
destination, the network layer is responsible for finding the best one. This is
done by running some routing protocols to help the routers coordinate their
knowledge about the neighborhood and to come up with consistent tables to
be used when a packet arrives.
Forwarding
The action applied by each router when a packet arrives at one of its
interfaces. A router normally use a decision-making table for applying this
action. It is called (the forwarding table) or (the routing table).
18.7
Figure 18.2: Forwarding process
When a router receives a packet from one of its attached networks, it needs to forward the
packet to another attached network (in unicast routing) or to some attached networks (in
multicast routing). To make this decision, the router uses a piece of information in the packet
header, which can be the destination address or a label, to find the corresponding output
interface number in the forwarding table.
18.8
18.18.3 Other Services
Let us briefly discuss other services expected from the network layer.
Error ControlL: a checksum field to the datagram to control any change or corruption in the
header, but not in the whole datagram.
Flow Control: Flow control regulates the amount of data a source can send without
overwhelming the receiver. The network layer in the Internet does not directly provide any
flow control. The datagrams are sent by the sender when they are ready.(Why flow control is
not provided?)
Congestion Control: Congestion may occur if the number of datagrams sent by source
computers is beyond the capacity of the network or routers. In this situation, some routers may
drop some of the datagrams.
Quality of Service: quality of service has become more important in the Internet especially
with multimedia communication. However, to keep the network layer untouched, these
provisions are mostly implemented in the upper layer.
Security: To provide security for a connectionless network layer, we need to have another
virtual level ( IPSec) that changes the connectionless service to a connection-oriented service.
18.9
18-2 PACKET SWITCHING
18.10
18.2.1 Datagram Approach
Connectionless Service
When the Internet started, to make it simple, the
network layer was designed to provide a
connectionless service in which the network-layer
protocol treats each packet independently, with each
packet having no relationship to any other packet. The
idea was that the network layer is only responsible for
delivery of packets from the source to the destination.
In this approach, the packets in a message may or may
not travel the same path to their destination. Figure
18.3 shows the idea..
18.11
Figure 18.3: A connectionless packet-switched network
18.12
Figure 18.4: Forwarding process in a router when used in a connectionless
network
In the datagram
approach, the
forwarding decision is
based on the
destination address of
the packet: The
packet header
has a source
and destination
addresses. The
destination
address defines SA DA Data
where it should SA DA Data
go and The router
routes the packet
based only on the
destination
address.
The source address defines where the packet comes from. It may be used to
send an error message to the source if the packet is discarded.
18.13
18.2.2 Virtual-Circuit Approach
Connection-Oriented Service
In a connection-oriented service (also called virtual-circuit
approach), there is a relationship between all packets
belonging to a message.
Before all datagrams in a message can be sent, a virtual
connection should be set up to define the path for the
datagrams
After connection setup, the datagrams can all follow the same
path.
In this type of service, not only must the packet contain the
source and destination addresses, it must also contain a flow
label, a virtual circuit identifier that defines the virtual path the
packet should follow.
18.14
Figure 18.5: A virtual-circuit packet-switched network
18.15
Figure 18.6: Forwarding process in a router when used in a virtual circuit
network
Incoming Outgoing
label label
18.16
Create a connection-oriented service
18.18
Figure 18.8: Sending acknowledgments in a virtual-circuit network
18.21
18.3.1 Delay
18.22
18.3.2 Throughput
18.23
Figure 18.10: Throughput in a path with three links in a
series
In this figure, the data can flow at the rate of 200 kbps in Link1.
When the data arrives at router R1 Data needs to be queued at the router
and sent at 100 kbps.
When data arrives at router R2, it could be sent at the rate of 150 kbps, but
there is not enough data to be sent.
So, the average rate of the data flow in Link3 is also 100 kbps.
The average throughput is determined by the bottleneck, the pipe with the smallest diameter.
In general, in a path with n links in series:
Throughput minimum {TR1, TR2, TRn}.
18.24
Figure 18.11: A path through the Internet backbone
The Internet backbone has a very high transmission rate, in the range of gigabits
per second.
The throughput is normally defined as the minimum transmission rate of the two
access links that connect the source and destination to the backbone. So, the
throughput is the minimum of TR1 and TR2.
For example, if a server connects to the Internet via a Fast Ethernet LAN with the
data rate of 100 Mbps, but a user who wants to download a file connects to the
Internet via a dial-up telephone line with the data rate of 40 kbps, the throughput
is 40 kbps. The bottleneck is definitely the dial-up line.
18.25
Figure 18.12: Effect of throughput in shared links
18.26
18.3.3 Packet Loss
18.27
18.3.4 Congestion Control
18.28
Figure 18.13. Packet delay and throughput as functions of
load
When the load is much less than the When the load is below the capacity
capacity of the network, the delay is of the network, the throughput
at a minimum (propagation delay increases proportionally with the
and processing delay--> both load.
negligible).
After the load reaches the capacity,
When the load reaches the network the throughput declines sharply--
capacity, the delay increases sharply >because routers are discarding
because we now need to add the packets.
queuing delay to the total delay.
When the load exceeds the
The delay becomes infinite when the capacity, the queues become full
load is greater than the capacity. and the routers have to discard
18.29 some packets. The sources
Congestion Control
18.30
Figure 18.14: Backpressure method for alleviating
congestion
18.31
Figure 4.15: Choke packet
18.32
18-4 IPv4 ADDRESSES
18.33
18.4.1 Address Space
18.34
Figure 18.16: Three different notations in IPv4 addressing
In binary
notation, an
IPv4 address
is displayed
as 32 bits.
18.35
Figure 18.17: Hierarchy in addressing
18.36
18.4.2 Classful Addressing
18.37
Figure 18.18: Occupation of the address space in classful
addressing
18.38
18.4.3 Classless Addressing
18.40
Figure 18.20: Slash notation
classless interdomain routing (CIDR)
18.41
Figure 18.21: Information extraction in classless addressing
18.42
Example 18.1
A classless address is given as 167.199.170.82/27. We can find the
above three pieces of information as follows. The number of addresses
in the network is 232− n = 25 = 32 addresses. The first address can be
found by keeping the first 27 bits and changing the rest of the bits to
0s. 1 167 1 19
1 83 1 9
1 41 1 99
0 20 0 49
0 10 0 24
1 5 0 12
0 2 1 6
1 1 1 3
The last address can be found by keeping the first 27 1
18.43
Example 18.2 S
We repeat Example 18.1 using the mask. The mask in dotted-decimal
notation is 256.256.256.224.
The AND, OR, and NOT operations can be applied to individual bytes
using calculators and applets at the book website.
18.44
Example 18.3 S
In classless addressing, an address cannot per se define the
block the address belongs to. For example, the address
230.8.24.56 can belong to many blocks. Some of them are
shown below with the value of the prefix associated with
that block.
18.45
Figure 18.22: Network address
The network address is the identifier of the network. After the network
address has been found, the router consults its forwarding table to
find the corresponding interface from which the packet should be sent
18.46 out.
Example 18.4 S
An ISP has requested a block of 1000 addresses. Since 1000
is not a power of 2, 1024 addresses are granted. The prefix
length is calculated as n = 32 − log21024 = 22.
An available block, 18.14.12.0/22, is granted to the ISP.
It can be seen that the first address in decimal is
302,910,464, which is divisible by 1024.
18.47
Subnetting
An organization (or an ISP) that is granted a range of addresses may
divide the range into several subranges and assign each
subrange to a subnetwork (or subnet).
A subnetwork can be divided into several sub-subnetworks.
A sub-subnetwork can be divided into several sub-sub-subnetworks,
and so on.
The following steps need to be carefully followed to guarantee the
proper operation of the subnetworks:
❑ The number of addresses in each subnetwork should be a power
of 2.
❑ The prefix length for each subnetwork should be found using the
following formula: nsub = 32 − log2Nsub
❑ The starting address in each subnetwork should be divisible by
the number of addresses in that subnetwork. This can be
achieved if we first assign addresses to larger subnetworks.
Example 18.5
An organization is granted a block of addresses with the
beginning address 14.24.74.0/24. The organization needs to
have 3 subblocks of addresses to use in its three subnets:
one subblock of 10 addresses, one subblock of 60 addresses,
and one subblock of 120 addresses. Design the subblocks.
Solution
14.24.74.0/24 = 00001110. 00011000. 01001010.00000000
There are 232– 24 = 256 addresses in this block.
The first address is 14.24.74.0/24. = 00001110. 00011000.
01001010.00000000
the last address is 14.24.74.255/24. = 00001110. 00011000.
01001010.11111111
To satisfy the third requirement, we assign addresses to subblocks,
starting with the largest and ending with the smallest one.
18.49
Example 18.5 (continued)
a. The number of addresses in the largest subblock, which requires
120 addresses, is not a power of 2. We allocate 128 addresses.
The subnet mask for this subnet can be found as n1 = 32 − log2
128 = 25. The first address in this block is 14.24.74.0/25; the last
address is 14.24.74.127/25.
14.24.74.0/25 = 00001110. 00011000. 01001010.00000000
First address = 00001110. 00011000. 01001010.00000000 =14.24.74.0/25
Las address = 00001110. 00011000. 01001010.01111111=14.24.74.127/25
18.51
Figure 18.23: Solution to Example 4.5
18.52
Example 18.6
Address Aggregation
When blocks of addresses are combined to create a larger block, routing
can be done based on the prefix of the larger block.
Figure 18.24 shows how four small blocks of addresses are assigned
to four organizations by an ISP. The ISP combines these four blocks
into one single block and advertises the larger block to the rest of the
world. Any packet destined for this larger block should be sent to this
ISP. It is the responsibility of the ISP to forward the packet to the
appropriate organization.
This is similar to routing we can find in a postal network. All
packages coming from outside a country are sent first to the capital
and then distributed to the corresponding destination.
18.53
Figure 18.24: Example of address aggregation
18.54
18.4.4 DHCP
Dynamic Host Configuration Protocol
After a block of addresses are assigned to an
organization, the network administration can
manually assign addresses to the individual hosts or
routers.
However, address assignment in an organization can
be done automatically using the Dynamic Host
Configuration Protocol (DHCP). DHCP is an
application-layer program, using the client-server
paradigm, that actually helps TCP/IP at the network
layer.
18.55
Figure 18.25: DHCP message format
18.56
Figure 18.26: Option format
18.57
Figure 18.27: Operation of DHCP
18.58
Figure 18.28: FSM for the DHCP client
Note that the client can use the IP address only whenit is in the BOUND,
RENEWING, or REBINDING state.
18.59
18.4.5 NAT
18.60
Figure 18.29: NAT
Translation table, In its simplest form, has only two columns: the private address and the
destination address of the packet.
(1+2) When the router translates the source address of the outgoing packet, it also makes note
of the destination address.
(3+4) When the response comes back from the destination, the router uses the source address of
the packet to find the private address of the packet.
18.63
Table 18.1: Five-column translation table
Using a Pool of IP Addresses
Instead of using only one global address (200.24.5.8), the NAT router can use four addresses
(200.24.5.8, 200.24.5.9, 200.24.5.10, and 200.24.5.11). In this case, four private-network hosts can
communicate with the same external host at the same time because each pair of addresses
defines a separate connection.
However, there are still some drawbacks:
- No more than four connections can be made to the same destination.
- No private-network host can access two external server programs (e.g., HTTP and TELNET) at the
same time.
- Two private-network hosts cannot access the same external server program (e.g., HTTP) at the
same time.
Must be
unique
18.64
18-5 FORWARDING OF IP PACKETS
18.65
18.5.1 Destination Address Forwarding
18.66
Figure 18.32: Simplified forwarding module in classless
address
The job of the forwarding module is to search the table, row by row.
In each row, the destination address prefix are kept and suffix are set to 0s.
If the resulting address (which we call the network address), match the address in
the first column, the information in the next two columns is extracted; otherwise the
search continues.
18.67
Example 18.7
Make a forwarding table for router R1 using the
configuration in Figure 18.33.
Solution:
Figure 18.33: Configuration for Example 4.7
Table 18.2 shows the corresponding table.
Table 18.2:
Forwarding table for router R1 in Figure
4.46
Example 18.8
Instead of Table 18.2, we can use Table 18.3, in which the
network address/mask is given in bits.
Table 18.3: Forwarding table for router R1 using prefix
bits
Solution
The router performs the following steps:
1. The first mask (/26) is applied to the
destination address. The result is
180.70.65.128, which does not match the
corresponding network address.
2. The second mask (/25) is applied to the
destination address. The result is 180.70.65.140= 10110100. 01000110. 01000001. 10001100
180.70.65.128, which matches the 1. After applying mask (/26):
corresponding network address. The next-hop 10110100. 01000110. 01000001. 10000000= 180.70.65.128
address and the interface number m0 are
Which does not match 180.70.65.192= 10110100. 01000110.
extracted for forwarding the packet (see 01000001.11000000
Chapter 5). 2. After applying mask (/25):
10110100. 01000110. 01000001. 10000000= 180.70.65.128
which matches:
180.70.65.128= 10110100. 01000110. 01000001. 10000000
18.70
Figure 18.34: Address aggregation
we have two
routers.
R1 is connected to
networks of four
organizations that
each use 64
addresses.
R2 is somewhere far
from R1.
R1 has a longer
forwarding table
because each
packet must be
correctly routed to
the appropriate
organization.
R2 can have a very
small forwarding
table.
For R2, any packet
with destination
140.24.7.0 to
140.24.7.255 is sent
out from interface
m0 regardless
This of the aggregation because the blocks of addresses for four organizations are
is called address
organizationinto one larger block. R2 would have a longer forwarding table if each organization
aggregated
number.
had addresses that could not be aggregated into one block.
18.71
Figure 18.35: Longest mask matching
The forwarding table is sorted from the longest mask to the shortest
mask. so, if there are three masks, /27, /26, and /24, the mask /27
must be the first entry and /24 must be the last.
The figure also shows how local and small ISPs have
assigned addresses.
18.73
Figure 18.35: Hierarchical routing with ISPs S
18.74
18.5.2 Forwarding Based on Label
18.76
Figure 18.37: Example 18.11: Forwarding based on destination
address
18.77
Example 18.12 S
Figure 18.38 shows a simple example of using a label to
access a switching table. Since the labels are used as the
index to the table, finding the information in the table is
immediate.
18.78
Figure 18.38: Example 18.12: Forwarding based on label
18.79
Figure 18.39: MPLS header added to an IP packet
18.80
Figure 18.40: MPLS header made of a stack of labels
18.81
18.5.3 Routers as Packet Switches
18.82