CN Module 3 Notes
CN Module 3 Notes
COMPUTER NETWORKS
1. NETWORK-LAYER
1.1 Network Layer Services
1.2 Packet Switching
1.3 IPv4 Addresses
1.4IPv4 Datagram
1.5 IPv6 Datagram
2. INTRODUCTION TO ROUTING ALGORITHMS
2.1 Introduction
2.2 Routing Algorithms
2.3 Unicast Routing Protocols:DVR, LSR, PVR
2.4 Unicast Routing Protocols:RIP, OSPF,BGP
2.5 Multicast Routing:MOSPF
1. NETWORK-LAYER
The network layer in the TCP/IP protocol suite plays a crucial role in ensuring host-to-host
delivery of data. It operates between the data-link layer and the transport layer, providing services
to the latter while receiving services from the former. It is responsible for routing and delivering
packets across various networks, encapsulating data into packets, and decapsulating them at the
destination.
1.1 Network Layer Services
The Internet, a combination of LANs and WANs, consists of many networks connected through
routers and switches. The network layer is involved in:
• Source Host (e.g., Alice): It encapsulates the transport layer packet into a datagram and
hands it over to the data-link layer for transmission.
• Destination Host (e.g., Bob): It decapsulates the received datagram to retrieve the packet and
deliver it to the transport layer.
• Routers (R2, R4, R5, R7): They forward the datagrams across multiple networks until they
reach the destination.
1. Packetizing:
o The network layer encapsulates data from the transport layer into packets (datagrams)
at the source and decapsulates them at the destination.
o The source adds necessary headers, including source and destination addresses, to the
packet.
2. Routing:
o The network layer selects the best route for packets to travel across multiple
networks (LANs, WANs).
o Routers use algorithms to determine the most efficient path from source to
destination.
3. Forwarding:
o Forwarding refers to how routers handle packets upon arrival. Routers look up the
forwarding table or routing table to determine which network interface to send the
packet through.
• Error Control:
o Although the network layer itself doesn’t handle errors directly, the ICMP protocol
helps detect errors, such as when a packet cannot be delivered.
• Flow Control:
o The network layer helps prevent the receiver from becoming overwhelmed with data
by ensuring the sender doesn't send more data than the receiver can process.
• Congestion Control:
o The network layer helps in managing and avoiding congestion in the network by
controlling the flow of packets, especially in high-traffic conditions.
o QoS ensures the network layer delivers data with a certain performance level,
managing delays, throughput, and packet loss.
➢ Packet switching is a method of data transmission in which information is broken into small,
manageable pieces called packets. Each packet is sent independently through a network, and
they may take different routes to reach the destination. Once all packets arrive, they are
reassembled in the correct order to recreate the original message
➢ 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.
➢ Circuit switching is mostly used at the physical layer; the electrical switch mentioned earlier
is a kind of circuit switch.
➢ At the network layer, a message from the upper layer is divided into manageable packets and
each packet is sent through the network.
➢ The source of the message sends the packets one by one; the destination of the message
receives the packets one by one.
➢ The destination waits for all packets belonging to the same message to arrive before
delivering the message to the upper layer
Today, a packet-switched network can use two different approaches to route the packets: the
datagram approach and the virtual circuit approach.
1. Setup Phase
• Goal: Establish a virtual circuit between Source A and Destination B using request and
acknowledgment packets.
• Steps in Setup:
o Request Packet:
1. Source A sends a request packet to Router R1.
2. Router R1:
o Acknowledgment Packet:
1. Destination B sends an acknowledgment packet back to Router R4:
▪ Router R4 fills the outgoing label as 77.
2. Router R4 sends the acknowledgment to Router R3, which fills its outgoing
label as 22.
3. Router R3 sends an acknowledgment to Router R1, which fills its outgoing
label as 66.
4. Router R1 sends the acknowledgment to Source A, which fills its outgoing
label as 14 for future packets.
• Goal: Transfer data between Source A and Destination B once the virtual circuit is
established.
• Steps:
1. Source A labels the packets with Label 14 (from R1).
2. Router R1:
▪ Receives packets with Label 14.
▪ Changes the label to 66 and forwards to Router R3.
3. Router R3:
▪ Receives packets with Label 66.
▪ Changes the label to 22 and forwards to Router R4.
4. Router R4:
▪ Receives packets with Label 22.
3. Teardown Phase
• Packetizing is the primary service provided by IPv4. It defines the format of a packet (called a
datagram) to encapsulate data from the upper layers.
• An IPv4 datagram is a variable-length packet, with a header (20 to 60 bytes) and payload
(data).
• Header:
o 20 to 60 bytes in length.
o Contains crucial fields to ensure the proper routing and handling of the packet.
o Shown in 4-byte (32-bit) sections for easy reference.
• Payload:
o Contains the data from the upper-layer protocols, such as TCP, UDP, or other
transport or network protocols.
1. Version (4 bits):
o Specifies the IP version. For IPv4, the value is always 4.
2. Header Length (HLEN) (4 bits):
o Indicates the length of the header in 4-byte words.
o Helps identify where the header ends and the data (payload) begins.
3. Service Type (8 bits):
o Originally called Type of Service (TOS), now redefined as Differentiated Services
(DiffServ).
o Used for prioritizing different types of network traffic (e.g., voice over IP).
4. Total Length (16 bits):
o Specifies the total length of the datagram, including both header and data, in bytes.
o Helps receivers distinguish between actual data and any padding that might be added
(e.g., in Ethernet frames).
5. Identification, Flags, and Fragmentation Offset:
o Used for fragmenting datagrams that exceeds the maximum transmission unit (MTU)
of the network.
o Allows reassembly of fragmented packets at the destination.
6. Time-to-Live (TTL) (8 bits):
o Limits the number of hops a datagram can take.
o Each router decrements this value, and if it reaches zero, the datagram is discarded.
o Prevents datagrams from endlessly circulating due to routing errors.
7. Protocol (8 bits):
o Identifies the protocol of the encapsulated payload (e.g., TCP = 6, UDP = 17).
o Ensures the correct upper-layer protocol receives the data at the destination
(demultiplexing).
8. Header Checksum (16 bits):
o Used to verify the integrity of the header (not the payload).
o Each router recalculates the checksum since fields like TTL change with every hop.
9. Source and Destination IP Addresses (32 bits each):
3. Payload (Data)
• The payload is the data encapsulated in the datagram, which comes from upper-layer
protocols (e.g., TCP, UDP).
• The payload is the primary reason for sending the datagram, with the header providing the
necessary instructions for delivery.
4. Important Concepts
• An IPv4 address is a 32-bit identifier used to uniquely define the connection of a device (host
or router) to the Internet.
• Better header format: IPv6 uses a new header format in which options are
separated from the base header and inserted, when needed, between the base
header and the data. This simplifies and speeds up the routing process because
most of the options do not need to be checked by routers.
• New options: IPv6 has new options to allow for additional functionalities.
• The address space is the total number of addresses available for use in the IPv4 protocol.
• IPv4 uses 32 bits, so the address space is 2³² (or 4,294,967,296 addresses).
• In theory, this would allow more than 4 billion devices to connect to the Internet, but practical
limitations such as network design reduce the usable address space.
• Classful Addressing divides the IPv4 address space into five classes (A, B, C, D, E),
designed to accommodate different network sizes.
1. Class A:
o Prefix length: 8 bits (first bit is always 0, so only 7 bits are available for network
identification).
o Supports up to 128 networks.
o Address range: [Link] to [Link].
2. Class B:
o Prefix length: 16 bits (first two bits are 10, so 14 bits for network identification).
o Supports up to 16,384 networks.
o Address range: [Link] to [Link].
3. Class C:
o Prefix length: 24 bits (first three bits are 110, so 21 bits for network identification).
o Supports up to 2,097,152 networks.
o Address range: [Link] to [Link].
4. Class D (Multicast):
o First four bits are 1110.
o Reserved for multicast addresses (group communication).
o Address range: [Link] to [Link].
5. Class E (Experimental):
o First four bits are 1111.
o Reserved for experimental purposes.
o Address range: [Link] to [Link].
Address Depletion
Problem: Classful addressing led to rapid depletion of IPv4 addresses due to inefficient
distribution.
• Class A:
o Designed for very large organizations.
o Only 128 networks available, each with 16,777,216 addresses.
o Most organizations didn't need so many addresses, leading to significant waste.
• Class B:
o Designed for midsize organizations.
o Despite more networks available, many addresses remained unused.
• Class C:
o Intended for smaller networks.
o Each network had only 256 addresses, which was often too few for organizations.
• Class E: Reserved and almost never used, leading to wastage of the entire class.
• Subnetting:
o Concept: Divides a large class A or class B network into smaller subnets.
o Method: Increases the prefix length, creating multiple smaller networks from a single
large network.
o Issue: Not widely adopted because large organizations were reluctant to share unused
addresses with smaller ones.
• Supernetting:
o Concept: Combines several smaller class C networks into a larger block.
o Purpose: Designed to create larger address blocks for organizations needing more
than 256 addresses.
• Simplicity: The class of an address is easily identifiable from the address itself.
• Fixed Prefix Length:
o Each address class (A, B, C) has a predefined prefix length.
o No additional information is required to determine the prefix and suffix, making it
easier to understand and manage
• Classless addressing was introduced to solve the IPv4 address depletion problem.
• It eliminates the rigid class structure (A, B, C) of classful addressing and allows variable-
length blocks of IP addresses.
• Provides more efficient and flexible distribution of IP addresses to organizations and ISPs.
• Classful addressing wasted many IP addresses due to fixed-size blocks; classless addressing
resolves this by allowing different block sizes.
3. Variable-Length Blocks:
• In classless addressing, IP addresses are grouped into blocks of varying sizes, which can be 2,
4, 8, 16, 32, 64 addresses, and so on.
• The block sizes must be a power of 2, such as 21, 22, 23 and so on.
• The length of the network portion of the IP address is indicated by the prefix length.
• Slash Notation or CIDR (Classless Interdomain Routing) is used to specify the prefix
length, written as /n, where n is the number of bits used for the network part.
o Example: [Link]/24 means the first 24 bits are for the network and the remaining
8 bits are for hosts.
• Larger prefix length = smaller network (fewer hosts).
• Smaller prefix length = larger network (more hosts).
5. Block of Addresses:
• A block of addresses is determined by the prefix (network part) and the suffix (host part).
• The size of the block is based on the prefix length.
• The number of addresses in a block is calculated using the formula: N=232-n where n is the
prefix length.
Example : A classless address is given as [Link]/27. We can find the above three pieces of
information as follows. The number of addresses in the network is 232 − n = 25 = 32 addresses.
Example 18.3
In classless addressing, an address cannot per se define the block the address belongs to. For
example, the address [Link] can belong to many blocks. Some of them are shown below with
the value of the prefix associated with that block.
Network Address
The above examples show that, given any address, we can find all information about the block.
The first 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.
• Efficient use of IP addresses: Avoids the waste of addresses that occurs with classful
addressing.
• Scalability: Allows for more precise address allocation based on actual need, which is crucial
as the number of devices connected to the Internet grows.
• Better management by ISPs: ISPs can assign blocks of different sizes to customers,
ensuring everyone gets only the number of addresses they need.
Classless addressing (CIDR) was a crucial development in managing the limited IPv4 address space.
By allowing variable-length prefixes and more flexible block sizes, it ensures a more efficient and
scalable distribution of IP addresses across the Internet.
• Global Authority (ICANN): The Internet Corporation for Assigned Names and Numbers
(ICANN) is responsible for assigning IP address blocks.
o ICANN does not assign addresses to individual users but allocates large blocks to
ISPs or large organizations.
• Responsibilities of ISPs: ISPs receive large blocks of addresses from ICANN, which they
further subdivide and assign to customers.
o The first address should be represented as the prefix followed by (32−n) mzeros in
binary.
o The decimal value of the first address must be divisible by the number of addresses.
1. Overview of Subnetting:
2. Designing Subnets:
Example:
After designing the subnetworks, key information about each subnet (such as the first address and
last address) can be calculated using the same method applied to larger networks. The process is as
follows:
1. First Address:
o The first address of the subnet is found by setting the host bits (the last 32−n sub bits)
to 0.
2. Last Address:
o The last address is found by setting the host bits to 1.
• If a subnet has a prefix length of /24, the first address will have the last 8 bits set to 0, and the
last address will have the last 8 bits set to 1.
This approach ensures optimal usage of IP addresses, simplifies routing, and improves the scalability
of network infrastructure.
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 locks to its customers.
Problem : Example: An organization has been granted a block of 256 addresses, starting at
[Link]/24. The organization needs to divide this block into three subnets with the following
requirements:
The solution involves allocating a number of addresses that are powers of 2, which are larger than or
equal to the required number. The subnets are designed by starting with the largest requirement and
working down to the smallest.
1. Total Addresses:
o The block [Link]/24 has a total of: 232−24=256 addresses
o First address: [Link]
o Last address: [Link]
• First address: The next available address after the first block is [Link]/26.
• Last address:
o The block starts at [Link], and since there are 64 addresses, the last address is
[Link]/26.
Remaining Addresses:
• After assigning the three subnets, the total number of allocated addresses is:
128+64+16=208 addresses
• This leaves 48 addresses unused.
• First address of unused range: [Link]
• Last address of unused range: [Link]
• Prefix length: To be determined, but the range can be used for future subnets or other
purposes.
Summary of Subblocks:
• Subnet A:
o 120 required, 128 allocated
o First address: [Link]/25
o Last address: [Link]/25
• Subnet B:
o 60 required, 64 allocated
o First address: [Link]/26
o Last address: [Link]/26
• Subnet C:
o 10 required, 16 allocated
o First address: [Link]/28
o Last address: [Link]/28
• Unused Block:
o First address: [Link]
This method ensures efficient utilization of IP addresses while allowing for potential future
expansions.
IPv4 includes several special-purpose addresses used for specific functions in networking. Here are
five important types:
• Address: [Link]/32
• Purpose: Used when a host doesn't know its own IP address and needs to communicate.
• Use Case: A host might use this address as a source address before it knows its IP (e.g.,
during DHCP requests).
• Address: [Link]/32
• Purpose: Sends a datagram to all devices on the local network.
• Restrictions: Routers block these packets from being forwarded to other networks (they stay
within the local network).
• Use Case: A host can broadcast to all devices within the same local network segment.
4. Private Addresses
• Blocks:
o [Link]/8
o [Link]/12
o [Link]/16
o [Link]/16 (link-local addresses)
• Purpose: Used for internal/private networks. These addresses are not routable on the public
Internet.
• Use Case: Networks within homes, businesses, or organizations. They require Network
Address Translation (NAT) for accessing the Internet.
These addresses serve distinct roles in networking, ensuring proper communication, testing, and
private address use within internal networks.
• The second capability can provide a temporary IP address to a traveler to connect her laptop
to the Internet while she is staying in the hotel.
• It also allows an ISP with 1000 granted addresses to provide services to 4000 households,
assuming not more than one-forth of customers use the Internet at the same time.
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 [Link]. When the client finishes reading the message, it looks for this
magic cookie. If present, the next 60 bytes are options.
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 that are mostly used by vendors.
If the tag field is 53, the value field defines one of the 8 message types shown in Figure 18.26. We
show how these message types are used by DHCP.
DHCP Operation :
1. The joining host creates a DHCP DISCOVER message in which only the transaction ID field is set
to a random number. No other field can be set because the host has no knowledge with which to do
so. This message is encapsulated in a UDP user datagram with the source port set to 68 and the
destination port set to 67.
The user datagram is encapsulated in an IP datagram with the source address set to [Link] (“this
host”) and the destination address set to [Link] (broadcast address). 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
your address field defines the offered IP address for the joining host and the server address field
includes the IP address of the server. The message also includes the lease time for which the host can
keep the IP address. This message is encapsulated in a user datagram with the same port numbers,
but in the reverse order. The user datagram in turn is encapsulated in a datagram with the server
address as the source IP address, but the destination address is a broadcast address, in which the
server allows other DHCP servers to receive the offer and give a better offer if they can.
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. The fields with known
value are set. The message is encapsulated in a user datagram with port numbers as the first message.
The user datagram is encapsulated in an IP datagram with the source address set to the new client
address, but the destination address still is set to the broadcast address to let the other servers know
that their offer was not accepted.
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.
This message is also broadcast to let other servers know that the request is accepted or rejected.
DHCP uses two well-known ports (68 and 67) instead of one well-known and one ephemeral to
bifurcate the operations and to DHCP requests and response.
DHCP client uses timers and a retransmission policy if it does not receive the DHCP reply to a
request. However, to prevent a traffic jam when several hosts need to retransmit a request (for
example, after a power failure), DHCP forces the client to use a random number to set its timers.
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. While it is
there, it may receive more offers.
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 and uses the IP address. When the
lease is 50 percent expired, the client tries to renew it by moving to the RENEWING state.
If the server renews the lease, the client moves to the BOUND state again. 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 and continues
using the IP address; otherwise, the client moves to the INIT state and requests another IP address.
Note that the client can use the IP address only when it is in the BOUND, RENEWING, or
REBINDING state. The above procedure requires that the client uses three timers: renewal timer (set
to 50 percent of the lease time), rebinding timer (set to 75 percent of the lease time), and expiration
timer (set to the lease time).
Network address translation (NAT) is a technique that allows multiple devices to share a single
public IP address. It works by translating the private IP addresses of a local network into a public IP
address before sending packets to the internet.
As the figure 18.29 shows, the private network uses private addresses. The router that connects the
network to the global address uses one private address and one global address. The private network is
invisible to the rest of the Internet; the rest of the Inter net sees only the NAT router with the address
[Link].
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
A translation table has only two columns: the private address and the external address (destination
address of the packet). When the router translates the source address of the outgoing packet, it also
makes note of the destination address— where the packet is going. When the response comes back
from the destination, the router uses the source address of the packet (as the external address) to find
the private address of the packet. Figure 18.31 shows the idea. In this strategy, communication must
always be initiated by the private network. The NAT mechanism described requires that the private
network start the communication.
NAT can be connected to more than one private network by using more IP addresses. The NAT
router can use four addresses ([Link], [Link], [Link], and [Link]), so four private-
network hosts can communicate with the same external host at the same time because each pair of
addresses defines a separate connection. But no more than four connections can be made to the same
destination.
To allow a many-to-many relationship between private-network hosts and external server programs,
translation table with port numbers can be used. For example, suppose two hosts inside a private
network with addresses [Link] and [Link] need to access the HTTP server on external host
[Link]. If the translation table has five columns, instead of two, that include the source and
destination port addresses and the transport-layer protocol, the ambiguity is eliminated. Table 18.1
shows an example of such a table.
Unicast Routing
In an internet, the goal of the network layer is to deliver a datagram from its source to its destination
or destinations. If a datagram is destined for only one destination (one-to-one delivery), we have
unicast routing. If the datagram is destined for several destinations (one-to-many delivery), we have
multicast routing.
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.
Link-State 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.
• 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.
• 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.
• 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).
Each node can create this LSDB that contains information about the whole internet. This can be done
by a process called flooding.
Each node can send some greeting messages to all its immediate neighbors (those nodes to which it
is connected directly) to collect two pieces of information for each neighboring node: the identity of
the node and the cost of the link. The combination of these two pieces of information is called the LS
packet (LSP); the LSP is sent out of each interface, as shown in Figure 20.9 for our internet in Figure
20.1.
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.
Distance-Vector Routing
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.
Bellman-Ford Equation
• Find the least cost (shortest distance) between a source node, x, and a destination node, y,
through some intermediary nodes (a, b, c, …) , when following are given
◦ the costs between the source and the intermediary nodes
◦ the least costs between the intermediary nodes and the destination
• General case in which Dij is the shortest distance and cij is the cost between nodes i and j
◦ Dxy = min {(cxa + Day), (cxb + Dby), (cxc + Dcy), …}
• Bellman-Ford equation enables us to build a new least-cost path from previously established
least-cost paths.
Link State and distant vector problem- Refer class notes and PPT’s
Path-Vector Routing
• 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.
• The best route is determined by the source using the policy it imposes on the route. In other
words, the source can control the path.
• Although path-vector routing is not actually used in an internet, and is mostly designed to
route a packet between ISPs.
• Spanning Trees:
• In path-vector routing, the path from a source to all destinations is also determined by
the best spanning tree.
• 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.
In this equation, the operator (+) means to add x to the beginning of the path. We also need to be
cautious to avoid adding a node to an empty path because an empty path means one that does not
exist. The policy is defined by selecting the best of multiple paths. Path-vector routing also imposes
one more condition on this equation: If Path (v, y) includes x, that path is discarded to avoid a loop in
the path. In other words, x does not want to visit itself when it selects a path to y. 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.
Internet:
Hierarchical Routing:
• The Internet today is made up of a huge number of networks and routers that connect them.
• Routing in the Internet cannot be done using one single protocol for two reasons:
◦ a scalability problem - the size of the forwarding tables becomes huge, searching for a
destination in a forwarding table becomes time consuming, and updating creates a
huge amount of traffic
◦ an administrative issue- related to the Internet structure
◦ each ISP is run by an administrative authority
◦ The administrator needs to have control in its system.
◦ organization must be able to use as many subnets and routers as it needs, may
desire that the routers be from a particular manufacturer, may wish to run a
specific routing algorithm to meet the needs of the organization, and may want
to impose some policy on the traffic passing through its ISP
• Hierarchical routing means considering each ISP as an autonomous system (AS)
• Each AS can run a routing protocol that meets its needs, but the global Internet runs a
global protocol to glue all ASs together
◦ The routing protocol run in each AS is referred to as intra-AS routing protocol,
intradomain routing protocol, or interior gateway protocol (IGP);
◦ RIP and OSP
◦ the global routing protocol is referred to as inter-AS routing protocol, interdomain
routing protocol, or exterior gateway protocol (EGP)
◦ BGP
• Several intradomain routing protocols -each AS is free to choose one, but only one
interdomain protocol that handles routing between these entities
Autonomous Systems:
• Each ISP is an autonomous system when it comes to managing networks and routers under its
control
• Although we may have small, medium-size, and large ASs, each AS is given an autonomous
number (ASN) by the Internet Corporation for Assigned Names and Numbers (ICANN)
• Each ASN is a 16-bit unsigned integer that uniquely defines an AS
• The autonomous systems, however, are not categorized according to their size; they are
categorized according to the way they are connected to other Ass
◦ The network in which the source host is connected is not counted in this calculation
because the source host does not use a forwarding table
◦ the packet is delivered to the default router.
• 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)
• For this reason, RIP can be used only in autonomous systems in which the diameter of the AS
is not more than 15 hops
• Routers in an autonomous system need to keep forwarding tables to forward packets to their
destination networks
• A forwarding table in RIP is a three column table
• the address of the destination network
• the address of the next router to which the packet should be forwarded
• the cost (the number of hops) to reach the destination network
• the first and third columns together convey the same information as does a distance vector,
but the cost shows the number of hops to the destination networks.
• 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
• 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.
RIP Messages
Each entry carries the information related to one line in the forwarding table of the router that sends
the message
Timers in RIP;
• Garbage collection timer is used to purge a route from the forwarding table.
◦ When the information about a route becomes invalid, the router does not immediately
purge that route from its table.
◦ Instead, it continues to advertise the route with a metric value of 16.
◦ At the same time, a garbage collection timer is set to 120 s for that route.
◦ When the count reaches zero, the route is purged from the table.
◦ This timer allows neighbors to become aware of the invalidity of a route prior to
purging.
Performance of RIP
• Update messages – have a very simple format and are sent only to neighbors (local)
◦ They do not normally create traffic because the routers try to avoid sending them at
the same time.
• Convergence of forwarding tables - the distance-vector algorithm can converge slowly if
the domain is large, but, because RIP allows only 15 hops in a domain (16 is considered as
infinity), there is normally no problem in convergence
◦ The only problems that may slow down convergence are count-to-infinity and loops
created in the domain;
• An Intradomain 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.
• OSPF concept:
◦ Metric
◦ Forwarding tables
◦ Areas
◦ Link state advertisement
◦ Implementation – OSPF messages, authentication, algorithm
◦ Performance
• Cost of reaching a destination from the host is calculated from the source router to the
destination network
• Each link (network) can be assigned a weight based on the throughput, round-trip time,
reliability, and so on.
◦ An administration can also decide to use the hop count as the cost
• An interesting point about the cost in OSPF is that different service types (TOSs) can have
different weights as the cost.
• Each OSPF router can create a forwarding table after finding the shortest path tree between
itself and the destination using Dijkstra’s algorithm,
• If we use the hop count for OSPF, the tables will be exactly the same as RIP because both
protocols use the shortest-path trees to define the best route from a source to a destination.
• RIP is normally used in small ASs, OSPF was designed to be able to handle routing in a small
or large autonomous system.
• The formation of shortest-path trees in OSPF requires that all routers flood the whole AS with
their LSPs to create the global LSDB.
• Although this may not create a problem in a small AS, it may have created a huge volume of
traffic in a large AS
• OSPF uses another level of hierarchy in routing: The first level is the autonomous system, the
second is the area
• The AS needs to be divided into small sections called areas
• Each area acts as a small independent domain for flooding LSPs.
• However, each router in an area needs to know the information about the link states not only
in its area but also in other areas.
• For this reason, one of the areas in the AS is designated as the backbone area, responsible for
gluing the areas together.
• The routers in the backbone area are responsible for passing the information collected by each
area to all other areas.
• A router in an area can receive all LSPs generated in other areas
• For the purpose of communication, each area has an area identification.
Link-State Advertisement
• OSPF is based on the link-state routing algorithm, which requires that a router advertise the
state of each link to all neighbors for the formation of the LSDB.
• We need to advertise the existence of different entities as nodes, the different types of links
that connect each node to its neighbors, and the different types of cost associated with each
link
◦ This means we need different types of advertisements, each capable of advertising
different situations
• We can have five types of link-state advertisements:
◦ router link
◦ network link
◦ summary link to network
◦ summary link to AS border router
◦ external link
• In addition to giving the address of the announcing router, this type of advertisement can
define one or more types of links that connect the advertising router to other entities
◦ A transient link announces a link to a transient network, a network that is connected
to the rest of the networks by one or more routers
◦ This type of advertisement should define the address of the transient network
and the cost of the link
◦ A stub link advertises a link to a stub network, a network that is not a through network
◦ Again, the advertisement should define the address of the network and the cost
◦ A point-to-point link should define the address of the router at the end of the point-to-
point line and the cost to get there.
• However, because a network cannot do announcements itself (it is a passive entity), one of
the routers is assigned as the designated router and does the advertising
• In addition to the address of the designated router, this type of LSP announces the IP address
of all routers (including the designated router as a router and not as speaker of the network),
but no cost is advertised because each router announces the cost to the network when it sends
a router link advertisement.
3. Summary link to network -This is done by an area border router; it advertises the summary of
links collected by the backbone to an area or the summary of links collected by the area to the
backbone
4. Summary link to AS - This is done by an AS router that advertises the summary links from
other ASs to the backbone area of the current AS, information which later can be disseminated to the
areas so that they will know about the networks in other Ass
5. External link -This is also done by an AS router to announce the existence of a single network
outside the AS to the backbone area to be disseminated into the areas.
OSPF Messages
• The hello message (type 1) is used by a router to introduce itself to the neighbors and
announces all neighbors that it already knows.
• The database description message (type 2) is normally sent in response to the hello message
to allow a newly joined router to acquire the full LSDB
• The link-state request message (type 3) is sent by a router that needs information about a
specific LS
• The link-state update message (type 4) is the main OSPF message used for building the
LSDB
◦ This message, in fact, has five different versions (router link, network link, summary
link to network, summary link to AS border router, and external link),
• The link-state acknowledgment message (type 5) is used to create reliability in OSPF
◦ each router that receives a link-state update message needs to acknowledge it.
• Router R5 can now add these pieces of information at the end of its forwarding table
• When R5 receives any packet destined for these four networks, it can use its forwarding table
and find that the next router is R1.
The messages exchanged during three eBGP sessions help some routers know how to route packets
to some networks in the internet, but the reachability information is not complete.
1. Some border routers do not know how to route a packet destined for non-neighbor ASs.
◦ For example, R5 does not know how to route packets destined for networks in AS3
and AS4.
◦ Routers R6 and R9 are in the same situation as R5:
◦ R6 does not know about networks in AS4
◦ R9 does not know about networks in AS3.
2. None of the nonborder routers know how to route a packet destined for any networks in other
ASs.
To address these two problems, we need to allow all pairs of routers (border or nonborder) to run the
second variation of the BGP protocol, iBGP.
• The iBGP protocol is similar to the eBGP protocol in that it uses the service of TCP on the
well-known port 179, but it creates a session between any possible pair of routers inside an
autonomous system.
• If an AS has only one router, there cannot be an iBGP session. For example, we cannot create
an iBGP session inside AS2 or AS4 in our internet.
• If there are n routers in an autonomous system, there should be [n × (n − 1) / 2] iBGP
sessions in that autonomous system (a fully connected mesh) to prevent loops in the system.
In other words, each router needs to advertise its own reachability to the peer in the session
instead of flooding what it receives from another peer in another session.
• Physical networks inside ASs have not shown because a session is made on an overlay
network (TCP connection), possibly spanning more than one physical network as determined
by the route dictated by the intradomain routing protocol.
• In this stage only four messages are exchanged
◦ The first message (numbered 1) is sent by R1 announcing that networks N8 and N9
are reachable through the path AS1- AS2, but the next router is R1
Chethana H R, Asst. Prof. Dept Of CSE, RNSIT 60
◦ This message is sent, through separate sessions, to R2, R3, and R4.
◦ Routers R2, R4, and R6 do the same thing but send different messages to different
destinations.
◦ The interesting point is that, at this stage, R3, R7, and R8 create sessions with their
peers, but they actually have no message to send.
• For example, after R1 receives the update message from R2, it combines the reachability
information about AS3 with the reachability information it already knows about AS1 ad
sends a new update message to R5.
• Now R5 knows how to reach networks in AS1 and AS3
• The process continues when R1 receives the update message from R4.
• The point is that we need to make certain that at a point in time there are no changes in the
previous updates and that all information is propagated through all ASs.
• At this time, each router combines the information received from eBGP and iBGP and creates
what we may call a path table after applying the criteria for finding the best path.
• For example, router R1 now knows that any packet destined for networks N8 or N9 should go
through AS1 and AS2 and the next router to deliver the packet to is router R5.
• Similarly, router R4 knows that any packet destined for networks N10, N11, or N12 should
go through AS1 and AS3 and the next router to deliver this packet to is router R1, and so on.
Path Attributes
• In both intradomain routing protocols (RIP or OSPF), a destination is normally associated with two
pieces of information:
◦ Next hop - shows the address of the next router to deliver the packet
◦ Cost - defines the cost to the final destination
• Interdomain routing is more involved and naturally needs more information about how to reach
the final destination
• In BGP these pieces are called path attributes. BGP allows a destination to be associated with
up to seven path attributes
• All attributes are inserted after the corresponding destination prefix in an update message.
• ORIGIN (type 1) - a well-known mandatory attribute, which defines the source of the
routing information.
• This attribute can be defined by one of the three values: 1, 2, and 3.
• Value 1 means that the information about the path has been taken from an
intradomain protocol (RIP or OSPF).
• Value 2 means that the information comes from BGP.
• Value 3 means that it comes from an unknown source.
• AS-PATH (type 2)- a well-known mandatory attribute, which defines the list of
autonomous systems through which the destination can be reached.
• The AS-PATH attribute helps to prevent a loop
• Whenever an update message arrives at a router that lists the current AS as the path,
the router drops that path
Messages
• Four types of messages for communication between the BGP speakers across the ASs and
inside an AS:
◦ Open- To create a neighborhood relationship
◦ a router running BGP opens a TCP connection with a neighbor and sends an
open message
◦ Update - heart of the BGP protocol which is used by a router to withdraw
destinations that have been advertised previously, to announce a route to a new
destination, or both
◦ BGP can withdraw several destinations that were advertised before, but it can
only advertise one new destination (or multiple destinations with the same
path attributes) in a single update message
• Keepalive- The BGP peers that are running exchange keep-alive messages regularly
(before their hold time expires) to tell each other that they are alive
• Notification-sent by a router whenever an error condition is detected or a router wants to
close the session
Multicast routing sends a single copy of data to multiple users simultaneously on a closed
network. It's commonly used for streaming media and videoconferencing on organizational networks.
Multicast Extensions to Open Shortest Path First (MOSPF) is a routing protocol that extends the
Open Shortest Path First (OSPF) protocol to support multicast routing:
• MOSPF builds on OSPF Version 2 to add multicast routing capabilities. It uses OSPF to
maintain a network topology image and adds a new type of link-state advertisement (LSA)
called group-membership-LSA to identify multicast group members.
• MOSPF routers can interoperate with non-multicast OSPF routers when forwarding unicast
IP data traffic.
To extend unicasting to multicasting, each router needs to have another database, as with the case of
unicast distance-vector routing, to show which interface has an active member in a particular group.
Router goes through the following steps to forward a multicast packet received from source S and to
be sent to destination G (a group of recipients:
1. The router uses the Dijkstra algorithm to create a shortest-path tree with S as the root and all
destinations in the internet as the leaves. Note that this shortest-path tree is different from the one the
router normally uses for unicast forwarding, in which the root of the tree is the router itself. In this
case, the root of the tree is the source of the packet defined in the source address of the packet. The
router is capable of creating this tree because it has the LSDB, the whole topology of the internet; the
Dijkstra algorithm can be used to create a tree with any root, no matter which router is using it. The
point we need to remember is that the shortest-path tree created this way depends on the specific
source. For each source we need to create a different tree.
2. The router finds itself in the shortest-path tree created in the first step. In other words, the router
creates a shortest-path subtree with itself as the root of the subtree.
3. The shortest-path subtree is actually a broadcast subtree with the router as the root and all
networks as the leaves. The router now uses a strategy similar to the one we describe in the case of
DVMRP to prune the broadcast tree and to change it to a multicast tree. The IGMP protocol is used
to find the information at the leaf level. MOSPF has added a new type of link state update packet that
floods the member ship to all routers. The router can use the information it receives in this way and
prune the broadcast tree to make the multicast tree.
4. The router can now forward the received packet out of only those interfaces that correspond to the
branches of the multicast tree. We need to make certain that a copy of the multicast packet reaches
all networks that have active members of the group and that it does not reach those networks that do
not.