0% found this document useful (0 votes)
6 views46 pages

Computer Network (Unit-3)

Uploaded by

ejarjun777
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views46 pages

Computer Network (Unit-3)

Uploaded by

ejarjun777
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

COMOPUTER NETWORKS UNIT-III

UNIT III

Introduction to Network Layer


The network layer in the TCP/IP protocol suite is responsible for the host-to-host delivery of datagrams. It
provides services to the transport layer and receives services from the data-link layer.

3.1 NETWORK- LAYER SERVICES


Figure 18.1 shows the communication between Alice and Bob at the network layer.

1
COMOPUTER NETWORKS UNIT-III

3.1.1 Packetizing:
 The first duty of the network layer is definitely packetizing: encapsulating the payload(data received
from upper layer) 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.
 The source host receives the payload from an upper-layer protocol, adds a header that contains the
source and destination addresses and some other information that is required by the network-layer
protocol and delivers the packet to the data-link layer.
 The source is not allowed to change the content of the payload unless it is too large for delivery and
needs to be fragmented.
 The destination host receives the network-layer packet from its data-link layer, decapsulates the
packet, and delivers the payload to the corresponding upper-layer protocol.
 If the packet is fragmented at the source or at routers along the path, the networklayer is responsible
for waiting until all fragments arrive, reassembling them, and delivering them to the upper-layer
protocol.
 The routers in the path are not allowed to decapsulate the packets they received unless the packets
need to be fragmented. The routers are not allowed to change source and destination addresses either.
They just inspect the addresses for the purpose of forwarding the packet to the next network on the
path.
3.1.2 Routing and Forwarding
1. Routing:
 The network layer is responsible for routing the packet from its source to the destination.
 A physical network is a combination of networks (LANs and WANs) and routers that connect
them. 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 among these possible routes.
 The network layer needs to have some specific strategies for defining the best route.
 In the Internet today, 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.

2
COMOPUTER NETWORKS UNIT-III

2. Forwarding:
 If routing is applying strategies and running some routing protocols to create the decision-
making tables for each router, forwarding can be defined as the action applied by each router
when a packet arrives at one of its interfaces.
 The decision-making table a router normally uses for applying this action is sometimes called
the forwarding table and sometimes the routing table.
 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. Figure 18.2 shows the idea of the forwarding process in a router.

3. Error Control
 Although error control also can be implemented in the network layer, the designers of the
network layer in the Internet ignored this issue for the data being carried by the network layer.
4. Flow Control
 Flow control regulates the amount of data a source can send without overwhelming the
receiver.
 If the upper layer at the source computer produces data faster than the upper layer at the
destination computer can consume it, the receiver will be overwhelmed with data.
 To control the flow of data, the receiver needs to send some feedback to the sender to inform
the latter that it is overwhelmed with data.
 The network layer in the Internet, however, does not directly provide any flow control.

3
COMOPUTER NETWORKS UNIT-III

 The datagrams are sent by the sender when they are ready, without any attention to the
readiness of the receiver.
5. Congestion Control
 Another issue in a network-layer protocol is congestion control.
 Congestion in the network layer is a situation in which too many datagrams are present in an
area of the Internet.
 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. However, as more datagrams
are dropped, the situation may become worse because, due to the error control mechanism at
the upper layers, the sender may send duplicates of the lost packets.
 If the congestion continues, some times a situation may reach a point where the system
collapses and no datagrams are delivered.
6. Quality of Service
 As the Internet has allowed new applications such as multimedia communication (in
particular real-time communication of audio and video), the quality of service (QoS) of the
communication has become more and more important.
 The Internet has thrived by providing better quality of service to support these applications.
However, to keep the network layer untouched, these provisions are mostly implemented in
the upper layer.
7. Security
 Another issue related to communication at the network layer is security.
 Security was not a concern when the Internet was originally designed because it was used by a
small number of users at universities for research activities; other people had no access to the
Internet.
 The network layer was designed with no security provision. Today, however, security is a big
concern. To provide security for a connectionless network layer, we need to have another virtual
level that changes the connectionless service to a connection-oriented service.

4
COMOPUTER NETWORKS UNIT-III

3.2 PACKET SWITCHING


 A router, in fact, is a switch that creates a connection between an input port and an output port (or a
set of output ports), just asan electrical switch connects the input to the output to let electricity flow.
 Although in data communication switching techniques are divided into two broad categories, circuit
switching and packet switching, only packet switching is used at the network layer because the unit of
data at this layer is a packet.
3.2.1 Datagram Approach: Connectionless Service
 In the datagram approach, the forwarding decision is based on the destination address of the
packet.
 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.

 When the network layer provides a connectionless service, each packet travelling in the Internet is an
independent entity; there is no relationship between packets belonging to the same message.
 The switches in this type of network are called routers. A packet belonging to a message may be
followed by a packet belonging to the same message or to a different message. A packet may be
followed by a packet coming from the same or from a different source.
 Each packet is routed based on the information contained in its header: source and destination
addresses.
 The destination address defines where it should go; the source address defines where it comes from.

5
COMOPUTER NETWORKS UNIT-III

 The router in this case routes the packet based only on the destination address. The source address
may be used to send an error message to the source if the packet is discarded. Figure 18.4 shows the
forwarding process in a router in this case. We have used symbolic addresses such as A and B.

3.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.
 Figure 18.5 shows the concept of connection-oriented service.

6
COMOPUTER NETWORKS UNIT-III

 Each packet is forwarded based on the label in the packet. To follow the idea of connection-oriented
design to be used in the Internet, we assume that the packet has a label when it reaches the router.
 Figure 18.6 shows the idea. In this case, the forwarding decision is based on the value of the label, or
virtual circuit identifier, as it is sometimes called.

 To create a connection-oriented service, a three-phase process is used: setup, data transfer, and
