CNS Unit 3
CNS Unit 3
• Circuit Switching
• Message Switching
• Packet Switching
Circuit Switching
• Circuit switching is a technique that directly connects the
sender and the receiver in an unbroken path.
• Telephone switching equipment, for example, establishes a
path that connects the caller's telephone to the receiver's
telephone by making a physical connection.
• With this type of switching technique, once a connection is
established, a dedicated path exists between both ends
until the connection is terminated.
• Routing decisions must be made when the circuit is first
established, but there are no decisions made after that
time.
• Three phases
• Establish
• Transfer
• Disconnect
Public Circuit Switched Network
Circuit Establishment
Circuit Switching
Advantages:
• The communication channel (once established) is dedicated.
Disadvantages:
• Possible long wait to establish a connection
• The message is then transmitted through the network, in its entirety, from node
to node.
• Each node receives the entire message, stores it in its entirety on disk, and then
transmits the message to the next node.
With virtual circuit, the node does not need to make a routing
decision for each packet.
It is made only once for all packets using that virtual circuit.
Virtual
Circuit
Diagram
Packet Switching: Virtual Circuit
Disadvantages:
• Protocols for packet switching are typically more
complex.
The IP addresses
are
unique.
The address space of IPv4 is
232
or
4,294,967,296.
In classful addressing,
the address space is
divided into five classes:
A, B, C, D, and E.
Finding the class in binary notation
Finding the class in decimal notation
Finding the address class
Netid and hostid
Class A Address
• The first bit of the first octet is always set to 0 (zero). Thus the first octet
ranges from 1 – 127, i.e.
• The first octet of Class C IP address has its first 3 bits set to 110,
that is:
Solution
Solution
The class is B because the first byte is between 128 and 191.
The block has a netid of 132.21. The addresses range from
132.21.0.0 to 132.21.255.255.
Given the network address 220.34.76.0, find
the class, the block, and the range of the
addresses.
Given the network address 220.34.76.0, find
the class, the block, and the range of the
addresses.
Solution
Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
Mask is 11111111 11111111 11111111 11110000
Solution
The prefix length is 27, which means that we
must keep the first 27 bits as is and change the
remaining bits (5) to 0s. The 5 bits affect only
the last byte. The last byte is 01010010.
Changing the last 5 bits to 0s, we get 01000000
or 64. The network address is 167.199.170.64/27.
A small organization is given a block with the beginning
address and the prefix length 205.16.37.24/29 (in slash
notation). What is the range of the block?
Solution
The beginning address is 205.16.37.24. To find the
last address we keep the first 29 bits and change the
last 3 bits to 1s.
Beginning:11001111 00010000 00100101 00011000
Ending : 11001111 00010000 00100101 00011111
There are only 8 addresses in this block.
Subnetting
Straight Method
In the straight method, we use binary
notation for both the address and the
mask and then apply the AND operation
to find the subnet address.
Example 1
Solution
The mask is
11111111 11111111 11111111 11000000
or
255.255.255.192
The number of subnets is 1024.
The number of addresses in each subnet is 26
(6 is the number of 0s) or 64.
See Figure 5.9
Example 14
An organization is granted the block 130.34.12.64/26.
The organization needs to have four subnets. What are the
subnet addresses and the range of addresses for each
subnet?
Solution
Design the subblocks and give the slash notation for each
subblock. Find out how many addresses are still available
after these allocations.
Solution
Group 1
For this group, each customer needs 256 addresses.
This means the suffix length is 8 (28 = 256). The
prefix length is then 32 - 8 = 24.
01: 190.100.0.0/24 190.100.0.255/24
02: 190.100.1.0/24 190.100.1.255/24
…………………………………..
64: 190.100.63.0/24190.100.63.255/24
Total = 64 256 = 16,384
Solution (Continued)
Group 2
For this group, each customer needs 128 addresses.
This means the suffix length is 7 (27 = 128). The
prefix length is then 32 - 7 = 25. The addresses
are:
001: 190.100.64.0/25 190.100.64.127/25
002: 190.100.64.128/25 190.100.64.255/25
003: 190.100.127.128/25 190.100.127.255/25
Total = 128 128 = 16,384
Solution (Continued)
Group 3
For this group, each customer needs 64 addresses.
This means the suffix length is 6 (26 = 64). The
prefix length is then 32 - 6 = 26.
001:190.100.128.0/26 190.100.128.63/26
002:190.100.128.64/26 190.100.128.127/26
…………………………
128:190.100.159.192/26 190.100.159.255/26
Total = 128 64 = 8,192
IPv4 ADDRESSES
19.79
Note
19.80
Note
19.81
Note
19.82
Addresses for private networks
19.83
IPv6 ADDRESSES
19.84
Note
19.85
IPv6 address in binary and hexadecimal colon notation
19.86
128-bit IPv6 Address
3FFE:085B:1F1F:0000:0000:0000:00A9:1234
3FFE:85B:1F1F::A9:1234
Solution
We first need to align the left side of the double colon to
the left of the original pattern and the right side of the
double colon to the right of the original pattern to find
how many 0s we need to replace the double colon.
19.88
19.89
IPv4 Header
• Version (4 bits)
• Indicates the version of IP and is set to 4.
• Internet Header Length (4 bits)
• Indicates the number of 4-byte blocks in the IPv4 header.
• Because an IPv4 header is a minimum of 20 bytes in size, the smallest value of the Internet
Header Length (IHL) field is 5.
• Type of Service (4 bits)
• Indicates the desired service expected by this packet for delivery through routers across the
IPv4 internetwork.
• Contains a 6-bit Differentiated Services Code Point (DSCP) field (RFC 2472) and two flags to
support Explicit Congestion Notification (RFC 3168).
91
IPv4 Header - Review
92
IPv4 Header - Review
93
IPv6 Header Fields
• Based on these rules, RFC 2460 defines the following IPv6 header fields:
1. Version (4 bits)
• 4 bits are used to indicate the version of IP and is set to 6
• Traffic Class (8 bits)
• same function as the Type of Service field in the IPv4 header.
1. Flow Label (20 bits)
• identifies a flow and it is intended to enable the router to identify packets that
should be treated in a similar way without the need for deep lookups within those
packets.
• set by the source and should not be changed by routers along the path to
destination.
• unique & powerful tool to IPv6
• Can be used with differentiated services (DiffServ) as well as integrated services
(IntServ) and Resource ReSerVation Protocol (RSVP2).
•It provides privacy as the device’s IP address, sending and receiving the traffic, will be hidden.
Disadvantage of NAT –
•Also, the router being a network layer device, should not tamper with port numbers(transport layer)
but it has to do so because of NAT.
Classless Inter-Domain Routing (CIDR)
OR Classless addressing.
• In the Classful addressing the no of Hosts within a network always remains
the same depending upon the class of the Network.
• Class A network contains 224 Hosts,
• Class B network contains 216 Hosts,
• Class C network contains 28 Hosts
• Now, let’s suppose an Organization requires 214 hosts, then it must have to
purchase a Class B network. In this case, 49152 Hosts will be wasted. This is
the major drawback of Classful Addressing.
• In order to reduce the wastage of IP addresses a new concept of Classless
Inter-Domain Routing is introduced.
• CIDR Link: https://youtu.be/ncsJ0uJu4n0
• CIDR Representation: It is also a 32-bit address, which includes a
special number which represents the number of bits that are present
in the Block Id.
a.b.c.d/n
Where, n is number of bits that are present in Network Id.
(blockid bits=32-n)
• Example: 20.10.50.100/20
• Here, 20 bits are present in Network Id.
Rules for forming CIDR Blocks
1.All IP addresses must be contiguous.
2.Block size must be the power of 2 (2n).
If the size of the block is the power of 2, then it will be easy to divide the
Network. Finding out the Block Id is very easy if the block size is of the
power of 2.
Example:
If the Block size is 25 then, Host Id will contain 5 bits and Network will
contain 32 – 5 = 27 bits.
3.First IP address of the Block must be evenly divisible by the size of the
block. in simple words, the least significant part should always start with
zeroes in Host Id. Since all the least significant bits of Host Id is zero, then
we can use it as Block Id part.
• Example:
Check whether 100.1.2.32 to 100.1.2.47 is a valid IP address block or not?
Solution:
• All the IP addresses are contiguous.
• Total number of IP addresses in the Block = 16 = 24.
• 1st IP address: 100.1.2.00100000
Since, Host Id will contains last 4 bits and all the least significant 4 bits are
zero. Hence, first IP address is evenly divisible by the size of the block.
• All the three rules are followed by this Block. Hence, it is a valid IP address
block.
Network layer protocols
• ARP
• RARP
• ICMP
• IGMP
ARP and RARP
• Note:
• The Internet is based on IP addresses
• Data link protocols (Ethernet, FDDI, ATM) may have different (MAC) addresses
• The ARP and RARP protocols perform the translation between IP addresses
and MAC layer addresses
• The delivery of a packet to a host or a router requires two levels of
addressing: logical and physical. We need to be able to map a logical
address to its corresponding
• physical address and vice versa. This can be done by using either static or
dynamic mapping.
• We will discuss ARP for broadcast LANs, particularly Ethernet LANs
109
Figure ARP operation
110
ARP Packet Format
Ethernet II header
6 6 2 28 10 4
* Note: The length of the address fields is determined by the corresponding address length fields
111
• Hardware type (HTYPE)This field specifies the Link Layer protocol type.
Example: Ethernet is 1.
• Protocol type (PTYPE)This field specifies the upper layer protocol for which the
ARP request is intended. For IPv4, this has the value 0x0800.
• Hardware length (HLEN)Length (in octets) of a hardware address. Ethernet
addresses size is 6.
• Protocol length (PLEN)Length (in octets) of addresses used in the upper layer
protocol. (The upper layer protocol specified in PTYPE.) IPv4 address size is 4.
•
112
Figure Encapsulation of ARP packet
113
Example 1
Solution
Figure 5 shows the ARP request and reply packets. Note
that the ARP data field in this case is 28 bytes, and that
the individual addresses do not fit in the 4-byte boundary.
That is why we do not show the regular 4-byte boundaries
for these addresses.
114
Figure Example 1, an ARP request and reply
115
Note
116
Reverse Address Resolution Protocol (RARP)
• Some network hosts, such as a diskless workstation, do not know their
own IP address when they are booted. To determine their own IP address,
they use a mechanism similar to ARP, but now the hardware address of
the host is the known parameter, and the IP address is the queried
parameter.
• The reverse address resolution is performed the same way as the ARP
address resolution. The same packet format is used for the ARP.
• An exception is the operation code field that now takes the following
values−
• 3 for RARP request
• 4 for RARP reply
• The physical header of the frame will now indicate RARP as the higher-
level protocol (8035 hex) instead of ARP (0806 hex) or IP-(0800 hex) in the
Ether type field.
The format of a RARP packet is almost identical to an ARP
packet. The only difference is that the frame type is 0X8035
for a RARP request or reply, and the op-field has a value of 3
for a RARP request and 4 for a RARP reply.
ICMP
121
Figure General format of ICMP messages
1 -The first byte specifies the type of ICMP message. For example, type 8 is used for an ICMP request
and type 0 is used for an ICMP reply. We use type 3 for destination unreachable messages.
2 -The second byte called code specifies what kind of ICMP message it is. For example, the destination
unreachable message has 16 different codes. When you see code 0 it means that the destination network
was unreachable while code 1 means that the destination host was unreachable.
3 -The third field are 2 bytes that are used for the checksum to see if the ICMP header is corrupt or not.
What the remaining part of the header looks like depends on the ICMP message type that we are using.
122
Figure ICMP Error-reporting messages
123
Note
124
Figure Contents of data field for the error messages
125
Figure 12 ICMP Query messages
127
Figure 13 Encapsulation of ICMP query messages
128
3 IGMP
130
Figure IGMP message format
132
Figure IGMP operation
133
Note
134
Note
135
Routing algorithms
Classification
Non adaptive (static)
Routing decisions computed in advance, off-line and downloaded
Adaptive (dynamic)
To changes in
Topology
Load
Get information
Locally
From adjacent routers
From all routers
136
A Link-State Routing Algorithm
1 Initialization:
2 N' = {u}
3 for all nodes v
4 if v adjacent to u
5 then D(v) = c(u,v)
6 else D(v) = ∞
7
8 Loop
9 find w not in N' such that D(w) is a minimum
10 add w to N'
11 update D(v) for all v adjacent to w and not in N' :
12 D(v) = min( D(v), D(w) + c(w,v) )
13 /* new cost to v is either old cost to v or known
14 shortest path cost to w plus cost from w to v */
15 until all nodes in N'
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
Then
dx(y) = min {c(x,v) + dv(y) }
where min is taken over all neighbors of x
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b
1d AS1
Forwarding table is
configured by both intra- and
inter-AS routing algorithm
Intra-AS Inter-AS
Routing Routing Intra-AS sets entries for internal
algorithm algorithm
dests
Forwarding Inter-AS & Intra-As sets entries
table
for external dests
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b
1d AS1
Network Layer 4-156
Example: Setting forwarding table in
router 1d
Inter-AS Routing
BGP: Border Gateway Protocol
u destination hopsfromA
v
u 1
A B w v 2
w 2
x 3
x y 3
z C D z 2
y
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b
AS1 1d
eBGP session
iBGP session
Network Layer 4-171
Distributing reachability info
With eBGP session between 3a and 1c, AS3 sends prefix
reachability info to AS1.
1c can then use iBGP do distribute this new prefix reach info to
all routers in AS1
1b can then re-advertise the new reach info to AS2 over the 1b-
to-2a eBGP session
When router learns about a new prefix, it creates an entry for
the prefix in its forwarding table.
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b
AS1 1d
eBGP session
iBGP session
Network Layer 4-172
Path attributes & BGP routes
When advertising a prefix, advert includes BGP attributes.
prefix + attributes = “route”
Two important attributes:
AS-PATH: contains the ASs through which the advert for the prefix passed: AS 67 AS 17
NEXT-HOP: Indicates the specific internal-AS router to next-hop AS. (There may be
multiple links from current AS to next-hop-AS.)
When gateway router receives route advert, uses import policy to
accept/decline.
Applications
TCP UDP
IP
MPLS MPS
PPP FR ATM Ethernet DWDM
Physical
• What is it?
• Goal: sending a packet from A to B
• We can do it in a broadcast way.
• We can use source routing where the source determines
the path.
• How do we do it on the Internet today?
• Hop-by-hop routing: continue asking who is closer to B at every
stop (hop).
MPLS
IP Label Label IP
Routing Switching Switching Routing
MPLS Operation
R1 --- E0 172.16.1.0
S1 6
R2 6 S0 172.16.1.0
S2 11
R3 11 S0 172.16.1.0
S3 7
R4 7 S1 172.26.1.0
E0 --
Q: create LFIB for R4 => R3 => R2 => R1
Routing in Mobile Ad Hoc Networks
(MANETs)
Mobile Ad Hoc Networks (MANET)
B
A A
B
Ad hoc networks:
– Do not need backbone infrastructure support
– Are easy to deploy
– Useful when infrastructure is absent, destroyed or impractical
Many Applications
Reactive protocols
– Determine route if and when needed
– Source initiates route discovery
– Example: DSR, AODV
Hybrid protocols
– Adaptive; Combination of proactive and reactive
– Example : ZRP (zone routing protocol)
Reactive Routing Protocols
Dynamic Source Routing (DSR)
Reactive
When node S wants to send a packet to node D, but does not know a route to D,
node S initiates a route discovery
Z
S E
F
B
C M L
J
A G
H D
K
I N
[S] Z
S E
F
B
C M L
J
A G
H D
K
I N
Z
S [S,E]
E
F
B
C M L
J
A [S,C] G
H D
K
I N
Z
S E
F [S,E,F]
B
C M L
J
A G
H D
[S,C,G] K
I N
Z
S E
F [S,E,F,J]
B
C M L
J
A G
H D
K
I [S,C,G,K] N
Z
S E
[S,E,F,J,M]
F
B
C M L
J
A G
H D
K
I N
RREP includes the route from S to D on which RREQ was received by node D
Route Reply in DSR
Y
Z
S RREP [S,E,F,J,D]
E
F
B
C M L
J
A G
H D
K
I N
When node S sends a data packet to D, the entire route is included in the packet
header
– hence the name source routing
DATA [S,E,F,J,D] Z
S E
F
B
C M L
J
A G
H D
K
I N
A single route discovery may yield many routes to the destination, due to
intermediate nodes replying from local caches
Dynamic Source Routing: Disadvantages
Packet header size grows with route length due to source
routing
AODV retains the desirable feature of DSR that routes are maintained only
between nodes which need to communicate
AODV
Route Reply travels along the reverse path set-up when Route Request is
forwarded
Route Requests in AODV
Y
Z
S E
F
B
C M L
J
A G
H D
K
I N
Z
S E
F
B
C M L
J
A G
H D
K
I N
Z
S E
F
B
C M L
J
A G
H D
K
I N
Z
S E
F
B
C M L
J
A G
H D
K
I N
Z
S E
F
B
C M L
J
A G
H D
K
I N
Reverse Path Setup in AODV
Y
Z
S E
F
B
C M L
J
A G
H D
K
I N
Z
S E
F
B
C M L
J
A G
H D
K
I N
Route Request (RREQ) includes the last known sequence number for the destination
An intermediate node may also send a Route Reply (RREP) provided that it knows a more
recent path than the one previously known to sender
Intermediate nodes that forward the RREP, also record the next hop to destination
A routing table entry maintaining a reverse path is purged after a timeout interval
A routing table entry maintaining a forward path is purged if not used for a active_route_timeout
interval
AODV: Summary
Nodes maintain routing tables containing entries only for routes that are in
active use
At most one next-hop per destination maintained at each node
– DSR may maintain several routes for a single destination