Cs3591cn Unit III & IV

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 141

CS3591 – Computer

Networks Unit III –


Network Layer
UNIT III – Network
Layer
Network Layer Services – Packet switching – Performance –
IPv4 Addresses – Forwarding of IP Packets – Network Layer
Protocols: IP, ICMPv4 – Unicast Routing Algorithms – Protocols
– Multicasting Basics – IPv6 Addressing – IPV6 Protocol.

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

the path (R2, R4, R5, and R7).

• 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.

• At the destination host (Bob), the datagram is decapsulated, and the


packet is

extracted and delivered to the corresponding transport layer.


Network Layer
1. Packetizing Services
• Encapsulating the payload (data received from upper layer) in a network-layer packet
at the source and decapsulating the payload from the network-layer packet at the
destination.
• The source host receives the payload from an upper-layer protocol, adds a header that
contains the source and destination addresses and some other information that is
required by the network-layer protocol.
• The destination host receives the network-layer packet from its data-link layer,
decapsulates the packet, and delivers the payload to the corresponding upper-layer
protocol.
• If the packet is fragmented at the source or at routers along the path, the network layer
is responsible for waiting until all fragments arrive, reassembling them, and delivering
them to the upper-layer protocol.
Network Layer
2. Services
Routing and Forwarding

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.

Quality of Service (QoS)


• Internet has allowed new applications such as multimedia communication (in
particular real-time communication of audio and video), the quality of service (QoS) of
the communication has become more important.
Network Layer
3. Other Services Services
Security
• The network layer was designed with no security provision.
• Today, security is a big concern.
• To provide security for a connectionless network layer, another virtual level is needed
that changes the connectionless service to a connection-oriented service.
Packet Switching
• Packet switching is used at the network layer.
• 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.
• The connecting devices in a packet-switched network still need to decide how to route
the packets to the final destination.
• Packet-switched network can use two different approaches to route the packets: the
datagram approach and the virtual circuit approach.
Packet Switching
1. Datagram Networks
• The idea was that the network layer is only responsible for delivery of packets from the
source to the destination.
• In this approach, the packets in a message may or may not travel the same path to their
destination.
• When the network layer provides a connectionless service, each packet traveling in the
Internet is an independent entity; there is no relationship between packets belonging to
the same message.
• A packet belonging to a message may be followed by a packet belonging to the same
message or to a different message.
• A packet may be followed by a packet coming from the same or from a different source.
Packet Switching
1. Datagram Networks

• 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.

• To create a connection-oriented service, a three-phase process is used: setup,


data
transfer, and teardown.
• Setup Phase: The source and destination addresses of the sender and receiver are used to
make table entries for the connection-oriented service.
• Teardown Phase: The source and destination inform the router to delete
the
corresponding entries.
• Data Transfer Phase: The two parties can transfer data.
Packet Switching
2. Virtual-Circuit Networks - Tables
• In the virtual-circuit approach, the forwarding decision is based on the label of the
packet.

Switch and tables in a virtual-circuit network


Packet Switching
2. Virtual-Circuit Networks

Setup Phase – Setup Request


• A request packet is sent from the source to the destination.
• This auxiliary packet carries the source and destination addresses.
Packet Switching
2. Virtual-Circuit Networks

Setup Phase – Setup Acknowledgement


• A special packet, called the acknowledgment packet, completes the entries in
the switching tables.
Packet Switching
2. Virtual-Circuit Networks

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).

Delaypr = Time required to process a packet in a router or a 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

• Total Delay: (source-to destination delay) A packet encounters can be calculated if we


know the number of routers, n, in the whole path.

Total delay = (n + 1) (Delaytr + Delaypg + Delaypr) + (n) (Delayqu)

where, n + 1 is No. of links & n is No. of routers


Network Layer
2. Throughput Performance
• The number of bits passing through the point in a second, which is actually the transmission rate of
data at that point.
• In a path from source to destination, a packet may pass through several links (networks), each with
a different transmission rate.

Throughput = minimum {TR1, TR2, . . . TRn}.

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.

• Congestion control refers to techniques and mechanisms that can either