teardown. In the setup phase, the source and destination addresses of the sender and receiver are used
to make table entries for the connection-oriented service.
 In the teardown phase, the source and destination inform the router to delete the corresponding
entries. Data transfer occurs between these two phases.
Setup Phase
 In the setup phase, a router creates an entry for a virtual circuit. For example, suppose source A needs
to create a virtual circuit to destination B. Two auxiliary packets need to be exchanged between the
sender and the receiver: the request packet and the acknowledgment packet.
Request packet
 A request packet is sent from the source to the destination. This auxiliary packet carries the source
and destination addresses. Figure 18.7 shows the process.

7
COMOPUTER NETWORKS UNIT-III

1. Source A sends a request packet to router R1.


2. Router R1 receives the request packet. It knows that a packet going from A to B goes out through
port 3. How the router has obtained this information is a point covered later. For the moment, assume
that it knows the output port. The router creates an entry in its table for this virtual circuit, but it is
only able to fill three of the four columns. The router assigns the incoming port (1) and chooses an
available incoming label (14) and the outgoing port (3). It does not yet know the outgoing label,
which will be found during the acknowledgment step. The router then forwards the packet through
port 3 to router R3.
3. Router R3 receives the setup request packet. The same events happen here as at router R1; three
columns of the table are completed: in this case, incoming port (1), incoming label (66), and outgoing
port (3).
4. Router R4 receives the setup request packet. Again, three columns are completed: incoming port
(1), incoming label (22), and outgoing port (4).
5. Destination B receives the setup packet, and if it is ready to receive packets from A, it assigns a
label to the incoming packets that come from A, in this case 77, as shown in Figure 18.8. This label
lets the destination know that the packets come from A, and not from other sources.
Acknowledgment Packet
 A special packet, called the acknowledgment packet, completes the entries in the switching tables.
Figure 18.8 shows the process.

8
COMOPUTER NETWORKS UNIT-III

1. The destination sends an acknowledgment to router R4. The acknowledgment carries the global
source and destination addresses so the router knows which entry in the table is to be completed. The
packet also carries label 77, chosen by the destination as the incoming label for packets from A.
Router R4 uses this label to complete the outgoing label column for this entry. Note that 77 is the
incoming label for destination B, but the outgoing label for router R4.
2. Router R4 sends an acknowledgment to router R3 that contains its incoming label in the table,
chosen in the setup phase. Router R3 uses this as the outgoing label inthe table.
3. Router R3 sends an acknowledgment to router R1 that contains its incoming label in the table,
chosen in the setup phase. Router R1 uses this as the outgoing label in the table.
4. Finally router R1 sends an acknowledgment to source A that contains its incoming glabel in the
table, chosen in the setup phase.
5. The source uses this as the outgoing label for the data packets to be sent to destination B.
Data Transfer Phase
 The second phase is called the data-transfer phase.
 After all routers have created their forwarding table for a specific virtual circuit, then the network-
layer packets belonging to one message can be sent one after another.
 In Figure 18.9, we show the flow of a single packet, but the process is the same for 1, 2, or 100
packets.
 The source computer uses the label 14, which it has received from router R1 in the setup phase.
Router R1 forwards the packet to router R3, but changes the label to 66.
9
COMOPUTER NETWORKS UNIT-III

 Router R3 forwards the packet to router R4, but changes the label to 22. Finally, router R4 delivers
the packet to its final destination with the label 77.
 All the packets in the message follow the same sequence of labels, and the packets arrive in order at
the destination.

Teardown Phase
 In the teardown phase, source A, after sending all packets to B, sends a special packetcalled a
teardown packet. Destination B responds with a confirmation packet. All routers delete the
corresponding entries from their tables.
3.3 NETWORK-LAYER PERFORMANCE
 The upper-layer protocols that use the service of the network layer expect to receive an ideal service,
but the network layer is not perfect.
 The performance of a network can be measured in terms of delay, throughput, and packet loss.
Congestion control is an issue that can improve the performance.
3.3.1 Delay
 All of us expect instantaneous response from a network, but a packet, from its source to its
destination, encounters delays.
 The delays in a network can be divided into four types: transmission delay, propagation delay,
processing delay, and queuing delay.
 Let us first discuss each of these delay types and then show how to calculate a packet delay from the
source to the destination.

10
COMOPUTER NETWORKS UNIT-III

1. Transmission Delay
 A source host or a router cannot send a packet instantaneously.
 A sender needs to put the bits in a packet on the line one by one. If the first bit of the packet is put
on the line at time t1 and the last bit is put on the line at time t2, transmission delay of the packet
is(t2 − t1). Definitely, the transmission delay is longer for a longer packet and shorter if the sender
can transmit faster. In other words, the transmission delay is
Delaytr= (Packet length) / (Transmission rate).
 For example, in a Fast Ethernet LAN (see Chapter 13) with the transmission rate of100 million
bits per second and a packet of 10,000 bits, it takes (10,000)/(100,000,000)or 100 microseconds
for all bits of the packet to be put on the line.
2. Propagation Delay
 Propagation delay is the time it takes for a bit to travel from point A to point B in the transmission
media.
 The propagation delay for a packet-switched network depends on the propagation delay of each
network (LAN or WAN).
 The propagation delay depends on the propagation speed of the media, which is 3 × 108
meters/second in a vacuum and normally much less in a wired medium; it also depends on the
distance of the link. In other words, propagation delay is
Delaypg= (Distance) / (Propagation speed).
 For example, if the distance of a cable link in a point-to-point WAN is 2000 meters and the
propagation speed of the bits in the cable is 2 × 108 meters/second, then the propagation delay is
10 microseconds.
3. Processing Delay
 The processing delay is the time required for a router or a destination host to receive a packet
from its input port, remove the header, perform an error detection procedure, and deliver the
packet to the output port (in the case of a router) or deliver the packet to the upper-layer protocol
(in the case of the destination host).
 The processing delay may be different for each packet, but normally is calculated as an average.
