Cs3591cn Unit III & IV
Cs3591cn Unit III & IV
Cs3591cn Unit III & IV
2
Network Layer
Network Layer
• The communication between Alice and Bob at the network layer.
• The Internet is made of many networks (or links) connected through the connecting
devices.
• The network layer is involved at the source host, destination host, and all routers in
• At the source host (Alice), the network layer accepts a packet from a transport layer,
encapsulates the packet in a datagram, and delivers the packet to the data-link layer.
Routing
• 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.
• 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.
Network Layer
Services
2. Routing and Forwarding
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 called the
forwarding table or 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.
Network Layer
3. Other Services Services
Error Control
• The network layer in the Internet does not directly provide error control.
• The Internet uses an auxiliary protocol, ICMP, that provides some kind of error control
if the datagram is discarded or has some unknown information in the header.
Flow Control
• To control the flow of data, the receiver needs to send feedback to the sender to
inform the latter that it is overwhelmed with data.
• The network layer in the Internet does not directly provide any flow control.
• The datagrams are sent by the sender when they are ready, without any attention to the
readiness of the receiver.
Network Layer
3. Other Services Services
Congestion Control
• Congestion may occur if the number of datagrams sent by source computers is beyond
the capacity of the network or routers.
• In this situation, some routers may drop some of the datagrams.
• 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.
• 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.
Packet Switching
1. Datagram Networks – Routing Table Mechanism
• The routing tables are dynamic and are updated
periodically.
• The destination addresses and the corresponding
forwarding output ports are recorded in the tables.
• The destination address in the header of a packet
in a datagram network remains the same during the
entire journey of the packet.
• When the router receives the packet, this
destination address is examined; the routing table
is consulted to find the corresponding port
through which the packet should be forwarded.
Packet Switching
2. Virtual-Circuit Networks
• 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.
Packet Switching
2. Virtual-Circuit Networks
• Each packet is forwarded based on the label in the packet.
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.
Packet Switching
2. Virtual-Circuit Networks
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.
Network Layer
• Performance
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.
1. Delay
• It defines how long it takes for a packet to completely arrive at the destination from the
source.
• It is divided into four types: propagation time, transmission time, queuing time and
processing delay.
• Transmission Delay: Depends on the packet length and the transmission rate.
Delaytr = (Packet length) / Transmission rate
• Propagation Delay: The time it takes for a bit to travel from point A to point B in the
transmission media.
Delaypg = Distance / Propagation Speed
Network Layer
1. Delay
Performance
• Processing Delay: 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).
• Queuing Delay: A packet in a router is measured as the time a packet waits in the input
queue and output queue of a router.
Delayqu = The time a packet waits in input and output queues in a router
3. Packet Loss
• The performance of communication is affected if 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.
Network Layer
4.
Performance
Congestion Control
• Congestion control is a mechanism for improving performance.
• When the load is much less than the capacity of the network, the delay is at a minimum.
• When the load is below the capacity of the network, the throughput
increases proportionally with the load.
Classful
Addressing
IPv4
Classful
Addressing Addresses
No. of No. of Hosts /
Class First Octet value Range
Network Network
00000000 – 01111111 1.0.0.1 –
A 126 224 - 2
(0 – 127) 126.255.255.254
10000000 – 10111111 128.1.0.1 –
B 16000 65000
(128 – 191) 191.255.255.254
11000000 – 11011111 192.0.1.1 –
C 2 Million 254
(192 – 223) 223.255.255.254
11100000 – 11101111 224.0.0.0 –
D Multicast addresses
(224 – 239) 239.255.255.255
11110000 – 11111111 240.0.0.0 –
E Future use
(240 – 255) 254.255.255.254
– 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.
• Advantage
– Easily find the class of the address and, since the prefix length for each class is
fixed, we can find the prefix length immediately.
IPv4
Classful Addressing
Addresses
• Subnetting & Supernetting
– To alleviate address depletion, two strategies were 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.
– 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.
IPv4
Classless Addressing
Addresses
• 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).
• The number of addresses in a block needs to be a power of 2.
• In classless addressing, how to find the prefix length if an address is given, the prefix
length, n, is added to the address, separated by a slash.
IPv4
Classless Addressing: Extracting Information from an Address
Addresses
• Given any address in the block, there are 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.
2. To find the first address, the n leftmost bits and set the (32 − n) rightmost bits all to 0s.
3. To find the last address, the n leftmost bits and set the (32 − n) rightmost bits all to 1s.
IPv4
Classless Addressing: Extracting Information from an Address
Addresses
• Example: A classless address is given as 167.199.170.82/27. We can find the above
three pieces of information as follows. The number of addresses in the network is 232 − n
= 25 = 32 addresses.
The first address can be found by keeping the first 27 bits and changing the rest of the
bits to 0s.
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)].
IPv4
Classless Addressing: Address Addresses
Mask
• Example: A classless address is given as 167.199.170.82/27. We can find the above
three pieces of information as follows. The number of addresses in the network is 232 − n
= 25 = 32 addresses. The mask in dotted-decimal notation is 256.256.256.224.
First address:
Last address:
2. The requested block needs to be allocated where there is an adequate number of contiguous
addresses available in the address space. There is a restriction on choosing the first address in the
block. The first address needs to be divisible by the number of addresses in the block. The reason is
that the first address needs to be the prefix followed by (32 - n) number of 0s. The decimal value of
the first address is then first address = (prefix in decimal) x 232 - n = (prefix in decimal) x N.
IPv4
Addresses
Classless Addressing: Subnetting
• A subnetwork can be divided into several sub-subnetworks.
• 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).
Designing Subnets
2. The prefix length for each subnetwork should be found using the following formula:
nsub = 32 − log2Nsub
3. The starting address in each subnetwork should be divisible by the number of addresses
in that subnetwork. This can be achieved if we first assign addresses to larger
subnetworks.
IPv4
Addresses
Classless Addressing: Subnetting
• Example: An organization is granted a block of addresses with the beginning address
14.24.74.0/24. The organization needs to have 3 subblocks of addresses to use in its
three subnets: one subblock of 10 addresses, one subblock of 60 addresses, and one
subblock of 120 addresses. Design the subblocks.
Solution:
There are 232 – 24 = 256 addresses in this block. The first address is 14.24.74.0/24; the last
address is 14.24.74.255/24. To satisfy the third requirement, we assign addresses to
subblocks, starting with the largest and ending with the smallest one.
• The number of addresses in the largest subblock, which requires 120 addresses, is not a
power of 2. We allocate 128 addresses. The subnet mask for this subnet can be found as
n1 = 32 − log2128 = 25. The first address in this block is 14.24.74.0/25; the last address
is 14.24.74.127/25.
IPv4
Addresses
Classless Addressing: Subnetting
Solution:
• The number of addresses in the second largest subblock, which requires 60 addresses, is
not a power of 2 either. We allocate 64 addresses. The subnet mask for this subnet can be
found as n2 = 32 − log264 = 26. The first address in this block is 14.24.74.128/26; the
last address is 14.24.74.191/26.
• The number of addresses in the smallest subblock, which requires 10 addresses, is not a
power of 2 either. We allocate 16 addresses. The subnet mask for this subnet can be
found as n3 = 32 − log216 = 28. The first address in this block is 14.24.74.192/28; the
last address is 14.24.74.207/28.
IPv4
Classless Addressing: Address Addresses
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.
• Example:
IPv4
Addresses
Classless Addressing: 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): 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.
• Limited-broadcast Address (255.255.255.255/32): It is used whenever a router or a
host needs to send a datagram to all devices in a network.
• Loopback Address (127.0.0.0/8): A packet with one of the addresses in this block as the
destination address never leaves the host; it will remain in the host.
• 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.
• Multicast Addresses: The block 224.0.0.0/4 is reserved for multicast addresses.
IPv4
Addresses
Dynamic Host Configuration Protocol (DHCP)
A host need an IP Address and some other piece of information (subnet mask,
gateway address, etc…) to send the packets.
Normally this information’s are provided by the system administrator and configure in
manually.
But for a large network it is complex and error prone. So automatic configuration
method is used.
Automatic configuration is provided by DHCP.
It needs a DHCP server to provide the information dynamically.
DHCP Server – It is a central repository for host configuration details.
IPv4
Addresses
Dynamic Host Configuration Protocol (DHCP) – Steps
Unicast
DHCP DHCP
Other Networks
Relay Server
Broadcast
Host
• A newly booted or attached host sends a “DHCP DISCOVER” message to special IP
Address 255.255.255.255 (Broadcast Address).
• DHCP relay receives this request and unicast that request to the DHCP server.
• DHCP relay: It contains the IP address of DHCP Server.
• DHCP server sends back the response to the requesting client.
IPv4
Addresses
Dynamic Host Configuration Protocol (DHCP) - Steps
• DHCP dynamically assigns IP address to hosts. But host cannot keep
addresses
indefinitely.
• Thus DHCP allows addresses to be “leased” for some period of time. Once the lease
expires, client needs to renew the IP Address.
Advantages
• Scaling of network management
• Improves manageability of a network.
IPv4
Addresses
Dynamic Host Configuration Protocol (DHCP)
IPv4
Addresses
Dynamic Host Configuration Protocol (DHCP)
• Operation Code (8 bit): Specifies whether the message is request (1) / response (2).
• Hardware Type (8 bit): Specifies the type of hardware used for local network (Value 1
– Ethernet).
• Hardware Address Length (8 bit): Specifies the length of the hardware address.
• Hops (8 bit): Used to control the DHCP request message by DHCP relay.
• Transaction Identifier (32 bit) – XID: A 32-bit identification field generated by the
client, to allow it to match up the request with replies received from DHCP servers.
• Seconds (16 bit): Number of seconds elapsed since a client began an attempt to acquire
or renew a lease.
IPv4
Addresses
•Dynamic Host
Flag (16 Configuration
bit): Bit is set toProtocol (DHCP)
1 to represent the broadcast message. Other bits are set to
Zero.
• Client IP Address: The client puts its own current IP address in this field if and only if it
• Your IP Address: The IP address that the server is assigning to the client.
• CHAddr (Client Hardware Address): The hardware address of the client, which is
• Sname (Server Name): Name of the DHCP server, provided by the server during the
response.
IPv4
Addresses
Network Address Translation (NAT)
• 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.
IPv4
Addresses
Network Address Translation (NAT) – Using One IP Address
• 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.
IPv4
Addresses
Network Address Translation (NAT) – Using a Pool of IP Address
• The use of only one global address by the NAT router allows only one private-network
host to access a given external host.
• To remove this restriction, the NAT router can use a pool of global addresses.
• Example: Instead of using only one global address (200.24.5.8), the NAT router can use
four addresses (200.24.5.8, 200.24.5.9, 200.24.5.10, and 200.24.5.11). In this case, four
private-network hosts can communicate with the same external host at the same
time because each pair of addresses defines a separate connection.
• Drawback: No more than four connections can be made to the same destination.
– No private-network host can access two external server programs (e.g., HTTP and
TELNET) at the same time.
– Two private-network hosts cannot access the same external server program (e.g.,
HTTP or TELNET) at the same time.
IPv4
Addresses
Network Address Translation (NAT) – Using Both IP Addresses and Port Addresses
Note:
• When the response from HTTP comes back, the combination of source address
(25.8.3.2) and destination port address (1401) defines the private network host to which
the response should be directed.
• For this translation to work, the ephemeral port addresses (1400 and 1401) must be
unique.
Forwarding of IP
• Packets
When IP is used as a connectionless protocol, forwarding is based on the destination
address of the IP datagram.
• When the IP is used as a connection-oriented protocol, forwarding is based on the
label attached to an IP datagram.
• Forwarding Based on Destination Address
– Forwarding requires a host or a router to have a forwarding table.
– When a host has a packet to send or when a router has received a packet to be
forwarded, it looks at this table to find the next hop to deliver the packet to.
– Techniques Used:
• Address Aggregation
• Hierarchical Routing
• Geographical Routing
Forwarding of IP
• Packets
Change IP to behave like a connection-oriented protocol in which the routing is
replaced by switching.
• In a connection-oriented network (virtual-circuit approach), a switch forwards a
packet based on the label attached to the packet.
• Routing is normally based on searching the contents of a table; switching can be done
by accessing a table using an index.
• In other words, routing involves searching; switching involves accessing.
• Techniques Used:
– Multi-Protocol Label Switching (MPLS)
– Hierarchical Switching
Network Layer Protocols: 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 map network-layer addresses to
link-layer addresses.
• IPv4 is also a connectionless protocol that uses the datagram approach.
• IPv4 is an unreliable datagram protocol.
Network Layer Protocols: Internet Protocol (IP)
Datagram Format
Network Layer Protocols: Internet Protocol (IP)
Datagram Format
• Version (4 bits): Defines the version of the IPv4 protocol.
• Header Length (4 bits): Defines the total length of the datagram header in 4-byte
words.
• Service Type (8 bits): Type of Service (ToS), which defined how the datagram should
be handled.
• Total Length (16 bits): defines the total length (header plus data) of the IP datagram in
bytes. A 16-bit number can define a total length of up to 65,535.
• The combination of the identification and source IP address must uniquely define a
datagram as it leaves the source host.
• When a datagram is fragmented, the value in the identification field is copied into all
fragments.
• The identification number helps the destination in reassembling the datagram.
Network Layer Protocols: Internet Protocol (IP)
Fragmentation - Fields Related to Fragmentation:
• Flags Field (3 bits):
• If its value is 1, it means the datagram is not the last fragment; there are more
fragments after this one.
• If its value is 0, it means this is the last or only fragment.
Network Layer Protocols: Internet Protocol (IP)
Fragmentation - Fields Related to Fragmentation:
• Fragmentation Offset Field (13 bits):
– Shows the relative position of this fragment with respect to the whole datagram.
– It is the offset of the data in the original datagram measured in units of 8 bytes.
2. No ICMP error message will be generated for a fragmented datagram that is not the first
fragment.
3. No ICMP error message will be generated for a datagram having a multicast address.
4. No ICMP error message will be generated for a datagram having a special address such
as 127.0.0.0 or 0.0.0.0.
Network Layer Protocols: ICMPv4
Error Reporting Messages
ICMP Request
Host
Host or
ICMP Reply Router
– The program is usually set to check for the maximum of 30 hops (routers) to be
visited.
– The tracert messages are encapsulated directly in IP datagrams.
– The tracert, like traceroute, sends echo-request messages. When the last echo
request reaches the destination host, an echoreplay message is issued.
Network Layer Protocols: ICMPv4
ICMP Checksum
• In ICMP the checksum is calculated over the entire message (header and data).
• Example: checksum calculation for a simple echo-request message. We randomly chose
the identifier to be 1 and the sequence number to be 9. The message is divided into 16-
bit (2-byte) words. The words are added and the sum is complemented. Now the sender
can put this value in the checksum field.
Unicast Routing
Algorithms
Distance Vector Routing
• 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.
• Bellman-Ford
Equation
– The heart of
distance-vector
routing is the
Unicast Routing
Algorithms
Distance Vector Routing
• A least-cost tree is a combination of least-cost paths from the root of the tree to all
destinations.
• Distance-vector routing unglues these paths and creates a distance vector, a one-
dimensional array to represent the tree.
• The name of the distance vector defines the root, the indexes define the destinations,
and the value of each cell defines the least cost from the root to the destination.
• The node sends some greeting messages out of its interfaces and discovers the identity
of the immediate neighbors and the distance between itself and each neighbor.
• It then makes a simple distance vector by inserting the discovered distances in the
corresponding cells and leaves the value of other cells as infinity.
Unicast Routing
Algorithms
Distance Vector Routing
– It sometimes takes several updates before the cost for a broken link is recorded as
infinity by all routers.
Unicast Routing
Algorithms
Distance Vector Routing
• Two Node Loop
– One example of count to infinity is the two-node loop problem.
– At the beginning, both nodes A and B know how to reach node X. But suddenly, the
link between A and X fails.
– Node A changes its table. If A can send its table to B immediately, everything is
fine.
– However, the system becomes unstable if B sends its forwarding table to A before
receiving A’s forwarding table.
– Node A receives the update and, assuming that B has found a way to reach X,
immediately updates its forwarding table.
– Now A sends its new update to B. Now B thinks that something has been changed
around A and updates its forwarding table.
– The cost of reaching X increases gradually until it reaches infinity.
Unicast Routing
Algorithms
Distance Vector Routing
• Two Node Loop
– At this moment, both A and B know that X cannot be reached.
– However, during this time the system is not stable. Node A thinks that the route to
X is via B; node B thinks that the route to X is via A.
– If A receives a packet destined for X, the packet goes to B and then comes back to
A.
– Similarly, if B receives a packet destined for X, it goes to A and comes back to B.
– In this strategy, instead of flooding the table through each interface, each node sends only part
of its table through each interface.
• Poison Reverse
– Normally, the corresponding protocol uses a timer, and if there is no news about a route, the
node deletes the route from its table.
– 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: “Do not use this value;
what I know about this route comes from you.”
• Three-Node Instability
– The two-node instability can be avoided using split horizon combined with poison reverse.
– 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.
– 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.
Unicast Routing
Link State Routing Algorithms
• Link-State Database (LSDB) Example
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.
Unicast Routing
Path-Vector RoutingAlgorithms
• Both link-state and distance-vector routing are based on the least-cost goal.
• 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.
• Path-vector routing does not have the drawbacks of LS or DV routing as described
above because it is not based on least-cost routing.
• 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.
• Spanning Tree
– 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.
Unicast Routing
Path-Vector RoutingAlgorithms
• Spanning Tree
– 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.
Unicast Routing
Path-Vector RoutingAlgorithms
• Spanning Tree - Example
– 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.
– 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.
Unicast Routing
Path-Vector RoutingAlgorithms
• Creation of Spanning Trees
– Path-vector routing, like distance-vector routing, is an
asynchronous and
distributed routing algorithm.
– The spanning trees are made, gradually and asynchronously, by each node.
– When a node is booted, it creates a path vector based on the information it can
obtain about its immediate neighbor.
– A node sends greeting messages to its immediate neighbors to
collect information.
– Each node, after the creation of the initial path vector, sends it to all its immediate
neighbors.
Unicast Routing
Path-Vector RoutingAlgorithms
• Creation of Spanning Trees
– 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.
Path(x, y) = best {Path(x, y), [(x + Path(v, y)]} for all v’s in the internet.
Internet Structure
• There are several backbones run by private communication companies that provide
global connectivity.
• These backbones are connected by some peering points that allow connectivity between
backbones.
• At a lower level, there are some provider networks that use the backbones for global
connectivity but provide services to Internet customers.
Unicast Routing Protocols
Internet Structure
• Finally, there are some customer networks that use the services provided by the
provider networks.
• Any of these three entities (backbone, provider network, or customer network) can be
called an Internet Service Provider or ISP.
Unicast Routing Protocols
Hierarchical Routing
• Routing in the Internet cannot be done using a single protocol for two reasons: a
scalability problem and an administrative issue.
• 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.
• Administrative issue: Related to the Internet structure. The administrator needs to have
control in its system.
• Hierarchical routing
– 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).
– The global routing protocol is referred to as inter-AS routing protocol, interdomain
routing protocol, or exterior gateway protocol (EGP).
– The two common intradomain routing protocols are RIP and OSPF; the only
interdomain routing protocol is BGP.
Unicast Routing Protocols
Autonomous Systems
• Each ISP is an autonomous system.
• Each AS is given an autonomous number (ASN) by the ICANN.
• Each ASN is a 16-bit unsigned integer that uniquely defines an AS.
• ASs are categorized according to the way they are connected to other ASs.
• Stub AS: It 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. Example: Customer
network.
• Multihomed AS: It have more than one connection to other ASs, but it does not allow
data traffic to pass through it. Example: Customer network.
• Transient AS: It is connected to more than one other AS and also allows the traffic to
pass through. Example: Provider networks and Backbone.
Unicast Routing Protocols
1. Routing Information Protocol (RIP)
• Most widely used intradomain routing protocols based on the distance-vector routing
algorithm.
Hop Count
• 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.
• In other words, the cost is defined between a router and the network in which the
destination host is located.
• 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.
Unicast Routing Protocols
1. Routing Information Protocol (RIP)
Hop Count
• 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.
• In RIP, the maximum cost of a path can be 15, which means 16 is considered as infinity
(no connection).
• RIP can be used only in autonomous systems in which the diameter of the AS is not
more than 15 hops.
Unicast Routing Protocols
1. Routing Information Protocol (RIP)
Forwarding Table
• The 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 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.
• 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.
Unicast Routing Protocols
1. Routing Information Protocol (RIP)
RIP Implementation
• It is a process that uses the service of UDP on the well-known port number 520.
• RIP is a daemon process (a process running in the background).
• RIP is a routing protocol to help IP route its datagrams through the AS, the RIP
messages are encapsulated inside UDP user datagrams, which in turn are
encapsulated inside IP datagrams.
• RIP runs at the application layer, but creates forwarding tables for IP at the network
layer.
• RIP has two versions: RIP-1 and RIP-2.
• The second version is backward compatible with the first section; it allows the use of
more information in the RIP messages that were set to 0 in the first version.
Unicast Routing Protocols
1. Routing Information Protocol (RIP)
RIP Messages
• RIP has two types of messages: request and response.
• A request message is sent by a router that has just come up or by a router that has some
time-out entries. A request message can ask about specific entries or all entries.
• A response (or update) message can be either solicited or unsolicited.
• A solicited response message is sent only in answer to a request message. It contains
information about the destination specified in the corresponding request message.
• An unsolicited response message is sent periodically, every 30 seconds or when there
is a change in the forwarding table.
Unicast Routing Protocols
1. Routing Information Protocol (RIP)
RIP Algorithm
• Some changes need to be made to the algorithm to enable a router to update its
forwarding table:
– 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. The received router selects the old routes as the new
ones except in the following three cases:
• If the received route does not exist in the old forwarding table, it should be
added to the route.
• If the cost of the received route is lower than the cost of the old one, the
received route should be selected as the new one.
• If the cost of the received route is higher than the cost of the old one, but the
value of the next router is the same in both routes, the received route should be
selected as the new one. (i.e) Cost value infinity (16 in RIP).
– The new forwarding table needs to be sorted according to the destination route.
Unicast Routing Protocols
1. Routing Information Protocol (RIP)
Timers in RIP
• RIP uses three timers to support its operation.
• Periodic timer: Controls the advertising of regular update messages. Each router has one periodic
timer that is randomly set to a number between 25 and 35 seconds. The timer counts down; when
zero is reached, the update message is sent.
• Expiration timer: Governs the validity of a route. When a router receives update information for a
route, the expiration timer is set to 180 seconds. If there is a problem on an internet and no update
is received within the allotted 180 seconds, the route is considered expired and the hop count of the
route is set to 16, which means the destination is unreachable.
• Garbage collection timer: Used to purge a route from the forwarding table. When the information
about a route becomes invalid, the router continues to advertise the route with a metric value of 16.
A garbage collection timer is set to 120 seconds 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.
Unicast Routing Protocols
1. Routing Information Protocol (RIP)
Performance
• Update Messages: The update messages in RIP have a very simple format and are sent
only to neighbors; they are local. They do not normally create traffic.
• 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. The only
problems that may slow down convergence are count-to-infinity and loops created in
the domain; use of poison-reverse and split-horizon strategies added to the RIP
extension may alleviate the situation.
• Robustness: As we said before, distance-vector routing is based on the concept that
each router sends what it knows about the whole domain to its neighbors. 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.
Unicast Routing Protocols
1. Routing Information Protocol (RIP)
Metric
• In OSPF, the 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.
• In OSPF, different service types (TOSs) can have different weights as the cost.
Unicast Routing Protocols
2. Open Shortest Path First (OSPF)
Forwarding Tables
• Each OSPF router can create a forwarding table after finding the shortest-path tree
between itself and the destination using Dijkstra’s algorithm.
Areas
• 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.
• This may not create a problem in a small AS, it may have created a huge volume of
traffic in a large AS.
Unicast Routing Protocols
2. Open Shortest Path First (OSPF)
Areas
• To prevent this, the AS needs to be divided into small sections called areas.
• Each area acts as a small independent domain for flooding LSPs.
• 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.
• In this way, a router in an area can receive all LSPs generated in other areas.
• For the purpose of communication, each area has an area identification.
• The area identification of the backbone is zero.
Unicast Routing Protocols
2. Open Shortest Path First (OSPF)
OSPF Implementation
• It is a program in the network layer, using the service of the IP for propagation.
• An IP datagram that carries a message from OSPF sets the value of the protocol field to
89.
• OSPF is a routing protocol to help IP to route its datagrams inside an AS, the OSPF
messages are encapsulated inside datagrams.
• OSPF has two versions: version 1 and version 2.
OSPF Messages
• OSPF is a very complex protocol; it uses five different types of messages.
• Hello message: Used by a router to introduce itself to the neighbors and announce all
neighbors that it already knows.
Unicast Routing Protocols
2. Open Shortest Path First (OSPF)
OSPF Messages
• Database description message: Response to the hello message to allow a newly joined
router to acquire the full LSDB.
• Link-state request message: A router sends whenever it needs information about a
specific LS.
• Link-state update message: Main OSPF message used for building the LSDB.
• Link-state acknowledgment message: Used to create reliability in OSPF; each router
that receives a link-state update message needs to acknowledge it.
• The OSPF common header has the provision for authentication of the message sender.
Unicast Routing Protocols
2. Open Shortest Path First (OSPF)
OSPF Messages
Unicast Routing Protocols
2. Open Shortest Path First (OSPF)
OSPF Algorithm
• 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
• Update Messages: The link-state messages are flooded to the whole area. If the area is large,
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. Each router
needs to run Dijkstra’s algorithm, which may take some time.
• 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.
Unicast Routing Protocols
3. Border Gateway Protocol Version 4 (BGP4)
• It is a interdomain routing protocol used in the Internet today.
• BGP4 is based on the path-vector algorithm.
Introduction
• An internet with four autonomous systems. AS2, AS3, and AS4 are stub autonomous
systems; AS1 is a transient one. Data exchange between AS2, AS3, and AS4 should
pass through AS1.
Unicast Routing Protocols
3. Border Gateway Protocol Version 4 (BGP4)
Introduction
• To enable each router to route a packet to any network in the internet, A variation of
BGP4 is installed, called external BGP (eBGP), on each border router.
• Then install the second variation of BGP, called internal BGP (iBGP), on all routers.
• The border routers will be running three routing protocols (intradomain, eBGP, and
iBGP), but other routers are running two protocols (intradomain and iBGP).
1. Some border routers do not know how to route a packet destined for non-
neighbor ASs.
2. None of the nonborder routers know how to route a packet destined for any
networks in other ASs.
• To address the above two problems, allow all pairs of routers (border or nonborder) to
run the second variation of the BGP protocol, iBGP.
• iBGP 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.
Unicast Routing Protocols
3. Border Gateway Protocol Version 4 (BGP4)
Path Attribute
Route Selection
• A route in BGP has some attributes attached to it and it may come from an eBGP
session or an iBGP session.
• The router extracts the routes which meet the criteria in each step.
Unicast Routing Protocols
3. Border Gateway Protocol Version 4 (BGP4)
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.
• All BGP packets share the same common header.
• Open Message: To create a neighborhood relationship, a router running BGP opens a
TCP connection with a neighbor and sends an open message.
• Update Message: It is used by a router to withdraw destinations that have been
advertised previously, to announce a route to a new destination, or both.
• Keepalive Message: The BGP peers that are running exchange keepalive messages
regularly to tell each other that they are alive.
• Notification: A router sends whenever an error condition is detected or a router wants to
close the session.
Unicast Routing Protocols
3. Border Gateway Protocol Version 4 (BGP4)
Messages
Performance
• BGP speakers exchange a lot of messages to create forwarding tables, but BGP is free
from loops and count-to-infinity.
• The same weakness like propagation of failure and corruption also exists in BGP.
Multicast Basics
Multicast Address
• A multicast address defines a group of recipients, not a single one.
• A multicast address is an identifier for a group.
• If a new group is formed with some active members, an authority can assign an unused
multicast address to this group to uniquely define it.
• The source address of a packet in multicast communication can be a unicast address that
uniquely defines the sender, but the destination address can be the multicast address
that defines a group.
Multicast Basics
Multicast Addresses in IPv4
• In classful addressing, all of class D was composed of multicast addresses.
• In classless addressing used the same block, but it was referred to as the block 224.0.0.0/4.
• The number of addresses in the multicast block is huge (228).
• Local Network Control Block: The subblock 224.0.0.0/24, is used inside a network, the packet
with a destination address in this range cannot be forwarded by a router.
• Internetwork Control Block: The subblock 224.0.1.0/24, is used in the whole Internet, the packet
with a destination address in this range can be forwarded by a router.
• Source-Specific Multicast (SSM) Block: The block 232.0.0.0/8 is used for source specific
multicast routing.
• GLOP Block: The block 233.0.0.0/8 defines a range of addresses that can be used inside an
autonomous system (AS).
• Administratively Scoped Block: The block 239.0.0.0/8 used in a particular area of the Internet.
The packet whose destination address belongs to this range is not supposed to leave the area.
Multicast Basics
Delivery at Data-Link Layer – Network with Multicast Support
• Most LANs support physical multicast addressing. Ethernet is one of them.
• An Ethernet physical address (MAC address) is six octets (48 bits) long.
• If the first 25 bits in an Ethernet address are 00000001 00000000 01011110 0, this
identifies a physical multicast address for the TCP/IP protocol.
• The remaining 23 bits can be used to define a group.
• To convert an IP multicast address into an Ethernet address, the multicast router extracts
the least significant 23 bits of a multicast IP address and inserts them into a multicast
Ethernet physical address.
• An Ethernet multicast physical address is in the range 01:00:5E:00:00:00 to
01:00:5E:7F:FF:FF.
Multicast Basics
Delivery at Data-Link Layer – Network with No Multicast Support
• Most WANs do not support physical multicast addressing.
• To send a multicast packet through these networks, a process called tunneling is used.
• In tunneling, the multicast packet is encapsulated in a unicast packet and sent
through the network, where it emerges from the other side as a multicast packet.
1. In multicast communication, the destination of the packet defines one group, but that
group may have more than one member in the internet. To reach all of the destinations,
the router may have to send the packet out of more than one interface.
Features of IPv6
• Support for real time services
• 128-bit addresses
• Multicast
• End-to-end fragmentation
• Security support (Authentication and Security)
• Auto configuration
• Enhanced routing functionality, including support for mobile hosts
IPv6
•
Addressing
The address space of IPv6 is divided into several blocks of varying size and each block
is allocated for a special purpose.
IPv6
Address Notation
Addressing
• Notation: x: x: x: x: x: x: x: x (x - 16bit hexadecimal number)
• Example: 47CD: 1234: 4422: AC02: D022: 1234: A456: 1203
• Abbreviation
FDEC:0:0:0:0:BBFF:0:FFFF FDEC::BBFF:0:FFFF
• Shorthand representation:
473D: 0000: 0000: 0000: 0000: 0000: A456: 1243 473D:: A456:
1243
FDEC::BBFF:0:FFFF/60
IPv6 Protocol
Packet Format
• The base header occupies 40 bytes, whereas payload can be up to 65,535 bytes of
information.
IPv6 Protocol
Packet Format
• Version (4 bit): Indicates the protocol version, and IPv6 value is 6.
• Traffic Class (8 bit): This field is used by the source and routers to identify the packets
belonging to the same traffic class and thus distinguish between packets with different
priorities.
• Flow Label (20 bit): Label for a data flow.
• Payload Length (16 bit): Indicates the length of the packet data field.
• Next Header (8 bit): Identifies the type of header immediately following the IPv6
header.
– 6: TCP , 17: UDP, 44: Fragmentation Extension Header, 59: No next header value.
• Hop Limit (8 bit):Decremented by one by each node that forwards the packet. When the
hop limit field reaches zero, the packet is discarded.
• Source Address (128 bit): The address of the originator of the packet.
• Destination Address (128 bit) : The address of the intended recipient of the packet.
IPv6 Protocol
Extension Header
• Hop-by-Hop Option: Used when the source needs to pass information to all routers
visited by the datagram.
• Destination Option: Used when the source needs to pass information to the destination
only. Intermediate routers are not permitted access to this information.
• Source Routing: Combines the concepts of the strict source route and the loose source
route options of IPv4.
• Fragmentation: 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: It validates the message sender and ensures the integrity of data.
• Encrypted Security Payload (ESP): Provides confidentiality and guards against
eavesdropping.