Академический Документы
Профессиональный Документы
Культура Документы
DEPARTMENT OF
ELECTRONICS AND COMMUNICATION ENGINEERIGN
PREPARED BY
V.RAJESH - Assistant Professor / ECE
N.DARWIN – Assistant professor II / ECE
PRATHYUSHA
INSTITUTE OF TECHNOLOGY AND MANAGEMENT
ARANVAYALKUPPAM
TIRUVALLUR – 602 025
EC6611 - COMPUTER NEWORKS LABORATORY
VISION
MISSION
VISION
To promote academic growth by offering state of the art undergraduate and graduate
programmes, and to evolve as a Centre of Excellence in Electronics and Communication
Engineering equipped with highly skilled, trained and confident engineers imbued with
knowledge of core as well as interdisciplinary domains
MISSION
SYLLABUS
EC6611 – COMPUTER NETWORKS LABORATORY LTPC0032
OBJECTIVES:
The student should be made to:
Learn to communicate between two desktop computers.
Learn to implement the different protocols
Be familiar with socket programming.
Be familiar with the various routing algorithms
Be familiar with simulation tools.
LIST OF EXPERIMENTS:
1. Implementation of Error Detection / Error Correction Techniques
2. Implementation of Stop and Wait Protocol and sliding window
3. Implementation and study of Goback-N and selective repeat protocols
4. Implementation of High Level Data Link Control
5. Study of Socket Programming and Client – Server model
6. Write a socket Program for Echo/Ping/Talk commands.
7. To create scenario and study the performance of network with CSMA / CA
protocol and compare with CSMA/CD protocols.
8. Network Topology - Star, Bus, Ring
9. Implementation of distance vector routing algorithm
10. Implementation of Link state routing algorithm
11. Study of Network simulator (NS) and simulation of Congestion Control Algorithms using
NS
12. Encryption and decryption.
TOTAL: 45 PERIODS
OUTCOMES:
At the end of the course, the student should be able to
Communicate between two desktop computers.
Implement the different protocols
Program using sockets.
Implement and compare the various routing algorithms
Use simulation tool.
HARDWARE
Standalone desktops - 30 Nos
OBJECTIVE:
To study Stop & Wait protocol
EQUIPMENTS:
• DCT-03 & LTS-01 trainer kit.
• 25 Pin D connector Cables – 2 Nos.
• 2 Computers with win-2K / XP and LAN card installed on them.
• Connecting Chords.
• RJ-45 to RJ-45 LAN connecting cables.
• Power Supply.
PROCEDURE:
USING DCT-03:
1. Carry out the following connections and settings as shown in the diagram.
2. Keep all switch fault switches in off position.
3. Keep switch SW6 in PC mode.
4. Connect LPT/parallel port of one PC to connector CN1 on left hand side on DCT-03 kit using
25-25 pin D type cable. Similarly connect LPT/parallel port of another PC to connector CN2 on
right hand side on DCT-03 kit using 25-25 pin D type cable.
5. Keep the switch settings for SW1, SW2 & SW3 in ON position as shown.
6. Switch ON the power supply.
7. Run DCT software and select Parallel Communication Software link on both PC’s.
8. Click on Port Setting will show you three ports (i.e. LPT1, LPT2, LPT3), select the port from
the user machine through which the data transfer has to occur. For example Clicking on LPT1
will set the LPT1 as the active port on the machine for the data transfer.
10
11
10. Clicking on Protocols will show you three protocols namely Stop and Wait Protocol, Go
Back N Protocol and Selective Repeat protocol. Select Stop and Wait protocol on both PC.
11. Select one PC in transmit mode and another PC in receive mode.
12. Select the file to be sent from the transmitter computer, the screen shown below will appear
at transmitter side, with details of file selected number of packets formed using 128 byte per
packet size.
13. Inter packet delay can be varied from 5 ms to 100 ms.
14. Packets to be sent are shown with blue colour.
15. Click on Transmit file button.
16. On the remote PC click on receive file button.
17. Status of file transfer will be indicated on screen with different colour coding depending on
the status of packet whether it is sent & acknowledged, sent but not acknowledged, bad packet
error in packet.
18. After the user has selected the file. The PC shows the No of Packets and Size of the file in
the boxes on the top. The Packets with their packet sequence is also shown.
19. Once the transfer starts and the client computer acknowledges the packets it sends the signal
back to the transmitting PC. Any acknowledge positive or negative with their packet sequence is
displayed below the Current Packet No.
20. Any positive acknowledge received is displayed as ACK(0) and any negative acknowledge is
displayed as NACK(0) along with their packet sequence in brackets.
21. Once the packet has been acknowledged and signal shown the next packet is transmitted and
so on till the whole file gets transmitted.
22. On the right hand top shows frame info. The frame info consists of different color packets.
Each color specifies different status of the packet.
23. Observe the effect on file transfer by introducing error in data bits use switch SW2 to
introduce error for a moment.
24. Once the file transfer gets complete you will be prompted by file transfer successful at
transmitter.
12
13
26. Verify the received file with transmitted file, this shows end of file transfer with success.
27. The receiving packets can be discarded or killed by clicking the Discard button.
28. Any acknowledge that is transmitted back can be also made to lost by just clicking Lost
button. Thus the Transmitter side will not receive any acknowledge.
29. The third button NACK/LOST can be clicked to discard and to lose any acknowledge
sending back to the Transmitter simultaneously.
USING LTS-01:
1. Connect 2 computer LAN ports using RJ-45 to RJ-45 LAN connecting cables provided with
the system to LTS-01 star topology ports.
2. Switch on the LTS-01 & Computers.
3. Run L-SIM software on all the computers, one should be server and others should be clients.
4. On the server computer select type of network as LAN.
5. On the server computer select the topology as STAR, select protocol as Stop & Wait click on
create network button.
6. Remote computer details will appear on the computers connected in network, server will be
able to see all clients and all clients will be able to see only server.
7. Select the computer to whom data file is to be transferred, from the load button, previously
stored/selected file information can be loaded or you can select any file, which is to be
transmitted.
8. File size will appear in the software window, select the packet size, inter packet delay and
click OK.
9. Total packets formed for that file will be indicated on computers, same details of file will
appear on remote computer to which file is to be transmitted.
10. Click on file transfer button to transfer file.
14
15
11. During file transfer process you can insert errors into data packets being transmitted through
software window.
12. See the effect of Bad packet error, Packet negative acknowledgment error or auto errors on
file transfer.
13. File transfer from one computer to another will take place.
14. Multiple file transfer between various server-client combinations should be performed to
observe throughput v/s packet size graph on transmitter computer.
VIVA QUESTIONS:
1. How does a single bit error differ from a burst error?
2. Define Protocol.
3. Give the features of Stop & Wait Protocol.
4. What is the use of Physical addressing and Logical addressing in OSI?
5. What is Error Detection?
OBSERVATION:
Thus the stop and wait protocol is implemented using DCT Trainer / LAN Trainer and studied
their performance by introducing error while transferring packets.
16
17
OBJECTIVE:
To write a program Sliding window protocol using C and Java.
ALGORITHM:
SERVER:
CLIENT:
//SENDER PROGRAM
import java.net.*;
import java.io.*;
import java.rmi.*;
public class slidsender
{
public static void main(String a[])throws Exception
18
{
ServerSocket ser=new ServerSocket(10);
Socket s=ser.accept();
DataInputStream in=new DataInputStream(System.in);
19
//RECEIVER PROGRAM
import java.net.*;
import java.io.*;
class slidreceiver
{
public static void main(String a[])throws Exception
{
Socket s=new Socket(InetAddress.getLocalHost(),10);
DataInputStream in=new DataInputStream(s.getInputStream());
PrintStream p=new PrintStream(s.getOutputStream());
int i=0,rptr=-1,nf,rws=8;
String rbuf[]=new String[8];
String ch; System.out.println();
do
{
nf=Integer.parseInt(in.readLine());
if(nf<=rws-1)
{
for(i=1;i<=nf;i++)
{
rptr=++rptr%8;
rbuf[rptr]=in.readLine();
System.out.println("The received Frame " +rptr+" is : "+rbuf[rptr]);
}
rws-=nf;
System.out.println("\nAcknowledgment sent\n");
p.println(rptr+1); rws+=nf; }
else
break;
ch=in.readLine();
}
while(ch.equals("yes"));
}
}
20
OUTPUT:
//SENDER OUTPUT
Enter the no. of frames: 4
Enter 4 Messages to be send
hi
how r u
i am fine
how is everyone
Acknowledgment received for 4 frames
//RECEIVER OUTPUT
The received Frame 0 is : hi
The received Frame 1 is : how r u
The received Frame 2 is : i am fine
The received Frame 3 is : how is everyone
RECEIVER
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<netdb.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>
#include<errno.h>
int main()
{
intsock,bytes_received,i=1;
char receive[30];
structhostent *host;
22
23
OUTPUT
SENDER
$ cc sender.c
$ ./a.out
Enter Data Frame 1:(Enter exit for End): Manoj
Enter Data Frame 2:(Enter exit for End): mca
Enter Data Frame 3:(Enter exit for End): exit
$
RECEIVER
$ cc receiver.c
$ ./a.out
Socket created
Frame 1 data Manoj received
Frame 2 data mca received
$
24
25
OBJECTIVE:
To study Go Back N protocol
EQUIPMENTS:
• DCT-03 & LTS-01 trainer kit.
• 25 Pin D connector Cables – 2 Nos.
• 2 Computers with win-2K / XP and LAN card installed on them.
• Connecting Chords.
• RJ-45 to RJ-45 LAN connecting cables.
• Power Supply.
PROCEDURE:
USING DCT-03:
1. Carry out the following connections and settings as shown in the diagram.
2. Keep all switch fault switches in off position.
3. Keep switch SW6 in PC mode.
4. Connect LPT/parallel port of one PC to connector CN1 on left hand side on DCT-03 kit using
25-25 pin D type cable. Similarly connect LPT/parallel port of another PC to connector CN2 on
right hand side on DCT-03 kit using 25-25 pin D type cable.
5. Keep the switch settings for SW1, SW2 & SW3 in ON position as shown.
6. Switch ON the power supply.
7. Run DCT software and select Parallel Communication Software link on both PC’s.
8. Clicking on Port Setting will show you three ports (i.e. LPT1, LPT2, LPT3), select the port
from the user machine through which the data transfer has to occur. For example Clicking on
LPT1 will set the LPT1 as the active port on the machine for the data transfer.
9. Please ensure that the selected ports are in bi-directional mode, this can be checked from the
BIOS settings of the computer.
26
27
10. Clicking on Protocols will show you three protocols namely Stop and Wait Protocol, Go
Back N Protocol and Selective Repeat protocol. Select Go Back N protocol on both PC.
11. Select one PC in transmit mode and another PC in receive mode.
12. Select the file to be sent from the transmitter computer, the screen shown below will appear
at transmitter side, with details of file selected number of packets formed using 128 byte per
packet size.
13. Inter packet delay can be varied from 5 ms to 100 ms.
14. Window size can be selected from 3, 5, 7.
15. Packets to be sent are shown with blue colour.
16. Click on Transmit file button.
17. On the remote PC click on receive file button.
18. Status of file transfer will be indicated on screen with different colour coding depending on
the status of packet whether it is sent & acknowledged, sent but not acknowledged, bad packet
error in packet.
19. After the user has selected the file. The PC shows the No of Packets and Size of the file in
the boxes on the top. The Packets with their packet sequence is also shown.
20. Once the transfer starts and the client computer acknowledges the packets it sends the signal
back to the transmitting PC. Any acknowledge positive or negative with their packet sequence is
displayed below the Current Packet No.
21. Any positive acknowledge received is displayed as ACK(0) and any negative acknowledge is
displayed as NACK(0) along with their packet sequence in brackets.
22. Once the packet has been acknowledged and signal shown the next packet is transmitted and
so on till the whole file gets transmitted.
23. On the right hand top shows frame info. The frame info consists of different color packets.
Each color specifies different status of the packet.
24. Observe the effect on file transfer by introducing error in data bits use switch SW2 to
introduce error for a moment.
25. Once the file transfer gets complete you will be prompted by file transfer successful at
transmitter.
28
29
26. At the receiver a selection window will popup to indicate location for the received file to be
saved.
27. Verify the received file with transmitted file, this shows end of file transfer with success.
28. The receiving packets can be discarded or killed by clicking the Discard button.
29. Any acknowledge that is transmitted back can be also made to lost by just clicking Lost
button. Thus the Transmitter side will not receive any acknowledge.
30. The third button NACK/LOST can be clicked to discard and to lose any acknowledge
sending back to the Transmitter simultaneously.
USING LTS-01:
1. Connect 3 or more computer LAN ports using RJ-45 to RJ-45 LAN connecting cables
provided with the system to LTS-01 star topology ports.
2. Switch on the LTS-01 & Computers.
3. Run L-SIM software on all the computers, one should be server and others should be clients.
4. On the server computer select type of network as LAN.
5. On the server computer select the topology as STAR, select protocol as Go Back N click on
create network button.
6. Remote computer details will appear on the computers connected in network, server will be
able to see all clients and all clients will be able to see only server.
7. Select the computer to whom data file is to be transferred, from the load button, previously
stored/selected file information can be loaded or you can select any file, which is to be
transmitted.
8. File size will appear in the software window, select the packet size, inter packet delay, window
size and click OK.
9. Total packets formed for that file will be indicated on computers, same details of file will
appear on remote computer to which file is to be transmitted.
10. Click on file transfer button to transfer file.
11. During file transfer process you can insert errors into data packets being transmitted through
software window.
30
31
12. See the effect of Bad packet error, Packet negative acknowledgment error or auto errors on
file transfer; observe carefully which packet/packets are transmitted.
13. File transfer from one computer to another will take place.
14. Multiple file transfer between various server-client combinations should be performed to
observe throughput v/s packet size graph on transmitter computer.
VIVA QUESTIONS:
1. Define Topology.
2. What are the protocols used in noisy channels?.
3. List the types of Topologies.
4. Compare Mesh & Bus Topology.
5. Give the features of Go Back – N Protocol
OBSERVATION:
Thus the Go Back - N protocol is implemented using DCT Trainer / LAN Trainer and studied
their performance by introducing error while transferring packets.
32
33
OBJECTIVE:
To study Selective Repeat protocol
EQUIPMENTS:
• DCT-03 & LTS-01 trainer kit.
• 25 Pin D connector Cables – 2 Nos.
• 2 Computers with win-2K / XP and LAN card installed on them.
• Connecting Chords.
• RJ-45 to RJ-45 LAN connecting cables.
• Power Supply.
PROCEDURE:
USING DCT-03:
1. Carry out the following connections and settings as shown in the diagram.
2. Keep all switch fault switches in off position.
3. Keep switch SW6 in PC mode.
4. Connect LPT/parallel port of one PC to connector CN1 on left hand side on DCT-03 kit using
25-25 pin D type cable. Similarly connect LPT/parallel port of another PC to connector CN2 on
right hand side on DCT-03 kit using 25-25 pin D type cable.
5. Keep the switch settings for SW1, SW2 & SW3 in ON position as shown.
6. Switch ON the power supply.
7. Run DCT software and select Parallel Communication Software link on both PC’s.
8. Clicking on Port Setting will show you three ports (i.e. LPT1, LPT2, LPT3), select the port
from the user machine through which the data transfer has to occur. For example Clicking on
LPT1 will set the LPT1 as the active port on the machine for the data transfer.
9. Please ensure that the selected ports are in bi-directional mode, this can be checked from the
BIOS settings of the computer.
34
35
10. Clicking on Protocols will show you three protocols namely Stop and Wait Protocol, Go
Back N Protocol and Selective Repeat protocol. Select Selective Repeat protocol on both PC.
11. Select one PC in transmit mode and another PC in receive mode.
12. Select the file to be sent from the transmitter computer, the screen shown below will appear
at transmitter side, with details of file selected number of packets formed using 128 byte per
packet size.
13. Inter packet delay can be varied from 5 ms to 100 ms.
14. Window size can be selected from 3, 5, 7.
15. Packets to be sent are shown with blue colour.
16. Click on Transmit file button.
17. On the remote PC click on receive file button.
18. Status of file transfer will be indicated on screen with different colour coding depending on
the status of packet whether it is sent & acknowledged, sent but not acknowledged, bad packet
error in packet.
19. After the user has selected the file. The PC shows the No of Packets and Size of the file in
the boxes on the top. The Packets with their packet sequence is also shown.
20. Once the transfer starts and the client computer acknowledges the packets it sends the signal
back to the transmitting PC. Any acknowledge positive or negative with their packet sequence is
displayed below the Current Packet No.
21. Any positive acknowledge received is displayed as ACK(0) and any negative acknowledge is
displayed as NACK(0) along with their packet sequence in brackets.
22. Once the packet has been acknowledged and signal shown the next packet is transmitted and
so on till the whole file gets transmitted.
23. On the right hand top shows frame info. The frame info consists of different color packets.
Each color specifies different status of the packet.
24. Observe the effect on file transfer by introducing error in data bits use switch SW2 to
introduce error for a moment.
25. Once the file transfer gets complete you will be prompted by file transfer successful at
transmitter.
36
37
USING LTS-01:
1. Connect 3 or more computer LAN ports using RJ-45 to RJ-45 LAN connecting cables
provided with the system to LTS-01 star topology ports.
2. Switch on the LTS-01 & Computers.
3. Run L-SIM software on all the computers, one should be server and others should be clients.
4. On the server computer select type of network as LAN.
5. On the server computer select the topology as STAR, select protocol as Selective Repeat click
on create network button.
6. Remote computer details will appear on the computers connected in network, server will be
able to see all clients and all clients will be able to see only server.
7. Select the computer to whom data file is to be transferred, from the load button, previously
stored/selected file information can be loaded or you can select any file, which is to be
transmitted.
8. File size will appear in the software window, select the packet size, inter packet delay, window
size and click OK.
9. Total packets formed for that file will be indicated on computers, same details of file will
appear on remote computer to which file is to be transmitted.
10. Click on file transfer button to transfer file.
11. During file transfer process you can insert errors into data packets being transmitted through
software window.
12. See the effect of Bad packet error, Packet negative acknowledgment error or auto errors on
file transfer; observe carefully which packet/packets are transmitted.
38
39
13. File transfer from one computer to another will take place.
14. Multiple file transfer between various server-client combinations should be performed to
observe throughput v/s packet size graph on transmitter computer.
VIVA QUESTIONS:
OBSERVATION:
Thus the Selective Repeat protocol is implemented using DCT Trainer / LAN Trainer and
studied their performance by introducing error while transferring packets.
40
41
OBJECTIVE:
Implementation and study of CSMA-CD protocol.
EQUIPMENTS:
• LTS-01 trainer kit
• 3 Computers with win-2K / XP and LAN card installed on them
• RJ-45 to RJ-45 LAN connecting cables
PROCEDURE:
1. Connect 3 or more computer LAN ports using RJ-45 to RJ-45 LAN connecting cables
provided with the system to LTS-01 star topology ports.
2. Switch on the LTS-01 & Computers.
3. Run L-SIM software on all the computers, one should be server and others should be clients.
4. On the server computer select type of network as LAN.
5. On the server computer select the topology as STAR, select protocol as CSMA-CD click on
create network button.
6. Remote computer details will appear on the computers connected in network, server will be
able to see all clients and all clients will be able to see only server.
7. Select the server computer to whom data file is to be transferred from one of the client
computer; from the load button, previously stored/selected file information can be loaded or you
can select any file, which is to be transmitted.
8. File size will appear in the software window, select the packet size, inter packet delay and
click OK.
9. Total packets formed for that file will be indicated on computers, same details of file will
appear on remote computer to which file is to be transmitted.
10. Click on file transfer button to transfer file.
11. During file transfer process try to send file to server from another client computer, file
transfer from second transmitter will also gets initiated.
42
43
12. When packet from second sender collides with first sender it will be indicated as collision
packet. File from first sender will resume after some time and second sender file will be kept on
hold till first file transfer gets completed.
13. Once the first sender file reached to server it is prompted by transmission complete message.
14. Second sender file transfer will also get completed and thus collision of two packets
transmitted simultaneously from two senders is detected and cleared.
VIVA QUESTIONS:
1. Define CSMA/CD.
2. What is the advantage of Star Topology over Ring Topology?
3. What is the use of Hamming Codes?
4. What is Line Coding?
5. What are the features of FDDI?
OBSERVATION:
Thus the CSMA/CD protocol is implemented and studied their performance using L-
SIM.
44
45
OBJECTIVE:
Implementation and study of CSMA-CA protocol using LAN.
EQUIPMENTS:
• LTS-01 trainer kit
• 3 Computers with win-2K / XP and LAN card installed on them
• RJ-45 to RJ-45 LAN connecting cables
• Access point with accessories
• Wireless LAN Access cards with USB driver installed on respective computers
PROCEDURE:
1. Connect 3 or more computer LAN ports using RJ-45 to RJ-45 LAN connecting cables
provided with the system to LTS-01 star topology ports.
2. Switch on the LTS-01 & Computers.
3. Run L-SIM software on all the computers, one should be server and others should be clients.
4. On the server computer select type of network as LAN.
5. On the server computer select the topology as STAR, select protocol as CSMA-CA click on
create network button.
6. Remote computer details will appear on the computers connected in network, server will be
able to see all clients and all clients will be able to see only server.
7. Click on the Send RTS button to get your computer into transmitter mode.
8. Select the computer to whom data file is to be transferred, from the load button, previously
stored/selected file information can be loaded or you can select any file, which is to be
transmitted.
9. File size will appear in the software window, select the packet size, inter packet delay and
click OK.
10. Total packets formed for that file will be indicated on computers, same details of file will
appear on remote computer to which file is to be transmitted.
46
47
VIVA QUESTIONS:
OBSERVATION:
Thus the CSMA/CA protocol is implemented and studied their performance using L-
SIM.
48
49
THEORY: -
LAN: When two or more computers are connected directly within the small well defined area
such as room, building etc. The physical topology of a network refers to the configuration of
cables, computers, and other peripherals.
Star Topology
Many home networks use the star topology. A star network features a central connection point
called a "hub" that may be a hub, switch or router. Devices typically connect to the hub with
Unshielded Twisted Pair (UTP) Ethernet.
Compared to the bus topology, a star network generally requires more cable, but a failure in any
star network cable will only take down one computer's network access and not the entire LAN.
(If the hub fails, however, the entire network also fails
50
51
PROCEDURE:-
1. Create folder of source name in both PC in C or D drive
2. Write text document in one PC (sender)
3. Open Star topology on both PC
4. Write destination IP address on both PC
5. Share folder
6. Open the folder
7. Save the parameters
8. Open the text document
9. Sent data
10. Received data on another PC
VIVA QUESTIONS:
52
53
Q9.Define Node?
A9. Entry or exit point of the network
RESULT: - Thus the Study of Star Topology using WLAN has been performed.
54
55
THEORY: --
LAN: When two or more computers are connected directly within the small well defined area
such as room, building etc. The physical topology of a network refers to the configuration of
cables, computers, and other peripherals.
Bus Topology:
A bus topology consists of a single cable connecting all nodes on a network without intervening
connectivity devices .The single cable is called a bus and can support one channel for
communication. Each node shares the bus’s total capacity
On bus topology network devices share the responsibility for getting the data from one point to
another. Ethernet bus topologies are relatively easy to install and don't require much cabling
compared to the alternatives. 10Base-2 ("ThinNet") and 10Base-5 ("ThickNet") both were
popular Ethernet cabling options many years ago for bus topologies. However, bus networks
work best with a limited number of devices. If more than a few dozen computers are added to a
network.
PROCEDURE:-
1. Create folder of destination node (ECE COM 1, ECE COM 2) name in both PC.
2. Click IPX protocol to enable it
3. Select server on one PC.
4. Select connect to network on another PC
5. Open the text document
6. Type the data on one PC
7. Sent data
8. Data is received on another PC
56
57
VIVA QUESTION :
Q3. What does the term ―selection process‖ signify in bus topology?
A3. Primary message inquiring if secondary is ready to receive traffic
58
59
PROCEDURE:
1. Connect four computer LAN ports using RJ-45 to RJ-45 LAN connecting cables provided
with the system to LTS-01 ring topology ports.
2. Switch on the LTS-01 & Computers.
3. Run L-SIM software on all the computers, one should be server and other 3 should be client.
Run the software in the sequence of connection i.e. server first followed by first client to last
client.
4. On the server computer select type of network as LAN.
5. On the server computer select the topology as RING, select protocol as Token Ring and select
token activation time as desired, click on create network button.
6. To just observe how token passes from one computer to another computer and effect of token
time keep token duration from 5 to 40 seconds and to do actual file transfer keep token duration
as 50 or 60 seconds.
7. Remote computer details will appear on the computers connected in network, server will be
able to see all clients and all clients will be able to see only server.
8. Select the computer to whom data file is to be transferred, from the load button, previously
stored/selected file information can be loaded or you can select any file, which is to be
transmitted.
60
61
9. File size will appear in the software window, select the packet size, inter packet delay and
click OK.
10. Total packets formed for that file will be indicated on computers, same details of file will
appear on remote computer to which file is to be transmitted.
11. Click on file transfer button to transfer file.
12. File transfer from one computer to another will take place.
13. To see the effect of ring break state remove any of the client from the hardware and close L-
SIM window for that client. Ring broken message will be prompted on server computer and
network will get destroyed, you need to reconfigure the network.
VIVA QUESTIONS:
OBSERVATION:
Thus the performance of Token Bus and Token Ring protocols are studied by introducing error
in the network path
62
63
EQUIPMENTS:
• N-SIM
• Computer with win-2K / XP
PROCEDURE:
1. Run N-SIM software from your computer.
2. To check working of distance vector routing algorithm in the form of animated representation
click on distance vector routing under routing protocols.
64
3. You can study the working of distance vector routing algorithm through this animated movie.
4. To implement this algorithm click on algorithms under menu and click on distance vector
routing.
5. Add the number of routers you want to, select one by one, maximum 8 routers can be added,
all the added routers will appear in the window.
65
6. Click configure button to define the links between pair of routers and define its cost in
kilometers.
7. Once all the possible pairs have been defined click save button to save the configuration
defined by you.
8. Depending on the configuration you will see all the possible links defined by you are
implemented and drawn in the screen near the routers added.
9. You can edit the configuration at any time by clicking on the value of the router number or
cost.
66
10. To simulate and find out shortest path select the source and destination routers.
11. Click on simulate button to start the algorithm, this will calculate the shortest path and will
be shown on the screen.
67
12. Click on the result button to see the parameters for shortest path.
VIVA QUESTIONS:
OBSERVATION:
Thus the Distance vector routing algorithm is implemented using N-SIM and found the shortest
path between the routers
68
69
OBJECTIVE:
Implementation of link state routing algorithm.
EQUIPMENTS:
• N-SIM
• Computer with win-2K / XP
PROCEDURE:
1. Run N-SIM software from your computer.
2. To check working of state routing algorithm in the form
representation click on state routing under routing protocols.
70
3. You can study the working of state routing algorithm through this animated movie.
4. To implement this algorithm click on algorithms under menu and click on state routing.
5. Add the number of routers you want to, select one by one, maximum 8 routers can be added,
all the added routers will appear in the window.
71
6. Click configure button to define the links between pair of routers and define its cost in
kilometers.
7. Once all the possible pairs have been defined click save button to save the configuration
defined by you.
8. Depending on the configuration you will see all the possible links defined by you are
implemented and drawn in the screen near the routers added.
9. You can edit the configuration at any time by clicking on the value of the router number or
cost.
9. To simulate and find out shortest path select the source and destination routers.
72
73
11. Click on simulate button to start the algorithm, this will calculate the shortest path and will
be shown on the screen.
12. Click on the result button to see the parameters for shortest path.
VIVA QUESTIONS:
OBSERVATION:
Thus the Link State vector routing algorithm is implemented using N-SIM and found the shortest
path between the routers
74
75
7.1: - SOCKETS:
1. Introduction
In the classic client-server model, the client sends out requests to the server, and the
server does some processing with the request(s) received, and returns a reply (or replies) to the
client. The terms request and reply here may take on different meanings depending upon the
context, and method of operation. An example of a simple and ubiquitous client-server
application would be that of a Web-server. A client (Internet Explorer, or Netscape) sends out a
request for a particular web page, and the web-server (which may be geographically distant,
often in a different continent!) receives and processes this request, and sends out a reply, which
in this case, is the web page that was requested. The web page is then displayed on the browser
(client).
Further, servers may be broadly classified into two types based on the way they serve
requests from clients. Iterative servers can serve only one client at a time. If two or more clients
send in their requests at the same time, one of them has to wait until the other client has received
service. On the other hand, concurrent servers can serve multiple clients at the same time.
Typically, this is done by spawning off a new server process on the receipt of a request – the
original process goes back to listening to new connections, and the newly spawned off process
serves the request received.
Sockets (also called Berkeley Sockets, owing to their origin) can simply be defined as
end-points for communication. To provide a rather crude visualization, we could imagine the
client and server hosts in Figure 1 being connected by a pipe through which data-flow takes
place, and each end of the pipe can now be construed as an ―end-point‖. Thus, a socket provides
us with an abstraction – or a logical end point for communication. There are different types of
sockets. Stream sockets, of type SOCK_STREAM are used for connection oriented, TCP
connections, whereas datagram sockets of type SOCK_DGRAM are used for UDP based
applications. Apart from these two, there are other socket types defined, like SOCK_RAW and
SOCK_SEQPACKET.
76
77
Figure 2 shows the TCP/IP protocol stack, and shows where the ―Socket layer‖ may be placed.
Again, please be advised that this is just a representation to indicate the level at which we operate
when we write network programs using sockets. As shown in the figure, sockets make use of the
lower level network protocols, and provide the application developer with an interface to the
lower level network protocols. A library of system calls are provided by the socket layer, and are
termed as the ―Socket API‖. These system calls can be used in writing socket programs.
The socket() system call creates a socket and returns a handle to the socket created. The
handle is of data type SOCKET. In UNIX based environments, the socket descriptor is a
non-negative integer, but Windows uses the SOCKET data type for the same.
78
79
components – The address family, the host address, and the port number at which the
application will provide its service. The syntax and arguments taken by the bind system
call is given below:
bind() syntax
int result = bind (SOCKET sd, const struct sockaddr* name, int namelen);
Here, sd is the SOCKET handle returned by the socket() system call before, and name
points to the SOCKADDR structure, and namelen is the length of the parameter name in
bytes.
After creation of the socket, and binding to a local port, the server has to wait on
incoming connection requests. The listen() system call is used to specify the queue or
backlog of waiting (or incomplete) connections. The syntax and arguments taken by the
listen system call is given below:
listen() syntax
int result = listen (SOCKET sd, int backlog);
Here, sd is the SOCKET handle returned by the socket() system call before, and backlog
is the number of incoming connections that can be queued.
listen system call
int result = listen (...);
if (result == SOCKET_ERROR) /* error condition */
{...}
Upon success, listen() returns 0. In case of error, listen() returns SOCKET_ERROR.
After executing the listen() system call, a server waits for incoming connections. An
actual connection setup is completed by a call to accept(). accept() takes the first
connection request on the queue, and creates another socket with the same properties as
sd (the socket descriptor returned earlier by the socket() system call). In case of
blocking sockets, this call would block the caller until a connection request arrives.
accept() assumes a concurrent server, and automatically creates a new socket descriptor
for the connection request received. In case of concurrent servers, a new server process
is spawned (or ―fork‖ed in UNIX terminology), and the newly created server process
serves this connection on this socket. The earlier socket goes back to listening on new
80
connections. In a sense, the accept() system call completes the connection, and at the
end of a successful accept(), all elements of the four tuple (or the five tuple – if you
consider ―protocol‖ as one of the elements) of a connection are filled. The ―four-tuple‖
that we talk about here is <Local Addr, Local Port, Remote Addr, Remote Port>. This
combination of fields is used to uniquely identify a flow or a connection. The fifth tuple
element can be the protocol field. No two connections can have the same values for all
the four (or five) fields of the tuple.
accept() syntax
SOCKET newsd = accept (SOCKET sd, struct sockaddr* addr, int* addrlen);
Here, sd is the SOCKET handle returned by the socket() system call before, and addr is a
pointer to a buffer that receives the address of the connecting entity, and addrlen is the
length of the parameter addr.
accept system call
SOCKET newsd = accept (...);
if (newsd == INVALID_SOCKET) /* error condition */
{...}
Upon success, accept() returns a handle to the new socket created. In case of error,
accept() returns SOCKET_ERROR.
A client process also starts out by creating a socket by calling the socket() system call. It
uses connect() to connect that socket descriptor to establish a connection with a server.
In the case of a connection oriented protocol (like TCP/IP), the connect() system call
results in the actual connection establishment of a connection between the two hosts. In
case of TCP, following this call, the three-way handshake to establish a connection is
completed. Note that the client does not have to bind to a local port in order to call
connect(). Clients typically choose ephemeral port numbers for their end of the
connection. Servers, on the other hand, have to provide service on well-known
(premeditated) port numbers.
connect() syntax
int result = connect (SOCKET sd, const struct sockaddr* servaddr, int addrlen);
Here, sd is the SOCKET handle returned by the socket() system call before, servaddr is a
pointer to the server’s address structure. addrlen holds the length of this parameter.
connect system call
int result = connect (...);
if (result == SOCKET_ERROR) /* error condition */
{...}
Upon success, connect() returns 0. In case of error, connect() returns SOCKET_ERROR.
After connection establishment, data is exchanged between the server and client using the
system calls send(), recv(), sendto() and recvfrom(). The syntax of the system calls are
as below:
send(), recv(), sendto() and recvfrom() syntax
int nbytes = send (SOCKET sd, const char* buf, int len, int flags);
81
int nbytes = recv (SOCKET sd, const char* buf, int len, int flags);
int nbytes = sendto (SOCKET sd, const char* buf, int len, int flags,
struct sockaddr* to, int tolen);
int nbytes = recvfrom (SOCKET sd, const char* buf, int len, int flags,
struct sockaddr* from, int fromlen);
Here, sd is the SOCKET handle returned by the socket() system call before, buf is the
char buffer to be sent or received, flags is the indicator specifying the way the call is to be
made. sendto() and recvfrom() are used in case of connectionless sockets, and they do
the same function as send() and recv() except that they take more arguments (the ―to‖
and ―from‖ addresses – as the socket is connectionless)
Upon success, all these calls return the number of bytes written or read. Upon failure, all
the above calls return SOCKET_ERROR
The closesocket() system call is used to close the connection. In some cases, any
remaining data that is queued is sent out before the closesocket() is executed.
closesocket() syntax
int result = closesocket (SOCKET sd);
Here, sd is the SOCKET handle returned by the socket() system call before.
closesocket system call
int result = closesocket (...);
if (result == SOCKET_ERROR) /* error condition */
{...}
Upon success, closesocket() returns 0. In case of error, closesocket() returns
SOCKET_ERROR.
83
OBJECTIVE:
To write a java program to implement two way communication using TCP(Transmission
Control Protocol).
ALGORITHAM:
SERVER:
CLIENT:
84
SOURCE CODE:
CLIENT
import java.io.*;
import java.net.*;
importjava.lang.*;
class client1
{
public static void main(String a[])throws IOException
{
Socket s=new Socket("LocalHost",8000);
DataInputStream in=new DataInputStream(s.getInputStream());
DataInputStream inn=new DataInputStream(System.in);
PrintStream dos=new PrintStream(s.getOutputStream());
while(true)
{
String str=in.readLine();
System.out.println("msg received:"+str);
if(str.equals("end"))
{
s.close();
break;
}
System.out.println("enter the msg to send: ");
String str1=inn.readLine();
dos.println(str1);
if(str1.equals("end"))
{
s.close();
break;
}
}
}
}
85
SERVER
import java.io.*;
import java.net.*;
importjava.lang.*;
class server1
{
public static void main(String a[])throws IOException
{
ServerSocketss=new ServerSocket(8000);
Socket s=ss.accept();
PrintStream dos=new PrintStream(s.getOutputStream());
DataInputStream in=new DataInputStream(System.in);
DataInputStream inn=new DataInputStream(s.getInputStream());
while(true)
{
System.out.println("enter the msg to send: ");
String str=in.readLine();
dos.println(str);
if(str.equals("end"))
{
ss.close();
break;
}
String str1=inn.readLine();
System.out.println("msg received"+str1);
if(str1.equals("end"))
{
ss.close();
break;
}
}
}
}
86
87
OUTPUT:
SERVER
C:\>cd C:\Program Files\Java\jdk1.6.0\bin
C:\Program Files\Java\jdk1.6.0\bin>javac server1.java
C:\Program Files\Java\jdk1.6.0\bin>java server1
enter the msg to send:
HAI FRIENDS
msgreceived:HELLO
enter the msg to send:end
C:\Program Files\Java\jdk1.6.0\bin>
CLIENT
C:\>cd C:\Program Files\Java\jdk1.6.0\bin
C:\Program Files\Java\jdk1.6.0\bin>javac client1.java
C:\Program Files\Java\jdk1.6.0\bin>java client1
C:\Program Files\Java\jdk1.6.0\bin>java client1
msgreceived:HAI FRIENDS
enter the msg to send:
HELLO
enter the msg to send:end
C:\Program Files\Java\jdk1.6.0\bin>
RESULT: Thus the two way communication using TCP based on client-server model
has been successfully verified.
88
89
AIM:
To write a socket program to perform “File Transfer Protocol”.
ALGORITHM
SERVER SIDE
1. Import the java packages and create class fileserver.
2. String of argument is passed to the args[].
3. Create a new server socket and bind it to the port.
4. Accept the client connection at the requested port.
5. Get the filename and stored into the BufferedReader.
6. Create a new object class file and readline.
7. If File is exists then FileReader read the content until EOF is reached.
8. Else Print FileNamedoes’t exits.
9. End of main.
10. End of FileServer class.
CLIENT SIDE
1. Import the java packages and create class fileClient.
2. String of argument is passed to the args[].
3. The connection between the client and server is successfully established.
4. The object of a BufferReader class is used for storing data content which have been
retrieved from socket object s.
5. The content are read and stored in inp until the EOF is reached.
6. The content of file are displayed in displayed in client window and the connection is
closed.
7. End of main.
8. End of Fileclient class.
SOURCE CODE
SERVER
import java.io.*;
import java.net.*;
public class fileserver1
{
public static void main(String args[])throws IOException
{
ServerSocket s1=null;
try
90
{
s1=new ServerSocket(1187);
}
catch(IOException u1)
{
System.out.println("could not found port 1187");
System.exit(1);
}
Socket c=null;
try
{
c=s1.accept();
System.out.println("connection frame" +c);
}
catch(IOException e)
{
System.out.println("accept failed");
System.exit(1);
}
PrintWriter out=new PrintWriter(c.getOutputStream(),true);
BufferedReader sin=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the text file name");
String s=sin.readLine();
File f=new File(s);
if(f.exists())
{
BufferedReader in=new BufferedReader(new FileReader(s));
String v;
while((v=in.readLine())!=null)
{
out.write(v);
out.flush();
}
System.out.println("the file send successfully");
in.close();
c.close();
s1.close();
}
}
}
91
CLIENT
import java.io.*;
import java.net.*;
public class fileclient1
{
public static void main(String args[])throws IOException
{
Socket s=null;
BufferedReader b=null;
try
{
s=new Socket(InetAddress.getLocalHost(),1187);
b=new BufferedReader(new InputStreamReader(s.getInputStream()));
}
catch(Exception u)
{
System.out.println("the file is received");
System.out.println("don't know host");
System.exit(1);
}
String inp;
while((inp=b.readLine())!=null)
{
System.out.println("the content of the file is");
System.out.println(inp);
System.out.println("the file is received successfully");
}
b.close();
s.close();
}
}
92
93
OUTPUT:
SERVER
C:\>cd C:\Program Files\Java\jdk1.6.0\bin
C:\Program Files\Java\jdk1.6.0\bin>javac fileserver1.java
C:\Program Files\Java\jdk1.6.0\bin>java fileserver1
connectionframeSocket[addr=/127.0.0.1,port=1056,localport=1187]
enter the text file name
HAI.txt
the file send successfully
C:\Program Files\Java\jdk1.6.0\bin>
CLIENT
C:\>cd C:\Program Files\Java\jdk1.6.0\bin
C:\Program Files\Java\jdk1.6.0\bin>javac fileclient1.java
C:\Program Files\Java\jdk1.6.0\bin>java fileclient1
the content of the file is
GOD LOVE'S EVERY ONE IN THE WORLD.
the file is received successfully
C:\Program Files\Java\jdk1.6.0\bin>
RESULT:
The client – server model using FTP has been successfully verified.
94
95
AIM:
To write a program in java to demonstrate the ECHO command.
ALGORITHM:
ECHOSERVER:
ECHOCLIENT:
96
SOURCE CODE:
ECHO SERVER
import java.io.*;
import java.net.*;
class echoserver
{
public static void main(String args[])
{
try
{
Socket s=null;
ServerSocket ss=new ServerSocket(8000);
s=ss.accept();
System.out.println(s);
BufferedReader br=new BufferedReader(new InputStreamReader(s.getInputStream()));
PrintWriter print=new PrintWriter(s.getOutputStream());
int i=1;
while(i>0)
{
String str=br.readLine();
if(str.equals("."))
break;
System.out.println("msg received by client:"+str);
print.println(str);
print.flush();
}
}
catch(IOException e)
{
System.out.println("\n error:"+e);
}
}
}
97
ECHO CLIENT
import java.io.*;
import java.net.*;
class echoclient
{
public static void main(String a[])
{
try
{
Socket s=new Socket("LocalHost",8000);
DataInputStream in=new DataInputStream(System.in);
BufferedReader br1=new BufferedReader(new InputStreamReader(System.in));
BufferedReader br2=new BufferedReader(new InputStreamReader(s.getInputStream()));
PrintWriter print=new PrintWriter(s.getOutputStream());
System.out.println("\n msg to be echo:");
String str=br1.readLine();
print.println(str);
print.flush();
System.out.println(br2.readLine());
}
catch(UnknownHostException e)
{
}
catch(IOException e)
{
System.out.println("\n error:"+e);
}
}
}
98
99
OUTPUT:
CLIENT
C:\>cd C:\Program Files\Java\jdk1.6.0\bin
C:\Program Files\Java\jdk1.6.0\bin>javac echoclient.java
C:\Program Files\Java\jdk1.6.0\bin>java echoclient
msg to be echo:
GOD IS GREAT
GOD IS GREAT
C:\Program Files\Java\jdk1.6.0\bin>
SERVER:
C:\>cd C:\Program Files\Java\jdk1.6.0\bin
C:\Program Files\Java\jdk1.6.0\bin>javac echoserver.java
C:\Program Files\Java\jdk1.6.0\bin>java echoserver
Socket[addr=/127.0.0.1,port=1623,localport=8000]
msg received by client:GOD IS GREAT
C:\Program Files\Java\jdk1.6.0\bin>
RESULT:
Thus the output for the ECHO command using java was executed and verified
successfully.
100
101
AIM:
To write a program in java to demonstrate the usage of PING command.
ALGORITHM:
SOURCE CODE:
PING SERVER
import java.io.*;
import java.net.*;
public class pingserver
{
public static void main(String a[])
{
String line1,line2;
int i;
ServerSocket es;
DataInputStream di;
PrintStream ps;
Socket csoc;
es=null;
csoc=null;
try
{
es=new ServerSocket(9999);
}
catch(Exception e)
{
System.out.println(e);
}
System.out.println("ping server");
try
{
102
import java.io.*;
import java.net.*;
public class pingclient
{
public static void main(String args[])
{
PrintWriter out=null;
int i,j,k;
BufferedReader networkIn=null;
try
{
System.out.println("enter the IP address:");
DataInputStream in = new DataInputStream(System.in);
String ip = in.readLine();
Socket thesocket = new Socket(ip, 9999);
networkIn = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(thesocket.getOutputStream());
System.out.println("\npinging" + ip + "with 32 bytes of data\n");
for (i = 0; i < 4; i++)
{
out.println(ip);
out.flush();
String inp = networkIn.readLine();
if (inp != null)
{
for (j = 0; j < 10000; j++)
{
for (k = 0; k < 50000; k++)
103
104
105
OUTPUT
PING CLIENT
C:\>cd C:\Program Files\Java\jdk1.6.0\bin
C:\Program Files\Java\jdk1.6.0\bin>javac pingclient.java
C:\Program Files\Java\jdk1.6.0\bin>java pingclient
enter the IP address:
192.168.1.10
pinging192.168.1.10with 32 bytes of data
5
reply from5
8
reply from8
9
reply from9
4
reply from4
C:\Program Files\Java\jdk1.6.0\bin>
PINGSERVER
C:\>cd C:\Program Files\Java\jdk1.6.0\bin
C:\Program Files\Java\jdk1.6.0\bin>javac pingserver.java
C:\Program Files\Java\jdk1.6.0\bin>java pingserver
ping server
pinged by client
pinged by client
pinged by client
pinged by client
C:\Program Files\Java\jdk1.6.0\bin>
RESULT:
Thus the output for the PING command using java was executed and verified
successfully.
106
107
AIM:
To send and receive message from client and server using connection oriented service.
ALGORITHM:
SERVER:
CLIENT:
1. Create a client socket that connects to the required host and port.
2. Using input streams read message given by server and print it.
3. Using input streams, get message from user to be given to the server.
4. Use output streams to write message to the server.
SOURCE CODE:
TALKSERVER:
import java.io.*;
import java.net.*;
public class talkserver
{
public static void main(String[] args)throws IOException
{
try
{
ServerSocket server=new ServerSocket(2000);
Socket client=server.accept();
System.out.println("connection established..");
DataInputStream dis=new DataInputStream(client.getInputStream());
PrintStream ps=new PrintStream(client.getOutputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s="";
int i=0;
while(i<10)
108
TALKCLIENT:
import java.io.*;
import java.net.*;
public class talkclient
{
public static void main(String[] args)
{
try
{
Socket server=new Socket("localhost",2000);
System.out.println("connected..");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
DataInputStream dis=new DataInputStream(server.getInputStream());
PrintStream ps=new PrintStream(server.getOutputStream());
int i=0;
String s=" ";
while(i<10)
{
System.out.println("\n Message to server:");
s=br.readLine();
ps.println(s);
if(s.equals("end"))
break;
System.out.println("\n Message from server:"+dis.readLine());
}
ps.close();
109
dis.close();
br.close();
}
catch(Exception e)
{
}
}
}
OUTPUT
Talk Client
C:\>cd C:\Program Files\Java\jdk1.6.0\bin
C:\Program Files\Java\jdk1.6.0\bin>javac talkclient.java
C:\Program Files\Java\jdk1.6.0\bin>java talkclient
Connected…..
Message to Server:
Hi How R You
C:\Program Files\Java\jdk1.6.0\bin>
TALK SERVER
C:\>cd C:\Program Files\Java\jdk1.6.0\bin
C:\Program Files\Java\jdk1.6.0\bin>javac talkserver.java
C:\Program Files\Java\jdk1.6.0\bin>java talkserver
Connection established……
From Client: Hi How R You
To Client
C:\Program Files\Java\jdk1.6.0\bin>
RESULT:
Thus the output for the TALK command using java was executed and verified
successfully.
110
111
AIM:
To implement the Error Detection and Error Correction using Hamming Codes.
SOURCE CODE:
Import java.util.*;
class hamming_code
{
static int set_parity_bit(int a[])
{
int count=0; //........Initialising count to zero which will count the number of 1.
int l=a.length;
for(int i=0;i<l;++i)
if(a[i]==1)
++count; //............Incrementing count if value in array "a" is 1.
if((count%2)==0)
return 0;//........Returning 0 if even number of 1
else
return 1;//........Returning 1 if odd number of 1
}
public static void main(String args[])
{
Scanner scr=new Scanner(System.in);
System.out.println("This is hamming code error detection and correction using EVEN parity");
System.out.println();
System.out.println("Enter 4 data bits.D4 D3 D2 D1");
int n=4; //set number of data bits
int d[]=new int[4]; //..........Array to accept data bits
for(int i=n-1;i>=0;--i)
{
System.out.println("Enter the value of D"+(i+1));
d[i]=scr.nextInt();
}
int count=0;
int c=2;
while(count<4)
{
++c;
if(c==4)
continue;
h[c]=d[count];
++count;
}
int p1[]={h[1],h[3],h[5],h[7]};
int p2[]={h[2],h[3],h[6],h[7]};
int p3[]={h[4],h[5],h[6],h[7]};
int parity[]=new int[3];
/************Setting the value of parity bit*************/
parity[0]=set_parity_bit(p1);
parity[1]=set_parity_bit(p2);
parity[2]=set_parity_bit(p3);
/************Inserting the parity bits in the hamming code**********/
h[1]=parity[0];
h[2]=parity[1];
h[4]=parity[2];
System.out.println("\nSENDER:");
System.out.print("\nThe data bits entered are: ");
for(int i=3;i>=0;--i)
System.out.print(d[i]+" ");
113
System.out.println();
int p4[]={h[1],h[3],h[5],h[7]};
int p5[]={h[2],h[3],h[6],h[7]};
int p6[]={h[4],h[5],h[6],h[7]};
parity[0]=set_parity_bit(p4);
parity[1]=set_parity_bit(p5);
parity[2]=set_parity_bit(p6);
int position=(int)(parity[2]*Math.pow(2,2)+parity[1]*Math.pow(2,1)+parity[0]*Math.pow(2,0));
System.out.println("\nRECEIVER:");
System.out.println("Error is detected at position "+position+" at the receiving end.");
System.out.println("Correcting the error.... ");
if(h[position]==1)
h[position]=0;
else
h[position]=1;
114
115
SENDER:
Enter the hamming code with error at any position of your choice.
NOTE: ENTER A SPACE AFTER EVERY BIT POSITION.
Error should be present only at one bit position
1010110
RECEIVER:
Error is detected at position 3 at the receiving end.
Correcting the error....
The correct code is 1 0 1 0 0 1 0
*/
SELF TEST
1. Can parity code detect even number of errors?
2. What is the full form of CRC?
3. What is the advantage with Hamming code?
4. What is error detection-correction overhead?
RESULT:
Thus the above program implemented using Hamming Code has been executed successfully.
116
117
OBJECTIVE:
Study of data encryption and decryption.
EQUIPMENTS:
• LTS-01 trainer kit
• 2 Computers with win-2K / XP and LAN card installed on them
• RJ-45 to RJ-45 LAN connecting cables
PROCEDURE:
1. Connect at least two computer LAN ports using RJ-45 to RJ-45 LAN connecting cables
provided with the system to LTS-01 star topology ports.
2. Switch on the LTS-01 & Computers.
3. Run L-SIM software on both the computers, one should be server and another should be
client.
118
5. On the server computer select the topology as STAR and select protocol as Stop & Wait and
click on create network button.
6. Remote computer details will appear on the computers connected in network, server will be
able to see client and client will be able to see server.
7. Select the computer to whom data file is to be transferred, from the load button, previously
stored/selected file information can be loaded or you can select any file, which is to be
transmitted, if notepad text file is selected encryption information can be viewed very clearly for
each packet formed for that file.
8. File size will appear in the software window, select the packet size, inter packet delay and
click OK.
9. Total packets formed for that file will be indicated on computers, same details of file will
appear on remote computer to which file is to be transmitted.
10. Click on file transfer button to transfer file.
11. Click on pause button to interrupt file transfer and click on encrypt/decrypt button to see file
packet encrypted and decrypted.
119
12. You will see actual file content and encrypted data content in encryption details window.
13. You can type any text at the bottom box, which you want to encrypt and provide key text for
encryption. Similarly same key can be typed again to decrypt and recover encrypted text. If the
key at decryption stage differ from key at encryption stage, decrypted data will not be perfect as
per original data.
14. To understand the working of how encryption took place you can view visual explanation of
encryption and decryption process by clicking on visual help button.
15. You can resume file transfer by clicking on continue button.
120
121
16. Encrypted format of each packet can thus be seen by pausing the file transfer at respective
packet when it is under transmission state.
17. File transfer from one computer to another will take place.
VIVA QUESTIONS:
1. Define Encryption.
OBSERVATION:
Thus the data encryption and decryption implemented and studied with the help of L-SIM &
LTS Trainer.
122
123
AIM:
PROGRAM:
#include<stdio.h>
void main()
{
FILE *fp,*fp1;
intchoi;
char name[20],temp[20]={"Temp.txt"},c;
clrscr();
printf("Press 1 to Encrypt:Press 2 to Decrypt");
printf("Enter your Choice:");
scanf("%d",&choi);
switch(choi)
{
case 1:
printf("Enter the filename to Encrypt:");
scanf("%s",name);
fp=fopen(name,"r+");
if(fp==NULL)
{
printf("The file %s can't be open",name);
getch();
exit();
}
fp1=fopen(temp,"w+");
if(fp1==NULL)
{
printf("The file Temp can't be open");
getch();
exit();
}
c=fgetc(fp);
while(c!=EOF)
{
fputc((c+name[0]),fp1);printf("%c",c+name[0]);getch();
c=fgetc(fp);
}
fclose(fp);
124
fclose(fp1);
remove(name);
rename(temp,name);
printf("The file is Encrypted:");
getch();
break;
case 2:
printf("Enter the Filename to Decrypt:");
scanf("%s",name);
fp=fopen(name,"r+");
fp1=fopen(temp,"w+");
c=fgetc(fp);
while(c!=EOF)
{
fputc(c-name[0],fp1);
c=fgetc(fp);
}
fclose(fp);
fclose(fp1);
remove(name);
rename(temp,name);
printf("The file is decrypted:");
getch();
}
}
125
OUTPUT:
RESULT:
Thus the data encryption and decryption implemented and studied using TURBOC
126
127
Aim:
To study of different wireless network simulators and observe the comparison table of each
simulator.
THEORY:
1.1 GLOMOSIM/QUALNET:
Glomosim known as Global Mobile Information System simulator is a public domain simulator
developed by UCLA.Ithas scalable environment for large wireless and the communication for
wire line networks. GlomoSim is used for parallel discrete-event simulation .This capability is
provided by Parsec. Commercial tool of GloMosim is QuaNet. It is derived from the GloMoSim
that was first released in 2000 by SNT .The main differences between QualNet and GloMoSim
are(1) Qualnet is based on C++ but GloMoSim is based on the C Parsec language.(2)Qualnet is a
Commercial Product, butthe GloMosim is distributed under an open source license. (3) Qualnet
is maintained by SNT, but the GloMosim is maintained by Parallel Computing. Qualnet
Architecture is composed of (1) Qualnet kernel: The kernel of Qualnet is a parallel discrete-event
scheduler. It provides the scalability and portability to run hundreds and thousands of nodes with
high-fidelity models on a variety of platforms, from laptops and desktops to high performance
computing systems.(2)QualNet Model Libraries: QualNet supports a number of model libraries
that enables to design networks using various protocol models. QualNet includes the Developer,
Multimedia and Enterprise, and Wireless Model Libraries. Additional libraries such as cellular
networks, satellite networks, UMTS, WiMAX, sensor networks, military radio networks, and
advanced propagation model libraries are also available.(3)QualNet Graphical User Interface:
QualNet GUI consists of Architect, Analyzer, Packet Tracer, and File Editor. Architect is a
network design and visualization tool. Analyzer is a statistical graphing tool that displays
hundreds of metrics collected during simulation of a network scenario. Packet Tracer provides a
visual representation of packet trace files generated during the simulation of a network scenario.
File editor is a text editing tool.(4)QualNet Command Line Interface: The QualNet command
line interface enables a user torun QualNet from a DOS prompt (in Windows) or from a
command window (in Linux). Qualnet enables users to design new protocol models, optimize
new and existing models, Design large wired and wireless networks using preconfigured or user-
designed models and analyze the performance of networks . Qualnet can support real-time speed
to enable software-in-the-loop, network emulation, and hardware-in-the-loop modeling. QualNet
can model thousands ofnodes. QualNet can run on cluster, multi-core, and multi-processor
systems to model large networks with high fidelity. Qualnet can communicate with other
simulators through HLA module. The QualNet advantages are the
128
complete GUI provided, which is, in our opinion, simpler to use than the OPNET one. It shows a
very good scalability, simulation time being reasonable, even on a laptop or desktop computer
(tens of thousands of nodes including mobility and high traffic can be simulated in relatively
short simulation times). However, some features are not clearly detailed. For example,
QualNet allows the modeling of new protocols with the GUI as well as by directly coding the
protocol. Nevertheless, it makes not clear that new components can be created
2.2 OMNet++
OMNeT++ is an open source, component-based, modular and open architecture environment for
discrete event simulation. It is free of charge for academic and non-profit use. Its primary
application area is the simulation of communication networks, but its generic and flexible
architecture makes it possible to use it in other areas like the simulation of complex IT systems,
queuing networks or hardware architectures. OMNeT++ is not a network simulator; however, it
is currently gaining popularity as a network simulation platform in the scientific community as
well as in industrial ones, and building up a large user community. OMNeT++ runs on Linux,
other Unix-like systems and on Windows (XP, Win2K) OS platforms. OMNet++ is composed of
(1) Graphical network editor: A graphical network editor (GNED) to allow graphical topology
build, creating files in the Network Description (NED) language (2) Kernel library: A simulation
Kernel library contains definitions of objects used for the topology creation (3) Command line
interface: Includes Graphical and command line interfaces for simulation execution (4) A model
documentation tool for documentation. Two kinds of modules exist: simple modules and
compound modules. Compound modules are a set of simple modules. These modules are
assembled into larger components and models using a high-level Network Description (NED)
language, allowing a hierarchical organization of the network. These compound modules allow
simulation of large-scale networks. Modules communicate by message exchanges. These
messages may represent, for instance, packets in communication networks or jobs in queuing
networks. They are sent from a simple module to another simple module, either directly to their
destination or along a predefined path. Messages are exchanged through gates and connections
OMNeT++ offers the possibility either to modify existing models or to create new object classes
that may be derived from basic object classes (module, gate, connection, etc.). Modules types
can be stored in separate files. This allows the user to group existing module types and to
compose component libraries. OMNeT++ implements a deterministic modeling formalism. But
it also handles continuous and discrete stochastic variables that give randomness to the model.
OMneT ++ has a separate window for each modules text output. Scheduled messages can be
watched as the simulation progresses, Event–by-event execution .Execution animations.
Graphical display of simulation results during execution.
129
2.3 NS-2
It is a public domain event-driven network simulator developed at UC Berkeley. It is available
on UNIX, Free BSD and Windows OS platforms. NS-2 is currently a part of the VINT (Virtual
Inter-Network Test bed) project [VINT]. NS-2 is designed to simulate small-scale networks. NS-
2 is based on three languages: TCL writes simulation script, OTCL defines simulation parameter,
C++ implements the schedulers. The outputs produced by NS-2 can be: General format trace
files, NAM format trace files, Personalized trace files.Ns-2 is cheap, complex scenarios can be
easily tested, results can be quickly obtained, supports platform and protocols and popular. Main
disadvantage is that real time system too complex to model and scalability issue.
2.4 OPNET
It provides a global environment to model, simulate and evaluate performances of all kinds of
wired and wireless communication networks and distributed systems. It is available on Windows
2000, XP, Linux and Solaris platforms. The OPNET environment includes graphical tools for
scenarios and models conception, scenarios simulation, data collection and data analysis. A
simulation within OPNET is represented by a project including a set of scenarios. This project is
created through the project editor also known as the OPNET central interface. All the available
functionalities may be accessed from this editor. It provides an access to other editors that
propose functions including node and process model creation, building packet formats, and
creating filters and parameters. OPNET provides many additional functions including a High-
Level Architecture (HLA) module, which allows communication between various simulators.
OPNET allows hierarchical modeling by defining a network as a collection of sub-models
representing sub-networks or nodes. Modeling is done within the modeling environment, which
consists of three domains. (1)The network domain. It defines the communication network
topology to simulate. (2) The node domain. The node domain instantiates the nodes defined in
the network domain, i.e. elements connected to the network that can send and receive data(3)
The process domain The process domain describes every module (processors or queues) that is
programmable by the user. They execute processes or tasks. The visualization and analysis of
results is achieved with the Analysis Tool and the Filter Editor. The Analysis Tool displays the
results of a simulation or series of simulations as graphs. Although simulation results can be
viewed in the Project Editor. OPNET modeling modularity is an asset to model critical
infrastructures. It offers the possibility to define and add new models specific to the
infrastructure to simulate. New parameters can also be specified to model actions that might
occur within the infrastructure (management, processing, etc.). Infrastructures can be
distinguished by the process models (i.e.: the codes or programs that characterize the state of the
modules associated to a node or a link).However, this tool is quite complex, especially if specific
component have to be developed.
2.5 J-SIM
J-Sim (Java Simulator) is a free of charge implementation for simulation of a component-based
architecture, the Autonomous Component Architecture (ACA). The ACA mimics the integrated
circuit design and manufacturing model in terms of how components are specified, designed and
assembled [J-Sim]. J-Sim includes a specific platform, dedicated to network simulation, the
Internetworking Simulation Platform called INET, but is not limited to this field. Its organization
is similar to the one of OMNeT++. J-Sim is a real-time process-driven simulator, in other words,
130
131
a simulation runs in the same manner as a real system does, in the sense that event executions are
carried out in real time as opposed to at fixed time points in discrete event simulation. As in NS-
2, two languages are used in J-Sim: Java to describe and implement models and a script language
to construct, configure and/or control the simulation at run-time. JSim has been designed to
support Tcl, Perl or Python script languages, however, the available implementation is based on
Tcl. J-Sim provides specific Tcl commands, the Runtime Virtual (RUV) commands, to simplify
the manipulation and the configuration of the network components during simulation runtime. J-
Sim includes the INET platform that is dedicated to network simulation the simulation results
can be collected of three ways: Trace files, X-Y graph and NAM
RESULT:
Fast simulation capabilities are only supported by Qualnet and Opnet. Qualnet and
Opnet are commercial whereas Ns-2, Omnet++ and J-Sim are open source.
132
133
AIM:
To analyze the performance of TCP&UDP congestion control algorithm using NS2.
APPARATUS REQUIRED:
System with installed NS2, Ubuntu OS
PROGRAM:
134
135
# monitor the queue for the link between node 2 and node 3
$ns duplex-link-op $node3 $node4 queuePos 0.5
137
To RUN
RESULT:
Thus the performance of TCP/UDP congestion control algorithm using NS2 has been analyzed.
138
139
EXT NO : 12 : - PC – PC COMMUNICATION
OBJECTIVE:
To study Parallel Communication using 8 bit parallel cable.
EQUIPMENTS:
• DCT-03.
• 9 Pin D connector Cables – 2 Nos.
• 25 Pin D connector Cables – 2 Nos.
• Computers – PC - 2 nos.
• Connecting Chords.
• Power Supply.
PROCEDURE:
PARALLEL COMMUNICATION:
1. Carry out the following connections and settings as shown in the diagram.
2. Keep all switch fault switches in off position.
3. Keep switch SW6 in PC mode.
4. Connect LPT/parallel port of one PC to connector CN1 on left hand side on DCT-03 kit using
25-25 pin D type cable. Similarly connect LPT/parallel port of another PC to connector CN2 on
right hand side on DCT-03 kit using 25-25 pin D type cable.
5. Keep the switch settings for SW1, SW2 & SW3 in ON position as shown.
6. Switch ON the power supply.
7. Run DCT software
140
8. Clicking on Port Setting will show you three ports (i.e. LPT1, LPT2, LPT3), select the port
from the user machine through which the data transfer has to occur. For example Clicking on
LPT1 will set the LPT1 as the active port on the machine for the data transfer.
9. Please ensure that the selected ports are in bi-directional mode, this can be checked from the
BIOS settings of the computer.
10. Clicking on Protocols will show you three protocols namely Stop and Wait Protocol, Go
Back N Protocol and Selective Repeat protocol. Select Same protocol on both PC. Screen similar
to one given below will appear.
141
142
143
26. At the receiver a selection window will popup to indicate location for the received file to be
saved.
27. Verify the received file with transmitted file, this shows end of file transfer with success.
28. The receiving packets can be discarded or killed by clicking the Discard button.
29. Any acknowledge that is transmitted back can be also made to lost by just clicking Lost
button. Thus the Transmitter side will not receive any acknowledge.
30. The third button NACK/LOST can be clicked to discard and to lose any acknowledge
sending back to the Transmitter simultaneously.
31. Similarly other Parallel port file transfer protocols can be studied with the effects of fault in
packets.
RESULT:
Thus the implementation of serial communication and parallel communication were studied with
the help of DCT Trainer using RS232 cable
144
145
6. Right-click on the 10BaseT LAN node. Edit attributes and change the name of attribute to
LAN and observe that the Number of Workstations attribute has a value of 10.
7. Click in the Value column for the Application: Supported Profiles attribute, and select Edit.
You should get a table in which you should do the following:
9. Make three copies of the Engineering subnet we just created. Click on the Engineering node.
From the Edit menu, select Copy and then Paste three times, placing the subnet in the
workspace after each, to create the new subnets.
146
The figure-1 shows the servers subnet inside which there are individual servers for different
purposes and are interconnected.
147
the applications defined in the profiles we deployed. You can double- check these
applications by editing the attributes of our Profile node. Inspect each row under the
Applications hierarchy, which in turn, is under the Profile Configuration hierarchy. You
will see that we need servers that support the following applications: Web browsing, Email,
Telnet, File Transfer, Data base & File print.
148
149
OUTPUT
150
151
NETWORK SIMULATOR
TOOLS
152
1. Cloonix
web: http://clownix.net/
Description: Cloonix is a Linux router and host simulation platform. It fully encapsulates
application, host, and network l2 and l3 into a relatively easy-to-use simulation GUI. Network
delay and loss characteristics can be configured per link. It provides support for running kvm or
UML virtual machines configured into an arbitrary complex network configuration. It is possible
to run a 12 router UML simulation on a small x86 host (a P4 with 512 MB RAM). 32- and 64-bit
KVM machines are provided.
Web: http://www.nrl.navy.mil/itd/ncs/products/core
Description: The Common Open Research Emulator (CORE) is a tool for emulating networks
on one or more machines. You can connect these emulated networks to live networks. CORE
consists of a GUI for drawing topologies of lightweight virtual machines, and Python modules
for scripting network emulation.
2. GNS3
web: http://www.gns3.net/
Description: GNS3 is an open source software (under GPL) that simulate complex networks
while being as close as possible to the way real networks perform. All of this without having
dedicated network hardware such as routers and switches (focusing no Cisco and Juniper).
Our software provides an intuitive graphical user interface to design and configure virtual
networks, it runs on traditional PC hardware and may be used on multiple operating systems,
including Windows, Linux, and MacOS X.
GNS3 can also be used to simulate a network composed exclusively of VirtualBox and/or Qemu
virtual machines running open-source software. GNS3 provides a variety of prepared open-
source virtual appliances, and users can create their own.
153
3. IMUNES
web: http://www.imunes.net/
4 Marrionet
web: http://www.marionnet.org/
Description: Marionnet is a virtual network laboratory: it allows users to define, configure and
run complex computer networks without any need for physical setup. Only a single, possibly
even non-networked GNU/Linux host machine is required to simulate a whole Ethernet network
complete with computers, routers, hubs, switches, cables, and more. Support is also provided for
integrating the virtual network with the physical host network.
5.Mininet
web: http://mininet.org/
Description: Mininet creates a realistic virtual network, running real kernel, switch and
application code, on a single machine (VM, cloud or native), in seconds, with a single
command.
154
6. MLN
web: http://mln.sourceforge.net/index.php
Description: MLN (Manage Large Networks) is a virtual machine administration tool designed
to build and run virtual machine networks based on Xen, VMware Server and User-Mode Linux.
It is ideal for creating virtual network labs for education, testing, hosting or simply playing
around with virtual machines.
7. NS-2
web: http://nsnam.isi.edu/nsnam/index.php/User_Information
, http://nsnam.isi.edu/nsnam/index.php/Main_Page
Ns began as a variant of the REAL network simulator in 1989 and has evolved substantially over
the past few years. In 1995 ns development was supported by DARPA through the VINT project
at LBL, Xerox PARC, UCB, and USC/ISI. Currently ns development is supported through
DARPA with SAMAN and through NSF with CONSER, both in collaboration with other
researchers including ACIRI. Ns has always included substantal contributions from other
researchers, including wireless code from the UCB Daedelus and CMU Monarch projects and
Sun Microsystems.
155
8. NS-3
web: http://www.nsnam.org/
Description: Ns-3 is a discrete-event network simulator for Internet systems, targeted primarily
for research and educational use. ns-3 is free software, licensed under the GNU GPLv2 license,
and is publicly available for research, development, and use.
The goal of the ns-3 project is to develop a preferred, open simulation environment for
networking research: it should be aligned with the simulation needs of modern networking
research and should encourage community contribution, peer review, and validation of the
software.
9. Omnet++
web: http://www.omnetpp.org/
web: http://www.riverbed.com/products/performance-management-control/network-
performance-management/network-simulation.html
Description: Riverbed Modeler - discrete event-simulation engine for analyzing and designing
communication networks. Riverbed Modeler comprises of a suite of protocols and technologies
with a sophisticated development environment. By modeling all network types and technologies
(including VoIP, TCP, OSPFv3, MPLS, IPv6, and more), Riverbed Modeler analyzes networks
to compare the impact of different technology designs on end-to-end behavior. Modeler lets you
test and demonstrate technology designs before production; increase network R&D productivity;
develop proprietary wireless protocols and technologies; and evaluate enhancements to
standards-based protocols.
156
web: https://www.netacad.com/web/about-us/cisco-packet-tracer
Description: Cisco Packet Tracer is a powerful network simulation program that allows students
to experiment with network behavior and ask ―what if‖ questions. As an integral part of the
Networking Academy comprehensive learning experience, Packet Tracer provides simulation,
visualization, authoring, assessment, and collaboration capabilities and facilitates the teaching
and learning of complex technology concepts.
Packet Tracer supplements physical equipment in the classroom by allowing students to create a
network with an almost unlimited number of devices, encouraging practice, discovery, and
troubleshooting. The simulation-based learning environment helps students develop 21st century
skills such as decision making, creative and critical thinking, and problem solving. Packet Tracer
complements the Networking Academy curricula, allowing instructors to easily teach and
demonstrate complex technical concepts and networking systems design.
The Packet Tracer software is available free of charge to Networking Academy instructors,
students, alumni, and administrators who are registered NetSpace users.
12. Psimulator2
web: https://code.google.com/p/psimulator/
Description: Psimulator2 is simple graphical linux and cisco network simulator created for
education purposes - learning IP networks basis. It allows building virtual network consisted of
linux and (basic) cisco routers and simple switches. Virtual network can be easily and quickly
created in graphical user interface. Network devices (linux and cisco routers) are configured via
command line over telnet protocol. Telnet client is included in GUI or different client (putty,
linux telnet) can be used. GUI is designed to capture and display packets in virtual network (like
Wireshark). Virtual network can be connected to real network.
157
13. Virtualsquare
web: http://wiki.virtualsquare.org/wiki/index.php/Main_Page
Description: Virtual Square is the name of a project that includes several software tools and
libraries. Its main goal is to create an unified environment that allows virtual machines, systems
and networks to communicate and interact.
web: http://web.dit.upm.es/vnxwiki/index.php/Main_Page
Description: VNX is a general purpose open-source virtualization tool designed to help building
virtual network testbeds automatically. It allows the definition and automatic deployment of
network scenarios made of virtual machines of different types (Linux, Windows, FreeBSD,
Olive or Dynamips routers, etc) interconnected following a user-defined topology, possibly
connected to external networks.
VNX has been developed by the Telecommunication and Internet Networks and Services (RSTI)
research group of the Telematics Engineering Department (DIT) of the Technical University of
Madrid (UPM).
VNX is a useful tool for testing network applications/services over complex testbeds made of
virtual nodes and networks, as well as for creating complex network laboratories to allow
students to interact with realistic network scenarios. As other similar tools aimed to create virtual
network scenarios (like GNS3, NetKit, MLN or Marionnet), VNX provides a way to manage
testbeds avoiding the investment and management complexity needed to create them using real
equipment.
158