Delaypr= Time required to process a packet in a router or a destination host
4. Queuing Delay
 Queuing delay can normally happen in a router. A router has an input queue connected to each
of its input ports to store packets waiting to be processed; the router also has an output queue
connected to each of its output ports to store packets waiting to be transmitted.

11
COMOPUTER NETWORKS UNIT-III

 The queuing delay for a packet in a router is measured as the time a packet waits in the input
queue and output queue of a router.
 We can compare the situation with a busy airport. Some planes may need to wait to get the
landing band (input delay); some planes may need to wait to get the departure band(output
delay).
Delayqu= The time a packet waits in input and output queues in a router
5. Total Delay
 Assuming equal delays for the sender, routers, and receiver, the total delay (source-to
destination delay) a packet encounters can be calculated if we know the number of routers, n,
in the whole path.
Total delay = (n + 1) (Delaytr+ Delaypg+ Delaypr) + (n) (Delayqu)
Note that if we have n routers, we have (n + 1) links. Therefore, we have (n + 1)transmission delays
related to n routers and the source, (n + 1) propagation delays related to (n + 1) links, (n + 1)
processing delays related to n routers and the destination, and only n queuing delays related to n
routers.
3.3.2 Throughput
 Throughput at any point in a network is defined as the number of bits passing through the point in a
second, which is actually the transmission rate of data at that point.
 In a path from source to destination, a packet may pass through several links (networks),each with a
different transmission rate. How, then, can we determine the throughput of the whole path? To see the
situation, assume that we have three links, each with a different transmission rate, as shown in Figure
18.10.

 In this figure, the data can flow at the rate of 200 kbps in Link1. However, when the data arrives at
router R1, it cannot pass at this rate. 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

12
COMOPUTER NETWORKS UNIT-III

sent. In other words, the average rate of the data flow in Link3 is also 100 kbps. We can conclude that
the average data rate for this path is 100 kbps, the minimum of the three different data rates.
 The figure also shows that we can simulate the behaviour of each link with pipes of different sizes;
the average throughput is determined by the bottleneck, the pipe with the smallest diameter.
 In general, in a path with n links in series, we have Although the situation in Figure 18.10 shows how
to calculate the throughput when the data is passed through several links, the actual situation in the
Internet is that the data normally passes through two access networks and the Internet backbone, as
shown in Figure 18.11.

3.3.3 Packet Loss


 Another issue that severely affects the performance of communication is the number of packets lost
during transmission.
 When a router receives a packet while processing another packet, the received packet needs to be
stored in the input buffer waiting for its turn. A router, however, has an input buffer with a limited
size. A time may come when the buffer is full and the next packet needs to be dropped. The effect of
packet loss on the Internet network layer is that the packet needs to be resent, which in turn may
create overflow and cause more packet loss. A lot of theoretical studies have been done inqueuing
theory to prevent the overflow of queues and prevent packet loss.
3.3.4 Congestion Control
 Congestion control is a mechanism for improving performance.
 Congestion at the network layer is related to two issues, throughput and delay.
 Figure 18.13 shows these two performance measures as functions of load.

13
COMOPUTER NETWORKS UNIT-III

 When the load is much less than the capacity of the network, the delay is at a minimum.
 This minimum delay is composed of propagation delay and processing delay, both of which are
negligible. However, when the load reaches the network capacity, the delay increases sharply because
we now need to add the queuing delay to the total delay. Note that the delay becomes infinite when
the load is greater than the capacity. When the load is below the capacity of the network, the
throughput increases proportionally with the load.
 Open-Loop Congestion Control
 In open-loop congestion control, policies are applied to prevent congestion before it happens.
In these mechanisms, congestion control is handled by either the source or the destination. We
give a brief list of policies that can prevent congestion.
1. Retransmission Policy
 Retransmission is sometimes unavoidable. If the sender feels that a sent packet is
lost or corrupted, the packet needs to be retransmitted.
 Retransmission in general may increase congestion in the network. However, a
good retransmission policy can prevent congestion. The retransmission policy and
the retransmission timers must be designed to optimize efficiency and at the same
time prevent congestion.
2. Window Policy
 The type of window at the sender may also affect congestion.
 The Selective Repeat window is better than the Go-Back-N window for congestion
control.
 In the Go-Back-N window, when the timer for a packet times out, several packets
may be resent, although some may have arrived safe and sound at the receiver.
 This duplication may make the congestion worse.

14
COMOPUTER NETWORKS UNIT-III

 The Selective Repeat window, on the other hand, tries to send the specific packets
that have been lost or corrupted.
3. Acknowledgment Policy
 The acknowledgment policy imposed by the receiver may also affect congestion.
 If the receiver does not acknowledge every packet it receives, it may slow down
the sender and help prevent congestion.
 Several approaches are used in this case. A receiver may send an acknowledgment
only if it has a packet to be sent or a special timer expires. A receiver may decide
to acknowledge only N packets at a time.
3.4 IPV4 ADDRESSES
 The identifier used in the IP layer of the TCP/IP protocol suite to identify the connection of each
device to the Internet is called the Internet address or IP address.
 An IPv4address is a 32-bit address that uniquely and universally defines the connection of a host or a
router to the Internet.
 The IP address is the address of the connection, not the host or the router, because if the device is
moved to another network, the IP address may be changed.
 IPv4 addresses are unique in the sense that each address defines one, and only one, connection to the
Internet. If a device has two connections to the Internet, via two networks, it has two IPv4 addresses.
3.4.1 Address Space
 A protocol like IPv4 that defines addresses has an address space.
 An address space is the total number of addresses used by the protocol.
 If a protocol uses b bits to define an address, the address space is 2b because each bit can have two
different values (0 or 1).
 IPv4 uses 32-bit addresses, which means that the address space is 232 or 4,294,967,296(more than
four billion). If there were no restrictions, more than 4 billion devices could be connected to the
Internet.
Notation
 There are three common notations to show an IPv4 address: binary notation (base 2), dotted-
