Module-3-Notes
Module-3-Notes
BCS502
MODULE 3
Forwarding
Forwarding is the action done by each router when a packet arrives at one of its
interfaces.
The decision-making table a router uses for this action is called the forwarding table
or the routing table.
When a router receives a packet from one of the attached networks, it needs to send
the packet to another attached network. To decide where the packet should be sent,
it should know the destination address. The destination address is available in the
packet header. Router reads the address from the packet header, checks in the
routing table for the corresponding output interface number and sends the packet.
In the above fig, if B is the destination address, send the packet through interface 2.
Other services expected from network layer:
1. Error Control
Network layer adds a checksum field to the datagram to control any corruption
only in the header, but not in the whole datagram. This checksum prevents
any changes or corruptions in the header of the datagram. Error checking for
data is not included because the packet in the network layer may be
fragmented at each router, which makes error checking at this layer inefficient.
2. Flow Control
If the source produces data at a higher rate than the capacity of the receiver,
the receiver will not be able to handle the data. To control the flow of data,
receiver needs to send some feedback to sender. The flow control is the
mechanism of regulating the amount of data a source can send with
burdening the receiver.
The network layer in the Internet, however, does not directly provide any flow
control.
Reasons: (a)flow control is provided in upper layer. So, flow control in another
level is not necessary. (b)Receivers can use buffers to store extra packets and
in that case flow control will not be required. (c)Since there is no error control
in this layer, the job of this layer is simple at the receiver side. Hence, there is
less chance of packets piling up. They normally get processed fast.
3. Congestion Control
Congestion is a situation where too many packets are present in the
network. Congestion occurs when the number of packets in the network is
more than the network capacity. If the congestion continues, sometimes
the system collapses and no datagrams are delivered. We discuss
congestion control at the network layer later in the chapter although it is
not implemented in the Internet.
4. Quality of Service
The quality of service provided for various applications in the network is
very important. However, this is implemented in upper layers.
5. Security:
Security is another major concern especially in the Internet. In the initial
design, network layer had no security provisions. 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. This
virtual layer is called IPSec
Each packet is routed based on the information contained in its header: source and
destination addresses. The router in this case routes the packet based on the
forwarding table.
Virtual-Circuit Approach: Connection-Oriented Service
Here, 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.
To create a connection-oriented service, a three-phase process is used: setup, data
transfer, and teardown.
Setup Phase:
In the setup phase, a router creates a virtual connection between source and
destination.
To create a connection, Two packets need to be exchanged between the sender and
the receiver: the request packet and the acknowledgment packet.
A request packet is sent from the source to the destination. This packet carries the
source and destination addresses.
Data-Transfer Phase
The second phase is called the data-transfer phase. After all routers have created
their forwarding table, the network-layer packets belonging to one message can be
sent one after another.
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. 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
packet called a teardown packet. Destination B responds with a confirmation packet.
All routers delete the corresponding entries from their tables.
Hierarchy in Addressing
(In a postal network, the postal address includes the country, state, city, street, house
number, and the name of the mail recipient. This is hierarchical addressing)
A 32-bit IPv4 address is also hierarchical
Address is divided 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
A prefix can be fixed length or variable length. The network identifier in the IPv4 was
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.
18.4.2 Classful Addressing
Here, the address space is divided into five classes (class A, B, C, D, and E)
In class A, the network length is 8 bits. If the first one bit is 0, it indicates class A. The
other 7 bits are used as network identifier. This means there are 2 7 = 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.
All addresses that start with 1110 in binary belong to class D and 1111 in binary
belong to class E. Class D is not divided into prefix and suffix. It is used for multicast
addresses. Class E is not divided into prefix and suffix and is used as reserve.
Advantage of Classful Addressing - 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
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.
Subnetting and Supernetting
To alleviate address depletion, two strategies were proposed: subnetting and
supernetting.
Subnetting is a technique used in computer networking to divide a large network into
smaller sub-networks, also known as subnets. This is done to optimize network
performance. Each subnet has its own unique network address, which is used to
identify and route data within that particular subnet.
In subnetting, a portion of the host bits in an IP address is used to create a network
ID, leaving the remaining bits to identify the host within that network.
Given any address, how to find the number of addresses, the first address in the
block, and the last address?
To find the first address, we keep the n leftmost bits and set the (32 − n) rightmost
bits all to 0s. To find the last address, we keep the n leftmost bits and set the (32 − n)
rightmost bits all to 1s.
The number of addresses in the block is found as N = 2 32−n.
Example 18.1
A classless address is given as 167.199.170.82/27.
Example 18.2
We repeat Example 18.1 using the mask. The mask in dotted-decimal notation is
256.256.256.224.
(11111111.11111111.11111111.11100000)
Number of addresses in the block: N = NOT (mask) + 1= 0.0.0.31 + 1 = 32
addresses
First address: First = (address) AND (mask) = 167.199.170.82
Last address: Last = (address) OR (NOT mask) = 167.199.170.255
Network Address
The network address is actually the identifier of the network; each network is
identified by its network address.
The network address is important because it is used in routing a packet to its
destination network.
When a packet arrives at the router from any source host, the router needs to know
to which network the packet should be sent and from which interface the packet
should be sent out.
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.
Block Allocation:
How are the blocks allocated? The ultimate responsibility of block allocation is given
to a global authority called the Internet Corporation for Assigned Names and
Numbers (ICANN). It assigns a large block of addresses to an ISP
Two restrictions need to be applied to the allocated block.
1. The number of requested addresses, N, needs to be a power of 2.
2. The requested block needs to be allocated where there is an adequate
number of contiguous addresses available in the address space. The first
address needs to be divisible by the number of addresses in the block.
Example 18.4 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.
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.
Designing Subnets
We assume the total number of addresses granted to the organization is N,
the prefix length is n, the assigned number of addresses to each subnetwork
is Nsub, and the prefix length for each subnetwork is nsub. Then the following
steps need to be carefully followed to guarantee the proper operation of the
subnetworks.
Solution: There are 2 32 – 24 = 256 addresses in this block. The first address is
14.24.74.0/24; the last address is 14.24.74.255/24.
If we add all addresses in the previous subblocks, the result is 208 addresses,
which means 48 addresses are left in reserve.
Address Aggregation –
blocks of addresses are combined to create a larger block
Example 18.6
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.
Special Addresses
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
0.0.0.0/32 is called the this-host address. It is used whenever a host needs to
send an IP datagram but it does not know its own address to use as the
source address.
Loopback Address
The block 127.0.0.0/8 is called the loopback address. A packet with one of the
addresses in this block as the destination address never leaves the host; it will
remain in the host. Any address in the block is used to test a piece of software
in the machine
Private Addresses - Four blocks are assigned as private addresses:
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, and 169.254.0.0/16. They are for
private internets.
[The main difference between broadcast and multicast is that during the
broadcast, the packet is sent to all of the hosts that are connected to the
network, but during the multicast, the packet is sent only to the hosts that are
supposed to receive it as the intended receivers.]
The 64-byte option field has a dual purpose. It can carry either additional
information or some specific vendor information.
An option is composed of three fields: a 1-byte tag field, a 1-byte length field,
and a variable-length value field. There are several tag fields.
If the tag field is 53, the value field defines one of the 8 message types shown
in Figure 18.26.
DHCP Operation:
Figure 18.27 shows a simple scenario.
1. The joining host creates a DHCPDISCOVER message. This message will
have the transactionID field is set to a random number, the source address
set to 0.0.0.0 (“this host”) and the destination address set to
255.255.255.255 (broadcast address). This message is encapsulated in a
UDP user datagram with the source port set to 68 and the destination port
set to 67. The reason is that the joining host knows neither its own address
nor the server address.
2. The DHCP server or servers (if more than one) responds with a
DHCPOFFER message in which it defines the offered IP address for the
joining host and the IP address of the server. The message also includes
the lease time for which the host can keep the IP address.
3. The joining host receives one or more offers and selects the best of them.
The joining host then sends a DHCPREQUEST message to the server
that has given the best offer.
4. Finally, the selected server responds with a DHCPACK message to the
client if the offered IP address is valid. If the server cannot keep its offer
(for example, if the address is offered to another host in between), the
server sends a DHCPNACK message and the client needs to repeat the
process.
client server
DHCPDISCOVER
DHCPOFFER
DHCPREQUEST
time
Reason for using fixed port numbers is: assume that a DHCP client and a one more
client, both are waiting to receive a response from their corresponding server and
both have accidentally used the same temporary port number (56017, for example).
Both hosts receive the response message from the DHCP server and deliver the
message to their clients. The DHCP client processes the message; the other client is
totally confused with a strange message received. Using a well-known port number
prevents the problem.
Using FTP:
The server does not send all of the information that a client may need for joining the
network. In the DHCPACK message, the server defines the pathname of a file in
which the client can find complete information. The client can then use a file transfer
protocol to obtain the rest of the needed information
Error Control:
To provide error control, DHCP uses two strategies. First, DHCP requires that UDP
use the checksum. Second, the DHCP client uses timers and a retransmission policy
if it does not receive the DHCP reply to a request.
Transition States:
When the DHCP client first starts, it is in the INIT state (initializing state). The client
broadcasts a discover message. When it receives an offer, the client goes to the
SELECTING state. After it selects an offer, it sends a request message and goes to
the REQUESTING state.
If an ACK arrives while the client is in this state, it goes to the BOUND state
When the lease is 50 percent expired, the client tries to renew it by moving to the
RENEWING state.
If the lease is not renewed and the lease time is 75 percent expired, the client moves
to the REBINDING state.
If the server agrees with the lease (ACK message arrives), the client moves to the
BOUND state.
18.4.5 Network Address Resolution (NAT)
For example, assume that in a small business with 20 computers the maximum
number of computers that access the Internet simultaneously is only 4. Most of the
computers are either doing some task that does not need Internet access or
communicating with each other. The business can use 20 (or 25) addresses from the
private block addresses (discussed before) for internal communication; five
addresses for universal communication can be assigned by the ISP.
Network Address Translation (NAT) is a technology that allows a site to use a set of
private addresses for internal communication and a set of global Internet addresses
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.
Global
address
As the figure shows, the private network uses private addresses. The rest of the
Internet sees only the NAT router with the address 200.24.5.8.
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. For this, NAT router
uses a translation table.
IPv4 Datagram
A router has a flow label table. The table has an entry for each active flow label; each
entry defines the services required by the corresponding flow label. When the router
receives a packet, it consults its flow label table to find the corresponding entry for
the flow label value defined in the packet. It then provides the packet with the
services mentioned in the entry
An IPv6 packet is made of a base header and some extension headers. The length
of the base header is fixed at 40 bytes. However, the base header can be followed
by up to six extension headers. These are hop-by-hop option, source routing,
fragmentation, authentication, encrypted security payload, and destination option.
Hop-by-Hop Option:
The hop-by-hop option is used when the source needs to pass information to all
routers visited by the datagram. It can be to inform about certain management,
debugging, or control functions Or to inform about the size of packet if its more than
the usual 65,535 bytes.
Destination Option
The destination option is used when the source needs to pass information to the
destination only. Intermediate routers are not permitted access to this information.
Source Routing
source routing is a method that allows the sender of a packet to specify the route
that the packet should take through the network.
Fragmentation
In IPv6, only the original source can fragment. A source must use a Path MTU
Discovery technique to find the smallest MTU supported by any network on the path.
The source then fragments using this knowledge.
Authentication
The authentication extension header has a dual purpose:
(a) it validates the message sender. This is needed so the receiver can be sure
that a message is from the genuine sender
(b) it ensures the integrity of data. This is needed to check that the data is not
altered in transition by some hacker.
Unicast Routing
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.
Least-Cost Trees
A least-cost tree is a tree with the source router as the root that spans the
whole graph (visits all other nodes) and in which the path between the root
and any other node is the shortest.
Properties of least cost tree:
1. The least-cost route from X to Y in X’s tree is the inverse of the least-cost
route from Y to X in Y’s tree; the cost in both directions is the same.
2. For example, in Figure 20.2, we can go from A to G in A’s tree using the
route (A → B → E → F → G). We can also go from A to E in A’s tree (A →
B → E) and then continue in E’s tree using the route (E → F → G). The
combination of the two routes in the second case is the same route as in
the first case. The cost in the first case is 9; the cost in the second case is
also 9 (6 + 3).
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, . . .)
Dij is the shortest distance and cij is the cost between nodes i and j.
A distance vector can represent least-cost paths in a least-cost tree. The question is
how each node in an internet originally creates the corresponding vector. Each node
in an internet, when it is booted, creates a very basic distance vector with the
minimum information the node can obtain from its neighbourhood. The node sends
some greeting messages and discovers the identity of the immediate neighbors and
the distance between itself and each neighbor. It then makes a simple distance
vector.
To improve these vectors, the nodes in the internet need to help each other by
exchanging information. After each node has created its vector, it sends a copy of
the vector to all its immediate neighbors. After a node receives a distance vector
from a neighbor, it updates its distance vector using the Bellman-Ford equation
(second case).
Distance-Vector Routing Algorithm
Refer to lab program
Count to Infinity
A problem with distance-vector routing is that any decrease in cost (good news)
propagates quickly, but any increase in cost (bad news) will propagate slowly. The
problem is referred to as count to infinity. It sometimes takes several updates before
the cost for a broken link is recorded as infinity by all routers.
One solution to instability is called split horizon. In this strategy, instead of flooding
the table through each interface, each node sends only part of its table through each
interface. If, according to its table, node B thinks that the optimum route to reach X is
via A, it does not need to advertise this piece of information to A; the information has
come from A (A already knows).
Poison Reverse
Using the split-horizon strategy has one drawback. Normally, the routing protocol
uses a timer, and if there is no news about a route, the node deletes the route from
its table. When a node B eliminates the route to X from its advertisement to A, node
A cannot guess whether this is due to the split-horizon strategy or because B has not
received any news about X recently. In the poison reverse strategy B can still
advertise the value for X, but if the source of information is A, it can replace the
distance with infinity as a warning
in the link-state routing algorithm, each router tells the whole internet what it knows
about its neighbors.
Figure 20.10 shows the formation of the least-cost tree for the graph in Figure 20.8
using Dijkstra’s algorithm.
Initialize source node with value 0 and all other nodes infinity.
Identify the non-coloured node with least cost value. Change colour. Change
incoming lines to solid lines. Identify costs of its immediate neighbours. If it is
minimum than existing value, connect them through dotted line and replace the
value. Repeat till all the nodes change colour.
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.
Figure 20.13 shows the path vector of node C after two events.
Hierarchical Routing
The Internet today is made of a huge number of networks and routers that connect
them. It is obvious that routing in the Internet cannot be done using a single
protocol for two reasons: a scalability problem and an administrative issue.
Scalability problem means that the size of the forwarding tables becomes huge
The administrative issue is related to administrator needs to have control in its
system.
Autonomous Systems
Each ISP is an autonomous system. Each AS is given an autonomous number
(ASN). The autonomous systems are categorized according to the way they are
connected to other ASs. We have stub ASs, multihomed ASs, and transient ASs.
Stub AS. A stub AS has only one connection to another AS. The data traffic can be
either initiated or terminated in a stub AS; the data cannot pass through it. A good
example of a stub AS is the customer network, which is either the source or the
destination.
Multihomed AS. A multihomed AS can have more than one connection to other ASs,
but it does not allow data traffic to pass through it. A good example of such an AS is
some of the customer ASs that may use the services of more than one provider
network, but their policy does not allow data to be passed through them.
Transient AS. A transient AS is connected to more than one other AS and also
allows the traffic to pass through. The provider networks and the backbone are good
examples of transient ASs.
AS2, AS3, and AS4 are stub autonomous systems; AS1 is a transient one.
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.
RIP prevents routing loops by limiting the number of hops allowed in a path from
source and destination. The maximum hop count allowed for RIP is 15 and a hop
count of 16 is considered as network unreachable.
RIP Implementation
RIP runs at the application layer, but creates forwarding tables for IP at the network
later. RIP has gone through two versions: RIP-1 and RIP-2.
RIP Messages
RIP has two types of messages: request and response. A request message is
sent by a router that has just come up. A response (or update) message is
sent only in answer to a request message or is sent periodically or when there
is a change in the forwarding table.
RIP Algorithm
RIP implements the same algorithm as the distance-vector routing algorithm
we discussed in the previous section. However, some changes need to be
made:
❑ Instead of sending only distance vectors, a router needs to send the whole
contents of its forwarding table in a response message.
❑ The receiver adds one hop to each cost and changes the next router field
to the address of the sending router.
Timers in RIP
RIP uses three timers to support its operation.
The periodic timer controls the advertising of regular update messages. The
timer counts down; when zero is reached, the update message is sent, and
the timer is randomly set once again.
The expiration timer governs the validity of a route. Every time a new update
for the route is received, the timer is reset. If there is a problem on an internet
and no update is received within the allotted expiration time, the route is
considered expired
The garbage collection timer is used to remove a route from the forwarding
table when a route becomes invalid.
Performance
Update Messages. The update messages in RIP have a very simple format
and are sent only to neighbors; They do not normally create traffic because
the routers try to avoid sending them at the same time.
Convergence of Forwarding Tables. RIP uses the distance-vector algorithm,
which can converge slowly if the domain is large, but, since RIP allows only
15 hops in a domain (16 is considered as infinity), there is normally no
problem in convergence.
Robustness. The Routing Information Protocol (RIP) is not a robust routing
protocol. If there is a failure or corruption in one router, the problem will be
propagated to all routers and the forwarding in each router will be affected.
Authentication
this prevents a malicious entity from sending OSPF messages to a router and
causing the router to become part of the routing system to which it actually
does not belong.
OSPF Algorithm
OSPF implements the link-state routing algorithm we discussed in the
previous section. However, some changes and augmentations need to be
added to the algorithm:
❑ After each router has created the shortest-path tree, the algorithm needs to
use it to create the corresponding routing algorithm.
❑ The algorithm needs to be augmented to handle sending and receiving all
five types of messages.
performance of OSPF:
Update Messages- The link-state messages in OSPF have a somewhat
complex format. these messages may create heavy traffic and use a lot of
bandwidth.
Convergence of Forwarding Tables- When the flooding of LSPs is completed,
each router can create its own shortest-path tree and forwarding table;
convergence is fairly quick.
Robustness. The OSPF protocol is more robust than RIP because, after
receiving the completed LSDB, each router is independent and does not
depend on other routers in the area.
Each autonomous system in this figure uses one of the two common
intradomain protocols, RIP or OSPF.
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).
Operation of External BGP (eBGP)
The eBGP variation of BGP allows two physically connected border routers in
two different ASs to exchange messages.
For example, in fig 20.24, message number 1 is sent by router R1 and tells
router R5 that N1, N2, N3, and N4 can be reached through router R1 . When
R5 receives any packet destined for these four networks, it can use its
forwarding table and find that the next router is R1.
To address the above two problems, we need to allow all pairs of routers (border or
non-border) to run the second variation of the BGP protocol, iBGP.
Path Attributes
In both intradomain routing protocols (RIP or OSPF), a destination is normally
associated with two pieces of information: next hop and cost. The first one shows the
address of the next router to deliver the packet; the second defines the cost to the
final destination.
Inter domain routing BGP needs more information about how to reach the final
destination. In BGP these pieces are called path attributes. It uses 7 path attributes.
The format for an attribute is shown in Figure 20.29.
The first byte in each attribute defines the four attribute flags
The next byte defines the type of attributes. There are 7 types.
ORIGIN (type 1) defines the source of the routing information.
AS-PATH (type 2) defines the list of autonomous systems through which the
destination can be reached.
NEXT-HOP (type 3) defines the next router to which the data packet should be
forwarded.
MULT-EXIT-DISC (type 4) -if router has multiple paths to the destination with
different values related to these attributes, the one with the lowest value is selected.
LOCAL-PREF (type 5) - The routes the administrator prefers are given a higher local
preference value
ATOMIC-AGGREGATE (type 6) - defines the destination prefix as not aggregate
AGGREGATOR (type 7) emphasizes that the destination prefix is an aggregate.
The attribute value length defines the length of the attribute value field
Route Selection
The route selection process in BGP is not as easy as the ones in the intradomain
routing protocol that is based on the shortest-path tree. A route in BGP has some
attributes attached to it.
The router extracts the routes which meet the criteria in each step. If only one route
is extracted, it is selected and the process stops; otherwise, the process continues
with the next step.
Messages
BGP uses four types of messages for communication between the BGP speakers
across the ASs and inside an AS: open, update, keepalive, and notification
Performance -BGP performance can be compared with RIP. BGP exchanges a lot of
messages to create forwarding tables, but BGP is free from loops and count-to-
infinity.