prevent congestion before it happens or remove congestion after it has happened.
• Two broad categories: open-loop congestion control (prevention) and closed-loop
congestion control (removal).
Network Layer
4. Performance
Congestion Control - Open-Loop Congestion Control
• Policies are applied to prevent congestion before it happens.
• In these mechanisms, congestion control is handled by either the source or
the destination.
• Retransmission Policy: Retransmission policy and retransmission timers must be
designed to optimize efficiency and at the same time prevent congestion.
• Window Policy: The type of window at the sender may also affect congestion. The
Selective Repeat window is better than the Go-Back-N window for congestion control.
• Acknowledgment Policy: The acknowledgment policy imposed by the receiver may
also affect congestion. If the receiver does not acknowledge every packet it receives, it
may slow down the sender and help prevent congestion.
Network Layer
4.
Performance
Congestion Control - Open-Loop Congestion Control
• Discarding Policy: A good discarding policy by the routers may prevent congestion
and at the same time may not harm the integrity of the transmission
• Admission Policy: An admission policy, which is a quality-of-service mechanism, can
also prevent congestion in virtual-circuit networks. Switches in a flow first check the
resource requirement of a flow before admitting it to the network. A router can deny
establishing a virtual-circuit connection if there is congestion in the network or if there is
a possibility of future congestion.
Network Layer
Performance
4. Congestion Control - Closed-Loop Congestion Control
• It try to alleviate congestion after it happens.
• Backpressure: A congested node stops receiving data from the immediate upstream
node or nodes. This may cause the upstream node or nodes to become congested, and
they, in turn, reject data from their upstream node or nodes, and so on.

• Choke Packet: Packet sent by a node to the source to inform it of congestion. In


backpressure, the warning is from one node to its upstream node, although the warning
may eventually reach the source station. In the choke-packet method, the warning is
from the router, which has encountered congestion, directly to the source station.
Network Layer
Performance
4. Congestion Control - Closed-Loop Congestion Control
• Implicit Signaling: There is no communication between the congested node or nodes
and the source. The source guesses that there is congestion somewhere in the network
from other symptoms.
• Explicit Signaling: The node that experiences congestion can explicitly send a signal
to the source or destination. In the choke-packet method, a separate packet is used
for this purpose. In the explicit-signaling method, the signal is included in the packets
that carry data. Explicit signaling can occur in either the forward or the backward
direction.
IPv4
• The identifier used in theAddresses
IP layer of the TCP/IP protocol suite to identify the
connection of each device to the Internet is called the Internet address or IP address.
• Used to uniquely identify the host globally.
• IP Addresses are hierarchical. i.e., it is made up of two parts,
o Network part
o Host part
• Totally it provides 4 billion addresses. (i.e.) The address space is 232 or 4,294,967,296.
• In which,
o Half are A type,
o ¼ is B type, and 1/8 is C type
• IP address is represented as Dot notation. Eg: 128.11.3.31
IPv4
Hierarchy in Addresses
Addressing

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

• In class A, 127.0.0.1 – 127.255.255.255 addresses are reserved for


loopback & diagnostic purpose.
IPv4
Classful Addressing Addresses
• Address Depletion
– Classful addressing has become obsolete is address depletion.

– Since the addresses were not distributed properly, the Internet was faced with the
problem of the addresses being rapidly used up, resulting in no more addresses
available for organizations and individuals that needed to be connected to the
Internet.
• 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.

• Prefix Length: Slash Notation (CIDR – Classless Inter Domain Routing)

• 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.

1. The number of addresses in the block is found as N = 232−n.

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.

Address: 167.199.170.82/27 10100111 11000111 10101010


01010010
First address:
167.199.170.64/27 10100111 11000111 10101010 01000000
The last address can be found by keeping the first 27 bits and changing the rest of the bits
to 1s.

Address: 167.199.170.82/27 10100111 11000111 10101010 01010010

Last address: 167.199.170.95/27 10100111 11000111 10101010


01011111
IPv4
Classless Addressing: Address Addresses
Mask
• Another way to find the first and last addresses in the block is to use the address
mask.
• The address mask is a 32-bit number in which the n leftmost bits are set to 1s and the
rest of the bits (32 − n) are set to 0s.
• A computer can easily find the address mask because it is the complement of (232 − n − 1).
• The reason for defining a mask in this way is that it can be used by a computer program
to extract the information in a block, using the three bit-wise operations NOT, AND and
OR.

1. The number of addresses in the block N = NOT (mask) + 1.

2. The first address in the block = (Any address in the block) AND (mask).

