Updated CN Module 3
Updated CN Module 3
2
4.1 Network Layer Design Issues
3
4.1.1 Store and Forward Packet Switching
The context in which network layer works can be seen in the next fig.
Major components are ISPs equipment, i.e routers connected by transmission lines, and customer’s
equipment, i.e hardware devices
As seen in the fig, host H1 is connected directly to ISP’s router, whereas host H2 is connected to a
LAN
This LAN is an office internet connected to router F, owned and operated by owner (office managers)
and has leased a line to ISP’s equipment
F is outside the oval as it does not belong to ISP, but algorithm that they run on are the same
4
4.1.1 Store and Forward Packet Switching
5.1.1 Store and Forward Packet Switching
6
4.1.2 Services provided to Transport layer
7
4.1.3 Implementation of Connectionless Service
If connectionless service is offered, packets are injected in the network individually and routed
independently of each other
No advance set up is needed
In this context, packets are known as datagram and n/w is called a datagram network
8
5.1.3 Implementation of Connectionless Service
A’s table (initially) A’s table (later) C’s Table E’s Table
Fig. 5.1.3 9
4.1.4 Implementation of Connection Oriented Service
For connection-oriented service, we need a virtual-circuit network. The idea behind virtual circuits is to
avoid having to choose a new route for every packet sent
Instead, when a connection is established, a route from the source machine to the destination machine
is chosen as part of the connection setup and stored in tables inside the routers. That route is used for
all traffic flowing over the connection, exactly the same way that the telephone system works
10
4.1.4 Implementation of Connection Oriented Service
That route is used for all traffic flowing over the connection, exactly the same way that the telephone
system works. When the connection is released, the virtual circuit is also terminated. With
connection-oriented service, each packet carries an identifier telling which virtual circuit it belongs to
Consider the situation shown in Fig. 5.1.4. Here, host H1 has established connection 1 with host H2.
This connection is remembered as the first entry in each of the routing tables .
11
4.1.4 Implementation of Connection Oriented Service
Fig. 5.1.4 12
4.1.4 Implementation of Connection Oriented Service
The first line of A’s table says that if a packet. bearing connection identifier 1 comes in from H1, it is to
be sent to router C and given connection identifier 1. Similarly, the first entry at C routes the packet to E,
also with connection identifier 1
It chooses connection identifier 1 (because it is initiating the connection and this is its only connection)
and tells the network to establish the virtual circuit. This leads to the second row in the tables
13
4.1.4 Implementation of Connection Oriented Service
We have a conflict here because although A can easily distinguish connection 1 packets from H1 from
connection 1 packets from H3, C cannot do this
For this reason, A assigns a different connection identifier to the outgoing traffic for the second
connection. Avoiding conflicts of this kind is why routers need the ability to replace connection
identifiers in outgoing packets
This process is called label switching. An example of a connection-oriented network service is MPLS
(Multi Protocol Label Switching). It is used within ISP networks in the Internet, with IP packets
wrapped in an MPLS header having a 20-bit connection identifier or label
14
4.1.5 Comparison of Virtual-Circuit and Datagram Networks
Both virtual circuits and datagrams have their supporters and their detractors
The major issues are listed in Fig. 5.1.5
15
4.1.5 Comparison of Virtual-Circuit and Datagram Networks
Fig. 5.1.5 16
4.1.5 Comparison of Virtual-Circuit and Datagram Networks
A related issue is that the destination addresses used in datagram networks are longer than circuit
numbers used in virtual-circuit networks because they have a global meaning. If the packets tend
to be fairly short, including a full destination address in every packet may represent a significant
amount of overhead, and hence a waste of bandwidth
Another issue is the amount of table space required in router memory. A datagram network needs
to have an entry for every possible destination, whereas a virtual-circuit network just needs an
entry for each virtual circuit.
17
4.1.5 Comparison of Virtual-Circuit and Datagram Networks
However, this advantage is somewhat illusory since connection setup packets have to be routed
too, and they use destination addresses, the same as datagrams do.
Virtual circuits have some advantages in guaranteeing quality of service and avoiding congestion
within the network because resources (e.g., buffers, bandwidth, and CPU cycles) can be reserved
in advance, when the connection is established. Once the packets start arriving, the necessary
bandwidth and router capacity will be there. With a datagram network, congestion avoidance is
more difficult.
18
5.1.5 Comparison of Virtual-Circuit and Datagram Networks
For transaction processing systems (e.g., stores calling up to verify credit card purchases), the overhead
required to set up and clear a virtual circuit may easily dwarf the use of the circuit.
If the majority of the traffic is expected to be of this kind, the use of virtual circuits inside the network
makes little sense. On the other hand, for long-running uses such as VPN traffic between two corporate
offices, permanent virtual circuits (that are set up manually and last for months or years) may be useful.
19
4.1.5 Comparison of Virtual-Circuit and Datagram Networks
Virtual circuits also have a vulnerability problem. If a router crashes and loses its memory, even if it
comes back up a second later, all the virtual circuits passing through it will have to be aborted.
n contrast, if a datagram router goes down, only those users whose packets were queued in the router at
the time need suffer (and probably not even then since the sender is likely to retransmit them shortly).
The loss of a communication line is fatal to virtual circuits using it.
Datagrams also allow the routers to balance the traffic throughout the network, since routes can be
changed partway through a long sequence of packet transmissions.
20
Communication Primitives
▪ Data is transported over a network by three simple methods i.e. Unicast,
Broadcast, and Multicast.
▪ Unicast: traffic, many streams of IP packets that move across networks flow from a
single point, such as a website server, to a single endpoint such as a client PC. This
is the most common form of information transference on networks.
▪ Broadcast: Here, traffic streams from a single point to all possible endpoints
within reach on the network, which is generally a LAN. This is the easiest technique
to ensure traffic reaches its destinations.
▪ This mode is mainly utilized by television networks for video and audio distribution.
Even if the television network is a cable television (CATV) system, the source signal
reaches all possible destinations, which is the key reason that some channels’
content is scrambled. Broadcasting is not practicable on the public Internet due to
the massive amount of unnecessary data that would continually reach each user’s
device, the complications and impact of scrambling, and related privacy issues.
Communication Primitives
▪ Multicast: In this method traffic recline between the boundaries of unicast (one point to one
destination) and broadcast (one point to all destinations). And multicast is a “one source to
many destinations” way of traffic distribution, which means that only the destinations that
openly point to their requisite to accept the data from a specific source to receive the traffic
stream.
▪ In the multicast model, the source and destinations are almost every time “Host” and not
“Routers”. The multicast traffic is spread by multicast routers across the network from source
to destination. The multicast routers must find multicast sources on the network, send out
copies of packets on a number of interfaces, avoid loops, connect interested destinations with
accurate sources and keep the flow of unsolicited packets to a minimum. The standard
protocols of multicast routing provide most of these facilities, but some router architecture
cannot send multiple copies of packets and so do not support direct multicasting.
IPV4 addresing (classfull & classless)
Introduction
❑ Header:
✔ 20 to 60 bytes in length
✔ contains information essential to routing and delivery.
✔ In TCP/IP it is customary to show header in 4 byte section.
IPv4 datagram format
IPv4 datagram header format
Version(VER):-
4 bit field defines the version [Version 4] of IP software running
If machine is using some other version of IP, the datagram is discarded rather that interpreted incorrectly.
Header Length(HLEN):-
4 bit field defines the total length of the datagram header in 4 byte words.
The length of the header is variable (between 20 and 60 bytes)
When there are no options:-
✔ HLEN is 20 bytes and the value of the field is 5 (5*4=20)
When the options field is at maximum size:
✔ HLEN is 60 bytes value of field is 15 (15*4=60)
IPv4 Addresses
IP Address: identifier used in IP layer to identify each device connected to the internet
It is a 32 bit long address ,unique and universal.
IPv4 addresses has address space.
Address space- is the total number of addresses used by the protocol.
If a protocol uses N bits to define an address, the address space is 2N because each bit can have two different
values (0 and 1) and N bits can have 2N values.
The address space of IPv4 is 232 or 4,294,967,296.
Classful Addrssing
b. The first byte is 193 (between 192 and 223); the class is C.
d. The first byte is 252 (between 240 and 255); the class is E.
e. The first byte is 134 (between 128 and 191); the class is B.
Netid and Hostid
✔Each address in classful addressing contains two parts: netid and hosted
✔The netid defines the network and hostid defines particular host connected to that network.
Blocks in class A
1 byte=Netid with leftmost bit 0 , Number of blocks=27 = 128 , each block=16,777,216 addresses
Many addresses are wasted
Blocks in class B
2 byte = Netid with leftmosts bit 10 , Number of blocks=214 = 16,384 , each block=65,536 addresses
Many addresses are wasted
Blocks in class C
3 byte = Netid with leftmost bits 110 , Number of blocks=221 = 2,097,152 , each block=256 addresses .
Not so organizations are so small to have a class C block.
The single block in class D
Solution
As 73 is in between 0 & 127, its Class=A , n=8
Solution
1. The number of addresses in the block, N , can be found using N = 232-n = 224 =16,777,216
2. To find the first address, we keep the n leftmost bits and set the (32-n = 24) rightmost bits all to 0s. The
first address (called as network address) is 73.0.0.0/8 in which 8 is the value of n and not assigned to any
host.
3. To find the last address, we keep the n leftmost bits as it is and set the (32-n=24) rightmost bits all to 1s.
The last address is 73.255.255.255. the last address is normally used for a special purpose.
Example
Solution
As 180 is in between 128 & 191, its Class=B,
n=16
Solution
1. The number of addresses in the block, N , can be found using N = 232-n = 216
=65,536
2. To find the first address, we keep the leftmost 16 bits and set the (32-n=16)
rightmost 16 bits all to 0s. The first address(network address) is 18.8.0.0/16
3. To find the last address, we keep the leftmost 16 bits and rightmost 16 bits to 1s.
The last address is 18.8.255.255
Example
Solution
As 200 is in between 192 & 223, its Class=C,
n=24
Solution
1. The number of addresses in the block, N , can be found using N = 232-n = 28 =256
2. To find the first address, we keep the leftmost 24 bits and set the (32-n=16)
rightmost 8 bits all to 0s. The first address(network address) is 200.11.8.o/24
3. To find the last address, we keep the leftmost 24 bits and all to 1s. The last
address is 200.11.8.255
Sample Internet
✔ To
extract the network address from destination address of a packet, a router uses the
AND operation.
Example 1
Solution
Since the class of the address is A, we assume that the router applies the default mask for
class B, 255.0.0.0 to find the network address
Decimal Binary
IP 93.12.5.3 01011101 00001100 00000101 00000011
Default 255.0.0.0 11111111 00000000 00000000 00000000
Mask
Network ID 93.0.0.0 01011101 00000000 00000000 00000000
after
ANDing
Solution
Since the class of the address is C, we assume that the router applies the
default mask for class C, 255.255.255.0 to find the network address.
Subnetting
✔ Splitting a block to smaller blocks is subnetting
✔ In Subnetting, a network is divided into several smaller subnetworks (subnets) with each
subnetworking having its own subnetwork address.
✔ 626 is the area code, 358 is the exchange, and 1301 is the subscriber connection.
Example
Figure (next) shows class B addresses before subnetting.
one network with almost 216 hosts. The whole network is connected, through one single
connection, to one of the routers in the Internet.
/16 to show the length of the netid (class B).
same network after subnetting
The whole network is still connected to the Internet through the same router. However, the
network has used a private router to divide the network into four subnetworks. The rest of
the Internet still sees only one network; internally the network is made of four subnetworks.
Each subnetwork can now have almost 214 hosts. The network can belong to a university
campus with four different schools (buildings). After subnetting, each school has its own
subnetworks, but still the whole campus is one network for the rest of the Internet. Note that
/16 and /18 show the length of the netid and subnetids.
Network mask and subnetwork mask
This means that the subnet mask has eighteen 1s and fourteen 0s.
In other words, the subnet mask is 255.255.192.0 which is
different from the network mask for class B (255.255.0.0).
Example
In previous Example we show that a network is divided into four subnets. Since one of
the addresses in subnet 2 is 141.14.120.77, we can find the subnet address as:
The values of the first, second, and fourth bytes are calculated using the first
short cut for AND operation. The value of the third byte is calculated using the
second short cut for the AND operation.
Supernetting
As most organizations did not want to share their granted blocks with others, subnetting could
not completely solve address depletion problem.
When size of block did not meet the requirement of new organization, option of supernetting
can be used.
Organization can combine several class C blocks to create a large range of addresses
Several networks are combined to create a Supernetwork.
By doing this an organization can apply for several class C blocks instead of just one.
nsub= 24+3=27
n = 24
Solutio
n
The number of 1s in the default mask is 24 (class C).
Solution
(Continued)
The company needs six subnets. This number 6 is not a power of 2. The next
number that is a power of 2 is 8 (23). We need 3 more 1s in the subnet mask.
The total number of 1s in the subnet mask is 27 (24 + 3).
The total number of 0s is 5 (32 - 27). The mask is
11111111 11111111 11111111 11100000
or
255.255.255.224
The number of subnets is 8.The number of addresses in each subnet is 25 (5
is the number of 0s) or 32. Refer Next Figure
Example 1
Example 2
(Subnet)
A company is granted the site address 181.56.0.0 (class B).
The company needs 1000 subnets. Design the subnets.
Solution
Solution
The supernet has 21 1s. The default mask has 24 1s. Since the
difference is 3, there are 23 or 8 blocks in this supernet. The blocks
are 205.16.32.0 to 205.16.39.0. The first address is 205.16.32.0.
The last address is 205.16.39.255.
Routing Header
Types
Routing Algorithm
► The Dijkstra’s algorithm finds the shortest path from a particular node, called
the source node to every other node in a connected graph. It produces a
shortest path tree with the source node as the root. It is profoundly used in
computer networks to generate optimal routes with the aim of minimizing
routing costs.
► Input − A graph representing the network; and a source node, s
► Output − A shortest path tree, spt[], with s as the root node.
Shortest Path Algorithm
► An array of distances dist[] of size |V| (number of nodes), where dist[s] = 0 and dist[u] = ∞ (infinite), where u
represents a node in the graph except s.
► An array, Q, containing all nodes in the graph. When the algorithm runs into completion, Q will become
empty.
► An empty set, S, to which the visited nodes will be added. When the algorithm runs into completion, S will
contain all the nodes in the graph.
► Repeat while Q is not empty −
► Remove from Q, the node, u having the smallest dist[u] and which is not in S. In the first run, dist[s] is
removed.
► Add u to S, marking u as visited.
► For each node v which is adjacent to u, update dist[v] as −
► If (dist[u] + weight of edge u-v) < dist[v], Then
► Update dist[v] = dist[u] + weight of edge u-v
► The array dist[] contains the shortest path from s to every other node.
Shortest Path Algorithm (1)
94
1. The first five steps used in computing the shortest path from A to D. The arrows indicate the
working node
4.2 Flooding
► In this every incoming packets is sent out on every outgoing line except the one it arrived
► It produces infinite number of duplicate packets unless some measure is used to damp the
process
► Process for Damping:
1. hop counter
2.To keep track of which packets have been flooded
3.selective flooding
► To choose a route between a given pair of routers, the algorithm just finds the shortest path
between them on graph.
► There are many Algorithms for computing the shortest path
► One of them is Dijkstra 95
4.2 Distance Vector Routings
► Distance vector routing algorithms operate by having each router
maintain a table (i.e, a vector) giving the best known distance to each
destination and which line to use to get there.
► These tables are updated by exchanging information with the
neighbors.
► The distance vector routing algorithm is sometimes called by other
names, Bellman-Ford routing algorithm and the Ford-Fulkerson
algorithm,.
96
Distance Vector Routings
► In this, each router maintains a routing table containing one entry for each
router in the subnet. This entry contains two parts:
► the preferred outgoing line to use for that destination and an estimate of the
time or distance to that destination.
► The metric used might be number of hops, time delay in milliseconds, total
number of packets queued along the path, or something similar.
► The router is assumed to know the ''distance'' to each of its neighbors.
► If the metric is hops, the distance is just one hop. If the metric is queue length,
the router simply examines each queue.
► If the metric is delay, the router can measure it directly with special ECHO
packets that the receiver just timestamps and sends back as fast as it can.
Distance Vector Routings
► Example: Assume that delay is used as a metric and the router knows the
delay of each of its neighbors.
► Once every T msec, each router sends to each neighbor a list of its estimated
delays to each destination.
► It also receives a similar list from each neighbor.
► Imagine that one of these tables has just come in from neighbor X, with Xi
being X’s estimate of how long it takes to get to router i. If the router knows
that the delay to X is msec, it also knows that it can reach router I via X Xi+
m msec.
► By performing this calculation for each neighbor, a router can find out which
estimate seems the best and use that estimate and the corresponding link in
its new routing table. Old routing table is not used in the calculations.
Distance Vector Routings
Explanation
► I am at N1 router so its dist=0 and nxt is N1 itself
► from N2->N1 dist is 1 & nxt is N2
► Note: N2 is the neighbour of N1
N3 is the neighbour of N2 but N1 is not the neigbour of N3 n so on
► So N1 doesn’t know anything about N3 so N1->N3 cost is ∞ ( infinite) so nxt dest also
remain unknown
► Similarly N1->N4 cost is ∞ ( infinite) so nxt dest also remain unknown
► Similarly N1->N5 cost is ∞ ( infinite) so nxt dest also remain unknown
► So this is the local routing table of Router N1
Complete New Routing table for N1 Complete New Routing table for N5
New Routing table for N1
Note: Similarly all the new routing table will be updated parallely
Distance Vector Routing
Part (a) shows a subnet. The first four columns of part (b) show the delay vectors received
from the neighbors of router J. A claims to have a 12-msec delay to B, a 25-msec delay to
C, a 40-msec delay to D, etc. Suppose that J has measured or estimated its delay to its
neighbors, A, I, H, and K as 8, 10, 12, and 6 msec, respectively.
103
Distance Vector Routing
Ex1. How J computes its new route to
router G
1. It knows that it can get to A in 8 msec
furthermore A claims to be able to get
to G in 18 msec
So J knows it can count on a delay of
26msec to G if it forwards packet bound
for G to A.
106
The Count-to-Infinity Problem
► To see how fast good news propagates, consider the five-node (linear) subnet
of Fig. where the delay metric is the number of hops. Suppose A is down
initially and all the other routers know this. In other words, they have all
recorded the delay to A as infinity..
107
4.2.5 Link State Routing
► Distance vector routing was used in the ARPANET until 1979, when it was
replaced by link state routing.
► Variants of link state routing are now widely used.
► The idea behind link state routing is simple and can be stated as five parts.
► Each router must do the following:
1. Discover its neighbors and learn their network addresses.
2. Measure the delay or cost to each of its neighbors.
3. Construct a packet telling all it has just learned.
4. Send this packet to all other routers.
5. Compute the shortest path to every other router. ..
108
Learning about the Neighbors
► When a router is booted, its first task is to learn who its neighbors are. It
accomplishes this goal by sending a special HELLO packet on each
point-to-point line.
► The router on the other end is expected to send back a reply telling who it is.
► These names must be globally unique because when a distant router later
hears that three routers are all connected to F, it is essential that it can
determine whether all three mean the same F.
► When two or more routers are connected by a LAN, the situation is slightly
more complicated.
109
► Fig. 5-11(a) illustrates a LAN to which three routers, A, C, and F, are
directly connected. Each of these routers is connected to one or more
additional routers, as shown
110
► Fig. 5-11(a) illustrates a LAN to which three routers, A, C, and F, are
directly connected. Each of these routers is connected to one or more
additional routers, as shown
111
Building Link State Packets
► The information needed for the exchange has been collected, the next step is
for each router to build a packet containing all the data.
► The packet starts with the identity of the sender, followed by a sequence
number and age (to be described later), and a list of neighbors.
► For each neighbor, the delay to that neighbor is given.
► An example subnet is given in Fig. 5-13(a) with delays shown as labels on the
lines. The corresponding link state packets for all six routers are shown in Fig.
5-13(b).
112
Building Link State Packets
113
Distributing the Link State Packets
The difficult part of the algorithm is distributing the link state packets
reliably.
As the packets are distributed and installed, the routers getting the first
ones will change their routes.
The different routers may be using different versions of the topology,
which can lead to inconsistencies, loops, unreachable machines, and other
problems.
First we will describe the basic distribution algorithm. Later we will give
some refinements.
The fundamental idea is to use flooding to distribute the link state
packets.
114
Distributing the Link State Packets
To keep the flood in check, each packet contains a sequence number that is
incremented for each new packet sent.
Routers keep track of all the pairs they see.
When a new link state packet comes in, it is checked against the list of
packets already seen.
If it is new, it is forwarded on all lines except the one it arrived on. If it is a
duplicate, it is discarded.
If a packet with a sequence number lower than the highest one seen so far
ever arrives, it is rejected as being obsolete since the router has more recent
data.
115
Disadvantages
116
Distributing the Link State Packets
A speaker node advertises the path, not the metric of the nodes, in its AS or
other ASs.
Types of AS in BGP
• Stub AS
– Only one connection to another AS (only a source or sink for data traffic)
– E g small corporation or a small local ISP
• Multihomed AS
– More than one connection to other AS, but it is still only a source or sink
for data traffic
– E g Large corporation connected to more than one regional or national
AS
• Transit AS
– Multihomed AS that also allows transient traffic
– E g national or international ISP
Types of BGP messages