decimal notation (base 256), and hexadecimal notation (base 16).
 In binary notation, an IPv4 address is displayed as 32 bits. To make the address more readable, one
or more spaces are usually inserted between each octet (8 bits). Each octet is often referred to as a
byte.

15
COMOPUTER NETWORKS UNIT-III

 To make the IPv4 address more compact and easier to read, it is usually written in decimal form with
a decimal point (dot) separating the bytes. This format is referred to as dotted-decimal notation.
 Note that because each byte (octet) is only 8 bits, each number in the dotted-decimal notation is
between 0 and 255.
 We sometimes see anIPv4 address in hexadecimal notation. Each hexadecimal digit is equivalent to
four bits.
 Figure 18.16 shows an IP address in the three discussed notations.

Hierarchy in Addressing
 In any communication network that involves delivery, such as a telephone network or a postal
network, the addressing system is hierarchical.
 In a postal network, the postal address (mailing address) includes the country, state, city, street, house
number, and the name of the mail recipient.
 Similarly, a telephone number is divided into the country code, area code, local exchange, and the
connection.
 A 32-bit IPv4 address is also hierarchical, but divided only into two parts.
 The first part of the address, called the prefix, defines the network; the second part of the address,
called the suffix, defines the node (connection of a device to the Internet).
 Figure18.17 shows the prefix and suffix of a 32-bit IPv4 address.
 The prefix length is n bits and the suffix length is (32 − n) bits.

16
COMOPUTER NETWORKS UNIT-III

 A prefix can be fixed length or variable length. The network identifier in the IPv4was first designed
as a fixed-length prefix.
 This scheme, which is now obsolete, is referred to as classful addressing. The new scheme, which is
referred to as classless addressing, uses a variable-length network prefix.
3.4.2 Classful Addressing
 When the Internet started, an IPv4 address was designed with a fixed-length prefix, butto
accommodate both small and large networks, three fixed-length prefixes were designed instead of one
(n = 8, n = 16, and n = 24).
 The whole address space was divided into five classes (class A, B, C, D, and E), as shown in Figure
18.18. This scheme is referred to as classful addressing.

17
COMOPUTER NETWORKS UNIT-III

 In class A, the network length is 8 bits, but since the first bit, which is 0, defines the class, we can
have only seven bits as the network identifier. This means there are only 27 = 128 networks in the
world that can have a class A address.
 In class B, the network length is 16 bits, but since the first two bits, which are(10)2, define the class,
we can have only 14 bits as the network identifier. This means there are only 214 = 16,384 networks
in the world that can have a class B address.
 All addresses that start with (110)2 belong to class C. In class C, the network length is 24 bits, but
since three bits define the class, we can have only 21 bits as the network identifier. This means there
are 221 = 2,097,152 networks in the world that can have a class C address.
 Class D is not divided into prefix and suffix. It is used for multicast addresses. All addresses that start
with 1111 in binary belong to class E. As in Class D, Class E is not divided into prefix and suffix and
is used as reserve.
Address Depletion
 The reason that classful addressing has become obsolete is address depletion.
 Since the addresses were not distributed properly, the Internet was faced with the problem of the
addresses being rapidly used up, resulting in no more addresses available for organizations and
individuals that needed to be connected to the Internet.
 To understand the problem, let us think about class A. This class can be assigned to only 128
organizations in the world, but each organization needs to have a single network (seen by the rest of
the world) with 16,777,216 nodes (computers in this single network).
 Since there may be only a few organizations that are this large, most of the addresses in this class
were wasted (unused). Class B addresses were designed for midsize organizations, but many of the
addresses in this class also remained unused. Class C addresses have a completely different flaw in
design. The number of addresses that can be used in each network (256) was so small that most
companies were not comfortable using a block in this address class. Class E addresses were almost
never used, wasting the whole class.
Subnetting and Supernetting
 To alleviate address depletion, two strategies were proposed and, to some extent, implemented:
subnetting and supernetting.
 In subnetting, a class A or class B block is divided into several subnets.
 Each subnet has a larger prefix length than the original network.
 For example, if a network in class A is divided into four subnets, each subnet has a prefix of n sub =
10. At the same time, if all of the addresses in a network are not used, subnetting allows the addresses
to be divided among several organizations.
18
COMOPUTER NETWORKS UNIT-III

 While subnetting was devised to divide a large block into smaller ones, supernetting was devised to
combine several class C blocks into a larger block to be attractive to organizations that need more
than the 256 addresses available in a class C block.
Advantage of Classful Addressing
 Although classful addressing had several problems and became obsolete, it had one advantage: Given
an address, we can easily find the class of the address and, since the prefix length for each class is
fixed, we can find the prefix length immediately.
 In other words, the prefix length in classful addressing is inherent in the address; no extra information
is needed to extract the prefix and the suffix.
3.4.3 Classless Addressing
 In classless addressing, variable-length blocks are used that belong to no classes.
 We can have a block of 1 address, 2 addresses, 4 addresses, 128 addresses, and so on.
 In classless addressing, the whole address space is divided into variable length blocks.
 The prefix in an address defines the block (network); the suffix defines the node(device).
Theoretically, we can have a block of 20, 21, 22, . . . , 232 addresses.
 One of the restrictions, as we discuss later, is that the number of addresses in a block needs to be a
power of 2. An organization can be granted one block of addresses.
 Figure 18.19 shows the division of the whole address space into non overlapping blocks.

 Unlike classful addressing, the prefix length in classless addressing is variable.


 We can have a prefix length that ranges from 0 to 32. The size of the network is inversely
proportional to the length of the prefix. A small prefix means a larger network; a large prefix means a
smaller network.
 An address in class A can be thought of as a classless address in which the prefix length is 8.
 An address in class B can be thought of as a classless address in which the prefix is 16, and so on.
 In other words, classful addressing is a special case of classless addressing.