3. The last address in the block = (Any address in the block) OR [(NOT (mask)].
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.

Number of addresses in the block:

N = NOT (mask) + 1= 0.0.0.31 + 1 = 32 addresses

First address:

First = (address) AND (mask) = 167.199.170.82

Last address:

Last = (address) OR (NOT mask) = 167.199.170.255


IPv4
Classless Addressing: NetworkAddresses
Address
• First address, the network address, is particularly important because it is used in routing
a packet to its destination network.
• When a packet arrives at the router from any source host, the router needs to know to
which network the packet should be sent: from which interface the packet should be sent
out.
• After the network address has been found, the router consults its forwarding table to find
the corresponding interface from which the packet should be sent out.
• The network address is actually the identifier of the network; each network is
identified by its network address.
IPv4
Addresses
Classless Addressing: Block Address
• The next issue in classless addressing is block allocation.
• The ultimate responsibility of block allocation is given to a global authority called the
Internet Corporation for Assigned Names and Numbers (ICANN).
• It assigns a large block of addresses to an ISP.
• For the proper operation of the CIDR, two restrictions need to be applied to the allocated
block.
1. The number of requested addresses, N, needs to be a power of 2. The reason is that N = 232 - n or
n = 32 - log2N. If N is not a power of 2, we cannot have an integer value for n.

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

1. The number of addresses in each subnetwork should be a power of 2.

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

has a valid IP address while in the renewing state.

• Your IP Address: The IP address that the server is assigning to the client.

• Server IP Address: Address of the DHCP server.

• CHAddr (Client Hardware Address): The hardware address of the client, which is

used for identification and communication.

• Sname (Server Name): Name of the DHCP server, provided by the server during the

response.
IPv4
Addresses
Network Address Translation (NAT)

• The distribution of addresses through ISPs has created a new problem.


• Assume that an ISP has granted a small range of addresses to a small business or a
household.
• If the business grows or the household needs a larger range, the ISP may not be able to
grant the demand because the addresses before and after the range may have already
been allocated to other networks.
• The technology allows a site to use a set of private addresses for internal
communication and a set of global Internet addresses (at least one) for
communication with the rest of the world.
• The site must have only one connection to the global Internet through a NAT-
capable router that runs NAT software.
IPv4
Network Address Translation Addresses
(NAT)

• As the figure 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 Internet
sees
only the NAT router with the address 200.24.5.8.
IPv4
Network Address Translation Addresses
(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

• To allow a many-to-many relationship between private-network hosts and external


server programs.
• 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.

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

• Longest Mask Matching & Forwarding Table Search Algorithms

• 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)

– A New Header: To encapsulate the IPv4 packet in an MPLS packet.

– 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.

Length of data = total length − (HLEN) × 4


• Identification, Flags, and Fragmentation Offset: These three fields are related to the
fragmentation of the IP datagram when the size of the datagram is larger than the
underlying network can carry.
Network Layer Protocols: Internet Protocol (IP)
Datagram Format
• Time-to-Live (8 bits): used to control the maximum number of hops (routers) visited by
the datagram.
• Protocol (8 bits): Demultiplexing key for higher level layer protocols.
TCP – 6 UDP - 17
• Header checksum (16 bits): Used to detect errors in header.

– Checksum is calculated by considering the entire header as a sequence of 16 bit


words, adding them and taking the ones compliment of the result
• Source and Destination Addresses (32 bits each): IP address of the source and
destination host.
• Options: A datagram header can have up to 40 bytes of options. Used for network
testing and debugging.
• Payload: Data, the packet coming from other protocols that use the service of IP.
Network Layer Protocols: Internet Protocol (IP)
Fragmentation
• In a heterogeneous collection of networks, each network has its own capacity to receive
a packet called Maximum Transfer Unit (MTU).
• Maximum Transfer Unit (MTU): Largest IP datagram that it can carry in a frame.
• Ethernet can accept up to 1500 bytes long packet. For FDDI, it is 4500 bytes long and
for PPP 512 bytes long.
• Fragmentation occurs in a router when it receives a datagram that it wants to forward
over a network which has MTU < IP datagram size.
• Reassembly is done at the receiving host.
Network Layer Protocols: Internet Protocol (IP)
Fragmentation - Fields Related to Fragmentation:
• Three fields in an IP datagram are related to fragmentation: identification, flags, and
fragmentation offset.
• Identification Field (16 bits):

• Identifies a datagram originating from the source host.

• 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):

– The leftmost bit is reserved (not used).

– The second bit (D bit) is called the do not fragment bit.

• If its value is 1, the machine must not fragment the datagram.

• If it cannot pass the datagram through any available physical


