Documente Academic
Documente Profesional
Documente Cultură
EXPERIMENT 4
AIM: To write a MATLAB code for cyclic redundancy check (CRC) algorithm.
CODE:
clc;
clear all;
close all;
x=[1 1 1 0 1 1 0 1];
y=input('divisor=');
z=size(y);
a=padarray(x,z-1,'post')
b=bi2de(a);
c=bi2de(y);
d=mod(b,c);
e=de2bi(d);
f1=size(a);
f2=size(e);
s=f1-f2;
g=padarray(e,s,'pre');
h=a+g
h1=bi2de(h);
OUTPUT:
Enter the data.[1 0 1 0 1 0 1 0]
Enter the generator matrix.[1 0 1 1 1]
transmitted =
0 1 0 1 1 1 0 0
received =
0
0 0
CONCLUSION:
15
DATA COMMUNICATION AND NETWORKING (181001)
PRACTICAL: 5
PART: A
Aim: Implementation of PC to PC with LAN trainer kit.
Procedure :
1. Connect CAT5 cables between computer (RJ-45 is on back panel of
the computer) and RJ-45 connectors on trainer.
2.
Connect patch cords between Tx & Rx (Tx+ to Rx+; Tx- to Rx-) for both ends.
3.
Run ST5002 installed software on both nodes and follow the steps
16
DATA COMMUNICATION AND NETWORKING (181001)
7.
8.
9.
Now you can have a chat application between server and client.
Enter data here and press Enter or click on Send Data
CONCLUSION:
17
DATA COMMUNICATION AND NETWORKING (181001)
2.
3. Please check whether the SPX/IPX Protocol is installed on all the systems before
performing experiment. (Refer How to Install SPX/IPX protocol)
4. Open ST5002 Software.
5. Click on Bus Topology.
8. On the other nodes you have to connect to server by pressing Connect to Network.
18
DATA COMMUNICATION AND NETWORKING (181001)
CONCLUSION:
19
DATA COMMUNICATION AND NETWORKING (181001)
PRACTICAL: 6
Aim: To implement different Topologies using LAN Trainer Kit (ST 5002).
Apparatus: ST 5002 Trainer Kit, ST 5002 software, 11 patch cords(2mm), 2 parallel port
cables, mains power cord.
Diagram:
21
DATA COMMUNICATION AND NETWORKING (181001)
EXPERIMENT 7
AIM: To implement cipher key algorithm using MATLAB.
CODE:
a=input('message=','s');
k=input('shiftkey=');
b=double(a)
f1=b+k;
m=size(f1);
for i=1:m(2)
if f1(i)>122
f1(i)=96+(f1(i)-122);
end
end
c=char(f1)
OUTPUT:
message=abcd
shiftkey=3
b=
97
98
99 100
c = defg
CONCLUSION:
22
DATA COMMUNICATION AND NETWORKING (181001)
EXPERIMENT 8
AIM: To implement hamming code using MATLAB
CODE:
clc;
close all;
clear all;
tic
y=0;
p=1;
m=input('message signal');
% m=[1 1 1 1 1 1 1 1];
m1=size(m);
m1=max(m1);
for r=1:10
if ((m1+1+r)>(2^r))
p=p+1;
end
end
s=zeros(1,2^p);
z=1;
d=1;
for i=1:m1+p
if i==2^(d-1)
s(i)=0;
d=d+1;
else
s(i)=m(z);
z=z+1;
end
end
for i=1:p
u=i-1;
f=2^u; %add 1 skip one
for j=f:2*f:m1+p
for g=j:j+f-1 %add consecutive
y=y +s(g);
end
end
if mod(y,2)==0
s(f)=0;
else
s(f)=1;
23
DATA COMMUNICATION AND NETWORKING (181001)
OUTPUT:
message signal[1 0 1 0 1 0 1 0]
t=
CONCLUSION:
24
DATA COMMUNICATION AND NETWORKING (181001)
PRACTICAL: 9
AIM: Introduction to NS-2 Software. (Complex Lab problem)
THEORY:
Introduction:
NS (version 2) is an object-oriented, discrete event driven network simulator developed at
UC Berkely written in C++ and OTcl. NS is primarily useful for simulating local and wide
area networks. It implements network protocols such as TCP and UPD, traffic source
behavior such as FTP, Telnet, Web, CBR and VBR, router queue management mechanism
such as Drop Tail, RED and CBQ, routing algorithms such as Dijkstra, and more.
Simulation Example:
This section shows a simple NS simulation script and explains what each line does.
This network consists of 4 nodes (n0, n1, n2, n3) as shown in above figure. The duplex links
between n0 and n2, and n1 and n2 have 2 Mbps of bandwidth and 10 ms of delay. The duplex
link between n2 and n3 has 1.7 Mbps of bandwidth and 20 ms of delay. Each node uses a
DropTail queue, of which the maximum size is 10. A "tcp" agent is attached to n0, and a
connection is established to a tcp "sink" agent attached to n3. As default, the maximum size of
a packet that a "tcp" agent can generate is 1KByte. A tcp "sink" agent generates and sends ACK
packets to the sender (tcp agent) and frees the received packets. A "udp" agent that is attached
to n1 is connected to a "null" agent attached to n3. A "null" agent just frees the packets received.
A "ftp" and a "cbr" traffic generator are attached to "tcp" and "udp" agents respectively, and
the "cbr" is configured to generate 1 KByte packets at the rate of 1 Mbps. The "cbr" is set to
start at 0.1 sec and stop at 4.5 sec, and "ftp" is set to start at 1.0 sec and stop at 4.0 sec.
25
DATA COMMUNICATION AND NETWORKING (181001)
CONCLUSION:
26
DATA COMMUNICATION AND NETWORKING (181001)