19
COMOPUTER NETWORKS UNIT-III

Prefix Length: Slash Notation


 Since the prefix length is not inherent in the address, we need to separately give the length of the
prefix. In this case, the prefix length, n, is added to the address, separated by a slash.
 The notation is informally referred to as slash notation and formally as classless interdomain routing
or CIDR strategy. An address in classless addressing can then be represented as shown in Figure
18.20.

Extracting Information from an Address


 Given any address in the block, we normally like to know three pieces of information about the block
to which the address belongs: the number of addresses, the first address in the block, and the last
address.
 Since the value of prefix length, n, is given, we can easily find these three pieces of information, as
shown in Figure 18.21.

20
COMOPUTER NETWORKS UNIT-III

Address Mask
 Another way to find the first and last addresses in the block is to use the address mask.
 The address mask is a 32-bit number in which the n leftmost bits are set to 1s and the rest of the bits
(32 −n) are set to 0s.
 A computer can easily find the address mask because it is the complement of (232 −n −1). The reason
for defining a mask in this way is that it can be used by a computer program to extract the
information in a block, using the three bit-wise operations NOT, AND, and OR.
1. The number of addresses in the block N =NOT (mask) +1.
2. The first address in the block =(Any address in the block) AND (mask).
3. The last address in the block =(Any address in the block) OR [(NOT (mask)].
Example
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.

Network Address
 The network address, is particularly important because it is used in routing a packet to its destination
network.
 For the moment, let us assume that an internet is made of m networks and a router with m interfaces.
 When a packet arrives at the router from any source host, the router needs to know to which network
the packet should be sent: from which interface the packet should be sent out.
 Figure 18.22 shows the idea.

21
COMOPUTER NETWORKS UNIT-III

 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 out.
 The network address is actually the identifier of the network; each network is identified by its
network address.
Address Aggregation
 One of the advantages of the CIDR strategy is address aggregation (sometimes called address
summarization or route summarization).
 When blocks of addresses are combined to create a larger block, routing can be done based on the
prefix of the larger block. ICANN assigns a large block of addresses to an ISP. Each ISP in turn
divides its assigned block into smaller sub blocks and grants the sub blocks to its customers.
Special Addresses
 Before finishing the topic of addresses in IPv4, we need to mention five special addresses that are
used for special purposes: this-host address, limited-broadcast address, loopback address, private
addresses, and multicast addresses.
This-host Address
 The only address in the block 0.0.0.0/32 is called the this-host address. It is used whenevera host
needs to send an IP datagram but it does not know its own address to use asthe source address.

Dynamic Host Configuration Protocol (DHCP)


 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.
 DHCP has found such widespread use in the Internet that it is often called a plugand-play protocol. In
can be used in many situations.
 A network manager can configure DHCP to assign permanent IP addresses to the host and routers.
 DHCP can also be configured to provide temporary, on demand, IP addresses to hosts.
DHCP Message Format
 DHCP is a client-server protocol in which the client sends a request message and the server returns a
response message.
 DHCP message in Figure 18.25.
 Most of the fields are explained in the figure, but we need to discuss the option field, which plays a
very important role in DHCP.

22
COMOPUTER NETWORKS UNIT-III

 The 64-byte option field has a dual purpose.


 It can carry either additional information or some specific vendor information.
 The server uses a number, called a magic cookie, in the format of an IP address with the value of
99.130.83.99.

Network Address Resolution (NAT)


 A technology that can provide the mapping between the private and universal addresses, and at the
same time support virtual private networks is Network Address Translation (NAT).
 The technology allows a site to use a set of private addresses for internal communication and a set of
global Internet addresses (at least one) for communication with the rest of the world.
 The site must have only one connection to the global Internet through a NAT-capable router that runs
NAT software. Figure 18.29 shows a simple implementation of NAT.

23
COMOPUTER NETWORKS UNIT-III

 Address Translation All of the outgoing packets go through the NAT router, which replaces the
source address in the packet with the global NAT address.
 All incoming packets also pass through the NAT router, which replaces the destination address in the
packet (the NAT router global address) with the appropriate private address.
 Figure 18.30 shows an example of address translation.
 Translation Table The reader may have noticed that translating the source addresses for an outgoing
packet is straightforward.

Network-Layer Protocols
3.5 INTERNET PROTOCOL (IP)
 Internet Protocol version 4 (IPv4), is responsible for packetizing, forwarding, and delivery of a packet
at the network layer.
 The Internet Control Message Protocol version 4 (ICMPv4) helps IPv4 to handle some errors that
may occur in the network-layer delivery.
 The Internet Group Management Protocol (IGMP) is used to help IPv4 in multicasting.
 The Address Resolution Protocol (ARP) is used to glue the network and data-link layers in mapping
network-layer addresses to link-layer addresses.
 Figure 19.1 shows the positions of these four protocols in the TCP/IP protocol suite.

24
COMOPUTER NETWORKS UNIT-III

 IPv4 is an unreliable datagram protocol—a best-effort delivery service.


 The term best-effort means that IPv4 packets can be corrupted, be lost, arrive out of order, or be
delayed, and may create congestion for the network.
 If reliability is important, IPv4must be paired with a reliable transport-layer protocol such as TCP.
 An example of a more commonly understood best-effort delivery service is the post office.
 IPv4 is also a connectionless protocol that uses the datagram approach. This means that each
datagram is handled independently, and each datagram can follow a different route to the destination.
This implies that datagrams sent by the same source to the same destination could arrive out of

25
COMOPUTER NETWORKS UNIT-III

26
COMOPUTER NETWORKS UNIT-III

3.6 ICMPv4
 The Internet Control Message Protocol version 4 (ICMPv4) is a companion to the IP protocol.
 ICMP itself is a network-layer protocol. However, its messages are not passed directly to the data-
link layer as would be expected. Instead, the messages are first encapsulated inside IP datagrams
before going to the lower layer. When an IP datagram encapsulates
MESSAGES
 ICMP messages are divided into two broad categories: error-reporting messages and query
messages.
 The error-reporting messages report problems that a router or a host (destination) may encounter
when it processes an IP packet.
 The query messages, which occur in pairs, help a host or a network manager get specific information
from a router or another host.
 For example, nodes can discover their neighbors. Also, hosts can discover and learn about routers on
their network and routers can help a node redirect its messages.
 An ICMP message has an 8-byte header and a variable-size data section. Although the general format
of the header is different for each message type, the first 4 bytes are common to all.
 As Figure 19.8 shows, the first field, ICMP type, defines the type of the message.

 The code field specifies the reason for the particular message type. The lastcommon field is the
checksum field. The rest of the header is specific for each message type.
 The data section in error messages carries information for finding the original packet that had the
error. In query messages, the data section carries extra information based on the type of query.

27
COMOPUTER NETWORKS UNIT-III

ICMP checksum

3.7 MOBILE IP
 As mobile and personal computers such as notebooks become increasingly popular, we need to think
about mobile IP, the extension of IP protocol that allows mobile computers to be connected to the
Internet at any location where the connection is possible.
Addressing
 The main problem that must be solved in providing mobile communication using the IP protocol is
addressing.
1. Stationary Hosts
 The original IP addressing was based on the assumption that a host is stationary, attached to one
specific network.
 A router uses an IP address to route an IP datagram. an IP address has two parts: a prefix and a
suffix.
 The prefix associates a host with a network.
 For example, the IP address 10.3.4.24/8 defines a host attached to the network 10.0.0.0/8.
 This implies that a host in the Internet does not have an address that it can carry with itself from one
place to another.
 The address is valid only when the host is attached to the network.
 If the network changes, the address is no longer valid. Routers use this association to route a packet;
they use the prefix to deliver the packet to the network to which the host is attached.
 This scheme works perfectly with stationary hosts.

28
COMOPUTER NETWORKS UNIT-III

2. Mobile Hosts
 When a host moves from one network to another, the IP addressing structure needs tobe
modified. Several solutions have been proposed.
I. Changing the Address
 One simple solution is to let the mobile host change its address as it goes to the new
network.
 The host can use DHCP to obtain a new address to associate it with the new network.
 This approach has several drawbacks.
 First, the configuration files would need to be changed.
 Second, each time the computer moves from one network to another, it must be rebooted.
 Third, the DNS tables need to be revised so that every other host in the Internet is aware of
the change.
 Fourth, if the host roams from one network to another during a transmission, the data
exchange will be interrupted.
 This is because the ports and IP addresses of the client and the server must remain
constant for the duration of the connection.
II. Two Addresses
 The approach that is more feasible is the use of two addresses.
 The host has its original address, called the home address, and a temporary address,
called the care-of address.
 The home address is permanent; it associates the host with its home network, the
network that is the permanent home of the host.
 The care-of address is temporary.
 When a host moves from one network to another, the care-of address changes; it is
associated with the foreign network, the network to which the host moves.
 Figure 19.12 shows the concept.

29
COMOPUTER NETWORKS UNIT-III

3.8 Unicast Routing


 In unicast routing, a packet is routed, hop by hop, from its source to its destination by the help of
forwarding tables.
 The source host needs no forwarding table because it delivers its packet to the default router in its
local network.
 The destination host needs no forwarding table either because it receives the packet from its default
router in its local network. This means that only the routers that glue together the networks in the
internet need forwarding tables. With the above explanation, routing a packet from its source to its
destination means routing the packet from a source router (the default router of the source host) to a
destination router (the router connected to the destination network).
An Internet as a Graph
 To find the best route, an internet can be modeled as a graph.
 A graph in computer science is a set of nodes and edges (lines) that connect the nodes.
 To model an internet as a graph, we can think of each router as a node and each network between a
pair of routers as an edge.
 An internet is, in fact, modeled as a weighted graph, in which each edge is associated with a cost.
 If a weighted graph is used to represent a geographical area, the nodes can be cities and the edges can
be roads connecting the cities; the weights, in this case, are distances between cities.

30
COMOPUTER NETWORKS UNIT-III

 For the moment, we assume that there is a cost associated with each edge. If there is no edge between
the nodes, the cost is infinity. Figure 20.1 shows how an internet can be modeled as a graph.

3.8.1 Least-Cost Routing


 When an internet is modeled as a weighted graph, one of the ways to interpret the best route from the
source router to the destination router is to find the least cost between the two.
 In other words, the source router chooses a route to the destination router in such a way that the total
cost for the route is the least cost among all possible routes.
 In Figure 20.1, the best route between A and E is A-B-E, with the cost of 6. This means that each
router needs to find the least-cost route between itself and all the other routers to be able to route a
packet using this criteria.

31
COMOPUTER NETWORKS UNIT-III

3.9 Routing algorithms


Distance-Vector Routing
 The distance-vector (DV) routing uses to find the best route.
 In distance-vector routing, the first thing each node creates is its own least-cost tree with the
rudimentary information it has about its immediate neighbors.
 The incomplete trees are exchanged between immediate neighbors to make the trees more and more
complete and to represent the whole internet.
 We can say that in distance-vector routing, a router continuously tells all of its neighbors what it
knows about the whole internet (although the knowledge can be incomplete). Before we show how
incomplete least-cost trees can be combined to make complete ones, we need to discuss two important
topics: the Bellman-Ford equation and the concept of distance vectors, which we cover next.
Bellman-Ford Equation
 The heart of distance-vector routing is the famous Bellman-Ford equation.
 This equation is used to find the least cost (shortest distance) between a source node, x, and a
destination node, y, through some intermediary nodes (a, b, c, . . .) when the costs between the source
and the intermediary nodes and the least costs between the intermediary nodes and the destination are
given.
 The following shows the general case in which Dij is the shortest distance and cij is the cost between
nodes i and j.

 In distance-vector routing, normally we want to update an existing least cost with a least cost through
an intermediary node, such as z, if the latter is shorter. In this case, the equation becomes simpler, as
shown below:

32
COMOPUTER NETWORKS UNIT-III

 We can say that the Bellman-Ford equation enables us to build a new least-cost path from previously
established least-cost paths.
 In Figure 20.3, we can think of (a→y), (b→y), and (c→y) as previously established least-cost paths
and (x→y) as the new least-cost path. We can even think of this equation as the builder of a new least-
cost tree from previously established least-cost trees if we use the equation repeatedly.
Distance Vectors
 The concept of a distance vector is the rationale for the name distance-vector routing.
 A least-cost tree is a combination of least-cost paths from the root of the tree to all destinations.
 These paths are graphically glued together to form the tree.
 Distance-vector routing unglues these paths and creates a distance vector, a one-dimensional array to
represent the tree.
 Figure 20.4 shows the tree for node A in the internet in Figure 20.1 and the corresponding distance
vector.

 Figure 20.5 shows all distance vectors for our internet.


 We show the whole vector instead of seven equations for each update in Figure 20.6.
 The figure shows two asynchronous events, happening one after another with some time in

33
COMOPUTER NETWORKS UNIT-III

Distance-Vector Routing Algorithm


Now we can give a simplified pseudocode for the distance-vector routing algorithm, as shown in Table 20.1.
The algorithm is run by its node independently and asynchronously.

34
COMOPUTER NETWORKS UNIT-III

Link-State Routing
 A routing algorithm for creating least-cost trees and forwarding tables is link-state (LS) routing.
 This method uses the term link-state to define the characteristic of a link (an edge) that represents a
network in the internet.
 In this algorithm the cost associated with an edge defines the state of the link.
 Links with lower costs are preferred to links with higher costs; if the cost of a link is infinity, it means
that the link does not exist or has been broken.
Link-State Database (LSDB)
 To create a least-cost tree with this method, each node needs to have a complete map of the network,
which means it needs to know the state of each link.
 The collection of states for all links is called the link-state database (LSDB).
 There is only one LSDB for the whole internet; each node needs to have a duplicate of it to be able to
create the least-cost tree.
 Figure 20.8 shows an example of an LSDB for the graph in Figure 20.1.
 The LSDB can be represented as a two-dimensional array(matrix) in which the value of each cell
defines the cost of the corresponding link.

35
COMOPUTER NETWORKS UNIT-III

 We need to convince ourselves that, after receiving all new LSPs, each node creates the comprehensive
LSDB as shown in Figure 20.9.
 This LSDB is the same for each node and shows the whole map of the internet. In other words, a node
can make the whole map if it needs to, using this LSDB.

Formation of Least-Cost Trees


 To create a least-cost tree for itself, using the shared LSDB, each node needs to run the famous
Dijkstra Algorithm.
 This iterative algorithm uses the following steps:
1. The node chooses itself as the root of the tree, creating a tree with a single node, and sets the total
cost of each node based on the information in the LSDB.
2. The node selects one node, among all nodes not in the tree, which is closest to the root, and adds this
to the tree. After this node is added to the tree, the cost of all other nodes not in the tree needs to be
updated because the paths may have been changed.
3. The node repeats step 2 until all nodes are added to the tree. We need to convince ourselves that the
above three steps finally create the least-cost tree.
Table 20.2 shows a simplified version of Dijkstra’s algorithm.

36
COMOPUTER NETWORKS UNIT-III

Path-Vector Routing
 Both link-state and distance-vector routing are based on the least-cost goal.
 Least-cost routing does not prevent a packet from passing through an area when that area is in the least-
cost path.
 In other words, the least-cost goal, applied by LS or DV routing, does not allow a sender to apply specific
policies to the route a packet may take.
 Aside from safety and security in which the goal of routing is merely reachability: to allow the packet to
reach its destination more efficiently without assigning costs to the route.

37
COMOPUTER NETWORKS UNIT-III

Spanning Trees
 In path-vector routing, the path from a source to all destinations is also determined by the best
spanning tree.
 The best spanning tree, however, is not the least-cost tree; it is the tree determined by the source when
it imposes its own policy.
 If there is more than one route to a destination, the source can choose the route that meets its policy
best.
 A source may apply several policies at the same time. One of the common policies uses the minimum
number of nodes to be visited (something similar to least-cost).
 Another common policy is to avoid some nodes as the middle node in a route.
 Figure 20.11 shows a small internet with only five nodes.
 Each source has created its own spanning tree that meets its policy.
 The policy imposed by all sources is to use the minimum number of nodes to reach a destination.

38
COMOPUTER NETWORKS UNIT-III

 The spanning tree selected by A and E is such that the communication does not pass through D as a
middle node.
 Similarly, the spanning tree selected by B is such that the communication does not pass through C as a
middle node.

 Figure 20.12 shows all of these path vectors for our internet in Figure 20.11.
 Note, however, that we do not mean that all of these tables are created simultaneously; they are created
when each node is booted.
 The figure also shows how these path vectors are sent to immediate neighbors after they have been
created (arrows). Each node, after the creation of the initial path vector, sends it to all its immediate
neighbors.
 Each node, when it receives a path vector from a neighbor, updates its path vector using an equation
similar to the Bellman-Ford, but applying its own policy instead of looking for the least cost. We can
define this equation as

39
COMOPUTER NETWORKS UNIT-III

 Figure 20.13 shows the path vector of node C after two events.
 In the first event, node C receives a copy of B’s vector, which improves its vector: now it knows how to
reach node A.
 In the second event, node C receives a copy of D’s vector, which does not change its vector.
 As a matter of fact the vector for node C after the first event is stabilized and serves as its forwarding
table.

Path-Vector Algorithm
 Based on the initialization process and the equation used in updating each forwarding table after receiving
path vectors from neighbors, we can write a simplified version of the path vector algorithm as shown in
Table 20.3.

40
COMOPUTER NETWORKS UNIT-III

41
COMOPUTER NETWORKS UNIT-III

3.10 UNICAST ROUTING PROTOCOLS


3.10.1 Routing Information Protocol (RIP)
 The Routing Information Protocol (RIP) is one of the most widely used intra domain routing
protocols based on the distance-vector routing algorithm we described earlier.
Hop Count
A router in this protocol basically implements the distance-vector routing algorithm shown in Table 20.1.

 First, since a router in an AS needs to know how to forward a packet to different networks
(subnets) in an AS, RIP routers advertise the cost of reaching different networks instead of
reaching other nodes in a theoretical graph.
 Second, to make the implementation of the cost simpler (independent from performance factors of
the routers and links, such as delay, bandwidth, and so on), the cost is defined as the number of
hops, which means the number of networks (subnets) a packet needs to travel through from the
source router to the final destination host.
 Figure 20.15 shows the concept of hop count advertised by three routers from a source host to a
destination host.
 In RIP, the maximum cost of a path can be 15, which means 16 is considered as infinity (no
connection).
Forwarding Tables
 A forwarding table in RIP is a three-column table in which the first column is the address of the
destination network, the second column is the address of the next router to which the packet should
be forwarded, and the third column is the cost (the number of hops) to reach the destination network.
 Figure 20.16 shows the three forwarding tables for the routers in Figure 20.15. Note that the first and
the third columns together convey the same information as does a distance vector, but the cost shows
the number of hops to the destination networks.

42
COMOPUTER NETWORKS UNIT-III

 Although a forwarding table in RIP defines only the next router in the second column, it gives the
information about the whole least-cost tree based on the second property of these trees, discussed in
the previous section.
 For example, R1 defines that the next router for the path to N4 is R2; R2 defines that the next router
to N4 is R3; R3 defines that there is no next router for this path. The tree is then R1 →R2 →R3
→N4.
 The third column is not needed for forwarding the packet, but it is needed for updating the forwarding
table when there is a change in the route.
3.10.2 Open Shortest Path First (OSPF)
 Open Shortest Path First (OSPF) is also an intra domain routing protocol like RIP, but it is based on
the link-state routing protocol.
 OSPF is an open protocol, which means that the specification is a public document.
 Figure 20.19 shows the idea of the cost from a router to the destination host network.
 We can compare the figure with Figure 20.15 for the RIP.

43
COMOPUTER NETWORKS UNIT-III

3.10.3 Border Gateway Protocol Version 4 (BGP4)


 The Border Gateway Protocol version 4 (BGP4) is the only inter domain routing protocol used in
the Internet today.
 BGP4 is based on the path-vector algorithm we described before, but it is tailored to provide
information about the reachability of networks in the Internet.
 BGP4, is a complex protocol.
 Figure 20.24 shows an example of an internet with four autonomous systems. AS2, AS3, and AS4 are
stub autonomous systems; AS1 is a transient one.
 In our example, data exchange between AS2, AS3, and AS4 should pass through AS1.

44
COMOPUTER NETWORKS UNIT-III

 Each autonomous system in this figure uses one of the two common intra domain protocols, RIP or
OSPF.
 Each router in each AS knows how to reach a network that is in its own AS, but it does not know how
to reach a network in another AS.
 To enable each router to route a packet to any network in the internet, we first install a variation of
BGP4, called external BGP (eBGP), on each border router (the one at the edge of each AS which is
connected to a router at another AS).
 We then install the second variation of BGP, called internal BGP (iBGP), on all routers.
 This means that the border routers will be running three routing protocols (intradomain, eBGP, and
iBGP), but other routers are running two protocols (intradomain and iBGP).
Next Generation IP
IPv6 ADDRESSING
 The main reason for migration from IPv4 to IPv6 is the small size of the address space in IPv4. In this
section, we show how the huge address space of IPv6 prevents address depletion in the future.
 An IPv6 address is 128 bits or 16 bytes (octets) long, four times the address length in IPv4.
Representation
 A computer normally stores the address in binary, but it is clear that 128 bits cannot easily be handled
by humans. Several notations have been proposed to represent IPv6 addresses when they are handled
by humans.

 Binary notation is used when the addresses are stored in a computer.


 The colon hexadecimal notation (or colon hex for short) divides the address into eight sections, each
made of four hexadecimal digits separated by colons.
Abbreviation
 Although an IPv6 address, even in hexadecimal format, is very long, many of the digits are zeros.
 In this case, we can abbreviate the address.
 The leading zeros of a section can be omitted.
 Using this form of abbreviation, 0074 can be written as 74, 000F as F, and 0000 as 0.
 Further abbreviation, often called zero compression, can be applied to colon hex notation if there are
consecutive sections consisting of zeros only.
 We can remove all the zeros and replace them with a double semicolon.

45
COMOPUTER NETWORKS UNIT-III

Mixed Notation
 Sometimes we see a mixed representation of an IPv6 address: colon hex and dotted decimal
notation.
 This is appropriate during the transition period in which an IPv4 address is embedded in an IPv6
address (as the rightmost 32 bits).
 We can use the colon hex notation for the leftmost six sections and four-byte dotted-decimal notation
instead of the rightmost two sections.
CIDR Notation
 IPv6 uses hierarchical addressing. For this reason, IPv6 allows slash or CIDR notation.
 For example, the following shows how we can define a prefix of 60 bits using CIDR.

Address Space
 The address space of IPv6 contains 2128 addresses. This address space is 296 times the IPv4
address—definitely no address depletion—as shown, the size of the space is

46

You might also like