network, it discards the datagram and sends an ICMP
error message to the source host.
• If its value is 0, the datagram can be fragmented if necessary.

– The third bit (M bit) is called the more fragment bit.

• 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.

– Used to identify the starting byte of the fragment.

– It is the offset of the data in the original datagram measured in units of 8 bytes.

(a) Unfragmented packet (b)Fragmented packets


Network Layer Protocols: Internet Protocol (IP)
Fragmentation
• Each fragment is itself a self-contained IP datagram that is transmitted over a sequence
of physical networks, independent of other fragments.
• Each IP datagram is re-encapsulated for each physical network over which it travels.
• IP does not recover any missing fragments.
Network Layer Protocols: Internet Protocol (IP)
Security of IPv4 Datagrams
• No security was provided for the IPv4 protocol.
• Packet Sniffing: An intruder may intercept an IP packet and make a copy of it. Packet
sniffing is a passive attack, in which the attacker does not change the contents of the
packet.
• Packet Modification: The attacker intercepts the packet, changes its contents, and
sends the new packet to the receiver. The receiver believes that the packet is coming
from the original sender. Prevented using data integrity mechanism.
• IP Spoofing: An attacker can masquerade as somebody else and create an IP packet
that carries the source address of another computer. An attacker can send an IP packet to
a bank pretending that it is coming from one of the customers. Prevented using an origin
authentication mechanism.
Network Layer Protocols: Internet Protocol (IP)
Security of IPv4 Datagrams - IPSec
• Used in conjunction with the IP protocol, creates a connection-oriented service between
two entities in which they can exchange IP packets without worrying about the three
attacks.
• Defining Algorithms and Keys: The two entities that want to create a secure channel.
• Packet Encryption: The packets exchanged between two parties can be encrypted for
privacy using one of the encryption algorithms and a shared key. Packet Sniffing is
eliminated.
• Data Integrity: Guarantees that the packet is not modified during the transmission.
• Origin Authentication: IPSec can authenticate the origin of the packet to be sure that
the packet is not created by an imposter.
Network Layer Protocols: ICMPv4
• The IPv4 has no error-reporting or error-correcting mechanism.
• The IP protocol also lacks a mechanism for host and management queries.
• A host needs to determine if a router or another host is alive.
• A network manager needs information from another host or router.
• ICMP itself is a network-layer protocol.
• The ICMP messages are first encapsulated inside IP datagrams before going to the
lower layer.
• When an IP datagram encapsulates an ICMP message, the value of the protocol field in
the IP datagram is set to 1 to indicate that the IP payroll is an ICMP message.
Network Layer Protocols: ICMPv4
• ICMP messages are divided into two broad categories: error-reporting messages and
query messages.
• The error-reporting messages report problems that a router or a host (destination) may
encounter when it processes an IP packet.
• The query messages, which occur in pairs, help a host or a network manager get
specific information from a router or another host.
• An ICMP message has an 8-byte header and a variable-size data section.
• The data section in error messages carries information for finding the original packet
that had the error.
• In query messages, the data section carries extra information based on the type of
query.
Network Layer Protocols: ICMPv4
Header Format

• Type (8 bits): Type of ICMP message


• Code (8 bits): Sub-type of ICMP message
• Checksum (16 bits): For error detection. Similar to IP checksum.
Network Layer Protocols: ICMPv4
Error Reporting Messages
• The main responsibilities of ICMP is to report some errors that may occur during the
processing of the IP datagram.
• ICMP uses the source IP address to send the error message to the source of the datagram.
• To make the error-reporting process simple, ICMP follows some rules in reporting
messages.

1. No ICMP error message will be generated in response to a datagram carrying an ICMP


error message.

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

Type Code Message Description


The reason why a datagram has not reached its
3 0 – 15 Destination Unreachable
final destination.
The network has encountered congestion and
4 0 Source Quench the datagram has been dropped; the source
needs to slow down sending more datagrams.
Router redirects the message to the appropriate
router, but informs the source that it needs to
5 0–3 Redirection Message change its default router in the future. The IP
address of the default router is sent in the
message.
There is a problem in the header of a datagram
12 0/1 Parameter Problem / Some options are missing or cannot
be
interpreted
Network Layer Protocols: ICMPv4
Query Messages
• Used to probe or test the liveliness of hosts or routers in the Internet.
• To find the one-way or the round-trip time for an IP datagram between two devices, or
even find out whether the clocks in two devices are synchronized.
• Query messages come in pairs: request and reply.

