DCAN Lab Journal Final PDF
DCAN Lab Journal Final PDF
DCAN Lab Journal Final PDF
Electrical Department
Group Members:
Advait Talele (171060009)
Saurabh Gawade (171060033)
Yash Patil (171060051)
Mahesh vhatkar (171060087)
1
INDEX
2
Experiment No. 1
Data link layer is responsible for something called Framing, which is the division of stream
of bits from network layer into manageable units (called frames). Frames could be of fixed size or
variable size. In variable-size framing, we need a way to define the end of the frame and the
beginning of the next frame.
Bit stuffing is the insertion of non information bits into data. Note that stuffed bits should
not be confused with overhead bits. Overhead bits are non-data bits that are necessary for
transmission (usually as part of headers, checksums etc.).
3
Applications of Bit Stuffing –
1. synchronize several channels before multiplexing
2. rate-match two single channels to each other
3. run length limited coding
Procedure:
Bit stuffing is the insertion of one or more bits into a transmission unit as a way to
provide signaling information to a receiver. The receiver knows how to detect and remove or
disregard the stuffed bits. ... The receiving end removes the stuffed bits and restores
the bit stream to its original sequence.
Whenever a 0 bit is followed by five consecutive 1bits in the message, an extra
0 bit is stuffed at the end of the five 1s. When the receiver receives the message, it removes
the stuffed 0s after each sequence of five 1s. The un-stuffed message is then sent to the upper
layers.
In a data link frame, the delimiting flag sequence generally contains six or more
consecutive 1s. In order to differentiate the message from the flag in case of the same sequence,
a single bit is stuffed in the message.Whenever a 0 bit is followed by five consecutive 1bits in
the message, an extra 0 bit is stuffed at the end of the five 1s.
4
Bit Stuffing Code-
clc
clear
close()
b1s = input("Please enter Bit stream: ")
n = length(b1s)
bstuf = b1s
count = 0
j=1
for i=1:n
if b1s(i) == 1 then
count = count+1
else
count = 0
end
bstuf(j) = b1s(i)
if count == 5 then
j = j+1
bstuf(j) = 0
count = 0
end
j = j+1
end
disp(bstuf)
Output Result :
Conclusion:
In the above experiment we learned how we can Perform bits stuffing of the input
signals. Bit stuffing is the insertion of one or more bits into a transmission unit as a way to
provide signaling information to a receiver.
5
Experiment No. 2
Destuffing is the reverse of stuffing. In a data link frame, the delimiting flag sequence
generally contains six or more consecutive 1s. In order to differentiate the message from the flag
in case of the same sequence, a single bit is stuffed in the message. Whenever a 0 bit is followed
by five consecutive 1bits in the message, an extra 0 bit is stuffed at the end of the five 1s. When
the receiver receives the message, it removes the stuffed 0s after each sequence of five 1s. The
un-stuffed message is then sent to the upper layers.
Procedure:
In order to differentiate the message from the flag in case of the same sequence, a single
bit is stuffed in the message. Whenever a 0 bit is followed by five consecutive 1bits in the
message, an extra 0 bit is stuffed at the end of the five 1s .When the receiver receives the
message, it removes the stuffed 0s after each sequence of five 1s. The un-stuffed message is then
sent to the upper layers.
When the receiver receives the message, it removes the stuffed 0s after each sequence of
five 1s. The un-stuffed message is then sent to the upper layers.
6
Bit Destuffing code-
clc;
clear;
close;
m1=input('Please type a message bits: ');
c1=0;
c0=0;
stuffcount=0;
[x y]=size(m1)
disp(y)
for i=1:y
for j=i:i+5
if m1(i)==1
c1=c1+1;
else
c0=c0+1;
end
end
if(c1==6||c0==6)
disp([m1(i:i+4) m1(i+6:y)])
break
end
end
Output Result :
Conclusion: In the above experiment we learned how we can Perform bits destuffing of the
input signals. Destuffing is the reverse of stuffing. When the receiver receives the message, it
removes the stuffed 0s after each sequence of five 1s.
7
Experiment 03
Aim: To study and perform Cyclic Redundancy Check
Software used : Repl.com (Online C++ compiler )
Theory:
8
Procedure :-
Step-01: Calculation Of CRC At Sender Side-
At sender side,
● Here, n is one less than the number of bits in the CRC generator.
● Binary division is performed of the resultant string with the CRC generator.
● The string of n 0’s appended to the data unit earlier is replaced by the CRC remainder.
● The newly formed code word (Original data + CRC) is transmitted to the receiver.
9
Result :-
Code:
#include<iostream>
for(int i=0;i<n;i++)
if (gen[0]==temp[i])
for(int j=0,k=i;j<r+1;j++,k++)
if(!(temp[k]^gen[j]))
temp[k]=0;
else
temp[k]=1;
} }}
int main()
{int n,r,message[50],gen[50],temp[50];
cin>>n;
cin>>r;
10
for(int i=0;i<n;i++)
cin>>message[i];
for(int i=0;i<r;i++)
cin>>gen[i];
r--;
for(int i=0;i<r;i++)
message[n+i] = 0;
for(int i=0;i<n+r;i++)
temp[i] = message[i];
division(temp,gen,n,r);
cout<<"CRC : ";
for(int i=0;i<r;i++)
cout<<temp[n+i]<<" ";
message[n+i] = temp[n+i];
for(int i=0;i<n+r;i++)
coût<<message[i]<<" ";
for(int i=0;i<n+r;i++)
cin>>message[i];
11
for(int i=0;i<n+r;i++)
temp[i] = message[i];
division(temp,gen,n,r);
for(int i=0;i<r;i++)
if(temp[n+i])
return 0;
} }
for(int i=0;i<n;i++)
coût<<message[i]<<" ";
return 0;
Output:
12
Algorithm:
Conclusion:-
In the above experiment we learned how CRC (Cyclic Redundancy Check) works and also
coded the algorithm using cpp with proper output.
13
Experiment no. 04
Aim :- To study Bellman-Ford algorithm and implement the same.
Theory :-
Bellman-Ford Algorithm :-
Solves the single shortest path problem in which edge weight may be negative but no
negative cycle exists. This algorithm works correctly when some of the edges of the directed
graph G may have negative weight. When there are no cycles of negative weight, then we can
find out the shortest path between source and destination. It is slower than Dijkstra's Algorithm
but more versatile, as it is capable of handling some of the negative weight edges.
This algorithm detects the negative cycle in a graph and reports their existence.
Based on the "Principle of Relaxation" in which more accurate values gradually recovered an
approximation to the proper distance by until eventually reaching the optimum solution.
Given a weighted directed graph G = (V, E) with source s and weight function w: E → R, the
Bellman-Ford algorithm returns a Boolean value indicating whether or not there is a negative
weight cycle that is attainable from the source. If there is such a cycle, the algorithm produces
the shortest paths and their weights. The algorithm returns TRUE if and only if a graph contains
no negative - weight cycles that are reachable from the source.
14
Applications in routing
1. Each node calculates the distances between itself and all other nodes within the
AS and stores this information as a table.
2. Each node sends its table to all neighboring nodes.
3. When a node receives distance tables from its neighbors, it calculates the shortest
routes to all other nodes and updates its own table to reflect any changes.
The main disadvantages of the Bellman–Ford algorithm in this setting are as follows:
● It does not scale well.
● Changes in network topology are not reflected quickly since updates are spread node-
by-node.
● Count to infinity if link or node failures render a node unreachable from some set of
other nodes, those nodes may spend forever gradually increasing their estimates of
the distance to it, and in the meantime there may be routing loops.
Procedure :-
Output: Shortest distance to all vertices from src. If there is a negative weight cycle, then
shortest distances are not calculated, negative weight cycle is reported.
1) This step initializes distances from the source to all vertices as infinite and distance to the
source itself as 0. Create an array dist[] of size |V| with all values as infinite except dist[src]
where src is the source vertex.
15
2) This step calculates shortest distances. Do following |V|-1 times where |V| is the number of
vertices in a given graph.
………………If dist[v] > dist[u] + weight of edge uv, then update dist[v]
3) This step reports if there is a negative weight cycle in the graph. Do following for each edge
u-v
……If dist[v] > dist[u] + weight of edge uv, then “Graph contains negative weight cycle”
The idea of step 3 is, step 2 guarantees the shortest distances if the graph doesn’t contain a
negative weight cycle. If we iterate through all edges one more time and get a shorter path for
any vertex, then there is a negative weight cycle
Result :-
Code:-
#include<bits/stdc++.h>
int dis[V];
dis[i] = INT_MAX;
dis[src]=0;
for(int i=0;i<V-1;i++)
16
{
for(int j=0;j<E;j++)
if(dis[graph[j][0]]+graph[j][2]<dis[graph[j][1]])
dis[graph[j][1]]=dis[graph[j][0]]+graph[j][2];
for(int j=0;j<E;j++)
if((dis[graph[j][0]]!=INT_MAX) &&
(dis[graph[j][0]]+graph[j][2]<dis[graph[j][1]]))
int main()
17
{
int V;
int E;
cin>>V;
cin>>E;
int graph[E][3];
for(int i=0;i<E;i++)
cin>>graph[i][0]>>graph[i][1]>>graph[i][2];
int src;
cin>>src;
cout<<endl;
BellmanFord(graph,V,E,src);
18
Output:
Conclusion :-
19
Experiment no.5
Aim :- To connect two networks using a router.
Equipments :-
1. Routers
2. Switches
3. Connecting wires
4. PC or Laptop devices
Theory :-
Routers :-
A router is a networking device that forwards data packets between computer networks.
Routers perform the traffic directing functions on the Internet. Data sent through the internet,
such as a web page or email, is in the form of data packets. A packet is typically forwarded from
one router to another router through the networks that constitute an internetwork (e.g. the
Internet) until it reaches its destination node..
A router is connected to two or more data lines from different IP networks.[b] When a
data packet comes in on one of the lines, the router reads the network address information in the
packet header to determine the ultimate destination. Then, using information in its routing table
or routing policy, it directs the packet to the next network on its journey.
Switches:-
Switches are networking devices operating at layer 2 or a data link layer of the OSI
model. They connect devices in a network and use packet switching to send, receive or forward
data packets or data frames over the network.
A switch has many ports, to which computers are plugged in. When a data frame arrives
at any port of a network switch, it examines the destination address, performs necessary checks
and sends the frame to the corresponding device(s).It supports unicast, multicast as well as
broadcast communications.
20
Procedure :-
To test select Add simple PDU and click on one computer to another computer, if you get a
successful message then you have successfully configured a router and connected two different
networks.
21
Results :-
circuit :-
Output :-
Conclusion :-
In this experiment we learned about routers and switches and also successfully connected
two networks by routers using Cisco Packet Tracker.
22
Experiment 06
Theory :-
Dijkastra’s Algorithm
Dijkstra's algorithm (or Dijkstra's Shortest Path First algorithm, SPF algorithm) is an
algorithm for finding the shortest paths between nodes in a graph, which may represent, for
example, road networks. It was conceived by computer scientist Edsger W. Dijkstra in 1956 and
published three years later.
For a given source node in the graph, the algorithm finds the shortest path between that
node and every other, 196–206 It can also be used for finding the shortest paths from a single
node to a single destination node by stopping the algorithm once the shortest path to the
destination node has been determined. For example, if the nodes of the graph represent cities and
edge path costs represent driving distances between pairs of cities connected by a direct road (for
simplicity, ignore red lights, stop signs, toll roads and other obstructions), Dijkstra's algorithm
can be used to find the shortest route between one city and all other cities. A widely used
application of the shortest path algorithm is network routing protocols, most notably IS-IS
(Intermediate System to Intermediate System) and Open Shortest Path First (OSPF). It is also
employed as a subroutine in other algorithms such as Johnson's.
23
Procedure :-
Result :-
Code:
#include <bits/stdc++.h>
#define V 9
24
min = dist[v], min_index = v;
return min_index;
int dist[V];
bool pset[V];
25
dist[src] = 0;
pset[u] = true;
printOutput(dist);
26
int main()
int graph[V][V] = { { 0, 4, 0, 0, 0, 0, 0, 8, 0 },
{ 4, 0, 8, 0, 0, 0, 0, 11, 0 },
{ 0, 8, 0, 7, 0, 4, 0, 0, 2 },
{ 0, 0, 7, 0, 9, 14, 0, 0, 0 },
{ 0, 0, 0, 9, 0, 10, 0, 0, 0 },
{ 0, 0, 4, 14, 10, 0, 2, 0, 0 },
{ 0, 0, 0, 0, 0, 2, 0, 1, 6 },
{ 8, 11, 0, 0, 0, 0, 1, 0, 7 },
{ 0, 0, 2, 0, 0, 0, 6, 7, 0 } };
dijkstra(graph, 0);
return 0;
27
Output:
Conclusion :- In this experiment we have learned about the Dijkstra algorithm and successfully
implemented it using c++ language and got proper output.
28
Experiment No.07
Aim :- To connect VLANs using switches.
Equipments :-
1. Switch
2. Devices (PC or laptop)
3. Connecting wires
Theory :-
VLAN :-
A virtual LAN (VLAN) is any broadcast domain that is partitioned and isolated in a
computer network at the data link layer (OSI layer 2). LAN is the abbreviation for local area
network and in this context virtual refers to a physical object recreated and altered by additional
logic. VLANs work by applying tags to network frames and handling these tags in networking
systems – creating the appearance and functionality of network traffic that is physically on a
single network but acts as if it is split between separate networks. In this way, VLANs can keep
network applications separate despite being connected to the same physical network, and without
requiring multiple sets of cabling and networking devices to be deployed.
VLANs address issues such as scalability, security, and network management. Network
architects set up VLANs to provide network segmentation. Routers between VLANs filter
broadcast traffic, enhance network security, perform address summarization, and mitigate
network congestion.
Switches:-
Switches are networking devices operating at layer 2 or a data link layer of the OSI
model. They connect devices in a network and use packet switching to send, receive or forward
data packets or data frames over the network.
A switch has many ports, to which computers are plugged in. When a data frame arrives
at any port of a network switch, it examines the destination address, performs necessary checks
and sends the frame to the corresponding device(s).It supports unicast, multicast as well as
broadcast communications.
29
Procedure :-
1. Create the network topology as shown below:
2. Create 2 VLANs on the switch: VLAN 10 and VLAN 20. You can give them custom
names.
3. Assign switch ports to the VLANs. Remember each VLAN is viewed as a separate
broadcast domain.
4. Assign static IP addresses to the four PCs which are located in the separate VLANs.
PC1 and PC2 fall in VLAN 10 while PC3 and PC4 fall in VLAN 20.
5. Configure inter-VLAN routing on the router
6. Test inter-VLAN connectivity. Here we’ll test connectivity between computers in
different VLANs . Don’t forget that its the router that enables inter-VLAN routing.
Result :-
Circuit
30
Output :-
Conclusion :-
In this experiment we have connected two VLANs using a single switch. Using Cisco Packet
tracker software .
31