ICMP Request
Host
Host or
ICMP Reply Router

Type Code Message Description


8 0 Echo Request Used by a host or a router to test
0 0 Echo Reply the
liveliness of another host or router.
13 0 Timestamp Request Used to find the round-trip time between two
devices or to check whether the
14 0 Timestamp Reply clocks in two devices are synchronized.
Network Layer Protocols: ICMPv4
Deprecated Messages
• Three pairs of messages are declared obsolete by IETF:
• Information request and replay messages: Their duties are done by the
Address Resolution Protocol (ARP). (To get Link-Layer Address)
• Address mask request and reply messages: Their duties are done by the Dynamic
Host Configuration Protocol (DHCP). (To Assign Subnet Mask)
• Router solicitation and advertisement messages: Their duties are done by
the
Dynamic Host Configuration Protocol (DHCP). (To Assign IP Address)
Network Layer Protocols: ICMPv4
Debugging Tools
• There are several tools that can be used in the Internet for debugging.
• Two tools that use ICMP for debugging: ping and traceroute.
• Ping
– The source host sends ICMP echo-request messages; the destination, if alive,
responds with ICMP echo-reply messages.
– The ping program sets the identifier field in the echo-request and echo-reply
message and starts the sequence number from 0; this number is incremented by 1
each time a new message is sent.
– The ping can calculate the round-trip time. It inserts the sending time in the data
section of the message. When the packet arrives, it subtracts the arrival time from
the departure time to get the round-trip time (RTT).
Network Layer Protocols: ICMPv4
Debugging Tools
• Ping
Network Layer Protocols: ICMPv4
Debugging Tools
• Traceroute or Tracert
– The traceroute program in UNIX or tracert in Windows can be used to trace the
path of a packet from a source to the destination.
– It can find the IP addresses of all the routers that are visited along the path.

– 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

The distance vector corresponding to a tree

The first distance


vector for an internet

Updating distance vectors


Unicast Routing
Algorithms
Distance Vector Routing
• Count to Infinity
– For a routing protocol to work properly, if a link is broken (cost becomes infinity),
every other router should be aware of it immediately, but in distance-vector routing,
this takes some time.
– The problem is referred to as count to infinity.

– It sometimes takes several updates before the cost for a broken link is recorded as
infinity by all routers.
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.

– Packets bounce between A and B, creating a two-node loop problem.


Unicast Routing
Algorithms
Distance Vector Routing
• Split Horizon
– One solution to instability is called split horizon.

– In this strategy, instead of flooding the table through each interface, each node sends only part
of its table through each interface.
• 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.

– However, if the instability is between three nodes, stability cannot be guaranteed.


Unicast Routing
Link State Routing Algorithms
• Uses the term link-state to define the characteristic of a link (an edge) that represents a network in
the internet.
• In this algorithm the cost associated with an edge defines the state of the link.
• Links with lower costs are preferred to links with higher costs; if the cost of a link is infinity, it
means that the link does not exist or has been broken.
• Link-State Database (LSDB)
– To create a least-cost tree with this method, each node needs to have a complete map of the
network, which means it needs to know the state of each link.
– The collection of states for all links is called the link-state database (LSDB).

– There is only one LSDB for the whole internet; each node needs to have a duplicate of it to
be able to create the least-cost tree.
– 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

• LSPs created and sent out by each node to build LSDB


Unicast Routing
Link State Routing Algorithms
• LSDB 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);
• When a node receives an LSP from one of its interfaces, it compares the LSP with the
copy it may already have.
• If the newly arrived LSP is older than the one it has (found by checking the sequence
number), it discards the LSP.
• If it is newer or the first one received, the node discards the old LSP (if there is one)
and keeps the received one.
Unicast Routing
Link State Routing Algorithms
• It then sends a copy of it out of each interface except the one from which the packet
arrived.
• This guarantees that flooding stops somewhere in the network (where a node has only
one interface).
• After receiving all new LSPs, each node creates the comprehensive LSDB.
• This LSDB is the same for each node and shows the whole map of the internet.
• Distance Vector Routing Vs. Link State Routing
– In the distance-vector routing algorithm, each router tells its neighbors what it
knows about the whole internet.
– In the link-state routing algorithm, each router tells the whole internet what it knows
about its neighbors.
Unicast Routing
Link State Routing Algorithms
• Formation of Least-Cost Trees: To create a least-cost tree for itself, using the shared
LSDB, each node needs to run the famous Dijkstra Algorithm.
• This iterative algorithm uses the following steps:

1. The node chooses itself as the root of the tree, creating a tree with a single node, and
sets the total cost of each node based on the information in the LSDB.

2. The node selects one node, among all nodes not in the tree, which is closest to the root,
and adds this to the tree. After this node is added to the tree, the cost of all other nodes
not in the tree needs to be updated because the paths may have been changed.

3. The node repeats step 2 until all nodes are added to the tree.
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.

Path vectors made at booting time Updating path vectors


Unicast Routing Protocols
• A protocol needs to define its domain of operation, the messages exchanged,
communication between routers, and interaction with protocols in other domains.
• Three common protocols used in the Internet: Routing Information Protocol (RIP),
based on the distance-vector algorithm, Open Shortest Path First (OSPF), based on the
link-state algorithm, and Border Gateway Protocol (BGP), based on the path-vector
algorithm.

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)

Example of an autonomous system using RIP


Unicast Routing Protocols
2. Open Shortest Path First (OSPF)
• Open Shortest Path First (OSPF) is also an intradomain routing protocol.
• It is based on the link-state routing protocol.

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)

Link-State Advertisement: Five Types


• Summary link to network: 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.
• Summary link to AS border router: Done by an AS router that advertises the summary
links from other ASs to the backbone area of the current AS.
• External link: 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.
• Router link: Advertises the existence of a router as a node.
• Network link: Advertises the network as a node.
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).

Operation of External BGP (eBGP)


• BGP is a kind of point-to-point protocol.
• When the software is installed on two routers, they try to create a TCP connection
using the well-known port 179.
• The two routers that run the BGP processes are called BGP peers or BGP speakers.
Unicast Routing Protocols
3. Border Gateway Protocol Version 4 (BGP4)

Operation of External BGP (eBGP)


• The eBGP variation of BGP allows two physically connected border routers in two
different ASs to form pairs of eBGP speakers and exchange messages.
Unicast Routing Protocols
3. Border Gateway Protocol Version 4 (BGP4)

Operation of Internal BGP (iBGP)


• There are two problems that need to be addressed:

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)

Operation of Internal BGP (iBGP)


• If an AS has only one router, there cannot be an iBGP session.
• 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.
Unicast Routing Protocols
3. Border Gateway Protocol Version 4 (BGP4)

Path Attribute

• BGP allows a destination to be associated with up to seven path attributes.


• Path attributes are divided into two broad categories: well-known and optional.
• Well-known attribute: Recognized by all routers; Optional attribute: Need not be.
• A well-known attribute can be mandatory, which means that it must be present in any
BGP update message, or discretionary, which means it does not have to be.
• An optional attribute can be either transitive, which means it can pass to the next AS,
or intransitive, which means it cannot.
Unicast Routing Protocols
3. Border Gateway Protocol Version 4 (BGP4)

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.

Collecting Information about Groups


• In multicasting, two protocols are needed: one to collect group information and the
second to propagate them.
• Collecting group information is done by the Internet Group Management Protocol
(IGMP).
• These pieces of information are propagated using different multicast protocols.
Multicast Basics
Multicast Forwarding
• Forwarding in multicast communication is different in two aspects:

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.

2. Forwarding decisions in multicast communication depend on both the destination


and the source address of the packet. In multicasting, forwarding is based on where
the packet should go and where the packet has come from.
Multicast Forwarding Multicast Basics
1. Source-Based Tree Approach
• Each router needs to create a separate tree for each source-group combination.
• If there are m groups and n sources in the internet, a router needs to create (m × n) routing trees.
• In each tree, the corresponding source is the root, the members of the group are the leaves, and
the router itself is somewhere on the tree.

2. Group-Based Tree Approach


• A router is designed to act as the phony source for each group.
• The designated router, which is called the core router or the rendezvouspoint router, acts as the
representative for the group.
• Any source that has a packet to send to a member of that group sends it to the core center
(unicast communication) and the core center is responsible for multicasting. (Uses tunneling)
• The core center creates one single routing tree with itself as the root and any routers with active
members in the group as the leaves.
• In this approach, there are m core routers (one for each group) and each core router has a routing
tree, for the total of m trees.
IPv6

Addressing
To provide more address space IPv6 is invented.

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

(i.e.) contiguous 0’s are compressed.


• CIDR Notation

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.

You might also like