0% found this document useful (0 votes)
2 views

Cn Lab Manual

The document outlines various computer networking experiments conducted in a lab setting, focusing on protocols such as Stop and Wait, Sliding Window, ARP/RARP, and socket programming. It includes objectives, concepts, Java programming examples, and procedures for each experiment, demonstrating client-server models and network troubleshooting commands like ping and traceroute. Additionally, it discusses the handling and configuration of networking hardware such as RJ-45 connectors and CAT-6 cables.

Uploaded by

Amitesh Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Cn Lab Manual

The document outlines various computer networking experiments conducted in a lab setting, focusing on protocols such as Stop and Wait, Sliding Window, ARP/RARP, and socket programming. It includes objectives, concepts, Java programming examples, and procedures for each experiment, demonstrating client-server models and network troubleshooting commands like ping and traceroute. Additionally, it discusses the handling and configuration of networking hardware such as RJ-45 connectors and CAT-6 cables.

Uploaded by

Amitesh Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

COMPUTER NETWORKS LAB (BCS-653)

Department of Information Technology

G. L. Bajaj Institute of Technology and Management,


Greater Noida
SESSION: 2024-25

Course: - B. Tech
Year: 3rd /6th Sem

SUBMITTED BY SUBMITTED TO
NAME: Amitesh Pandey NAME: Mr. Arun Kumar Takuli
Mr. Neeraj Chauhan
Section: A
Designation: Assistant Professor
Roll No: 2201920130025
Experiment – 01

Objective: Implementation of Stop and Wait Protocol and Sliding Window Protocol.
Concept:
It is the simplest flow control method. In this, the sender will transmit one frame at a time to the
receiver. The sender will stop and wait for the acknowledgement from the receiver.
This time (i.e. the time joining message transmitting and acknowledgement receiving) is the sender’s
waiting time, and the sender is idle during this time.
When the sender gets the acknowledgement (ACK), it will send the next data packet to the receiver
and wait for the disclosure again, and this process will continue as long as the sender has the data to
send.
While sending the data from the sender to the receiver, the data flow needs to be controlled. If the
sender is trans- mitting the data at a rate higher than the receiver can receive and process it, the data
will get lost.
The Flow-control methods will help in ensuring that the data doesn't get lost. The flow control
method will check that the senders send the data only at a rate that the receiver can receive and
process.
1. Error correction in Stop-and-Wait ARQ is done by keeping a copy of the sent frame and
retransmitting of the frame when the timer expires.
2. In Stop-and-Wait ARQ, we use sequence numbers to number the frames. The sequence
numbers are based on modulo-2 arithmetic
3. In Stop-and-Wait ARQ, the acknowledgment number always announces in modulo-2
arithmetic the se- quence number of the next frame expected.

Sliding Window Protocol in Computer Network


Sliding window protocols are data link layer protocols for reliable and sequential delivery of data
frames. The sliding window is also used in Transmission Control Protocol.
In this protocol, multiple frames can be sent by a sender at a time before receiving an acknowledgment
from the receiver. The term sliding window refers to the imaginary boxes to hold frames. Sliding
window method is also known as windowing

Program in Java Sender.java

import java.io.*; import java.net.*; public class Sender{

Socket sender;

ObjectOutputStream out;
ObjectInputStream in; String packet,ack,str, msg; int n,i=0,sequence=0;

Sender(){} public void run(){ try{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("Waiting for Connection. .. "); sender = new Socket("localhost",2005);

sequence=0;

out=new ObjectOutputStream(sender.getOutputStream()); out.flush(); in=new

ObjectInputStream(sender.getInputStream());

str=(String)in.readObject(); System.out.println("reciver > "+str); System.out.println("Enter the


data to send. .. ");

packet=br.readLine(); n=packet.length();

do{ try{ if(i<n){

msg=String.valueOf(sequence); msg=msg.concat(packet.substring(i,i+1));

}else if(i==n){ msg="end";out.writeObject(msg);break;

}out.writeObject(msg); sequence=(sequence==0)?1:0;

out.flush();

System.out.println("data sent>"+msg); ack=(String)in.readObject();

System.out.println("waiting for ack. ... \n\n"); if(ack.equals(String.valueOf(sequence))){ i++;

System.out.println("receiver > "+" packet recieved\n\n");

}else{

System.out.println("Time out resending data ... \n\n"); sequence=(sequence==0)?1:0;

}}catch(Exception e){}

}while(i<n+1);

System.out.println("All data sent. exiting.");

}catch(Exception e){}

finally{ try{ in.close(); out.close(); sender.close();

} catch(Exception

e){}
}} public static void main(String args[]){ Sender s=new Sender(); s.run(); }}

Receiver.java import java.io.*; import java.net.*; public class Receiver{

ServerSocket reciever;

Socket connection=null;

ObjectOutputStream out;
ObjectInputStream in; String packet,ack,data=""; int i=0,sequence=0; Receiver(){} public void
run(){ try{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); reciever = new
ServerSocket(2005,10); System.out.println("waiting for connection...");
connection=reciever.accept(); sequence=0;
System.out.println("Connection established :"); out=new
ObjectOutputStream(connection.getOutputStream()); out.flush();

in=new ObjectInputStream(connection.getInputStream()); out.writeObject("connected .");

do{ try{

packet=(String)in.readObject();
if(Integer.valueOf(packet.substring(0,1))==sequence){ data+=packet.substring(1);
sequence=(sequence==0)?1:0;

System.out.println("\n\nreceiver>"+packet);

} else

System.out.println("\n\nreceiver>"+packet +" duplicate data");

}if(i<3){ out.writeObject(String.valueOf(sequence));i++;

}else{
out.writeObject(String.valueOf((sequence+1)%2)); i=0; }} catch(Exception e){}
}while(!packet.equals("end")); System.out.println("Data recived="+data);
out.writeObject("connection ended .");

}catch(Exception e){} finally{ try{in.close();

out.close(); reciever.close();
} catch(Exception

e){}

}} public static void main(String args[]){ Receiver s=new Receiver(); while(true){

s.run();

RESULT:

Thus, the program is executed successfully and the output is verified.


Experiment – 02

Objective: Study of Socket Programming and Client – Server model

Concept:
The client–server model of computing is a distributed application structure that partitions tasks or
workloads between the providers of a resource or service, called servers, and service requesters, called
clients. Often clients and servers communicate over a computer network on separate hardware, but
both client and server may reside in the same system. A server host runs one or more server programs
which share their resources with clients. A client does not share any of its resources, but requests a
server's content or service function. Clients therefore initiate communication sessions with servers
which await incoming requests.

PROCEDURE:
In main window, enter Cd network, Cd layer, Cd Phy_Lyr , ./main Choose Layers - Transport Layer -
Socket - UDP. After choosing UDP protocol, Click on “Let’s Begin” button on both the systems. To
start the server, click on the Server Socket. Click on the Bind button, which will bind the socket. To
start the Client, first enter the IP Address of a machine where the server is listening. Enter the file name
as a request as shown in Screen. Click on socket to initiate the client socket. Click on the bind option.
Click on the Send To button to write the request. Click on the Recv From button, which will be
highlighted upon receiving a request in server system. Click on the Send To button to write the file
contents in the server system. Click on Recv From button in the client system to read the contents of
the file. Observe the text for the output of the file as shown in Screen.

Java Programming:

Client-Side Program:

package Networking; import


java.net.*; import java.io.*; public class
MyClient { public static void
main(String[] args) {
System.out.println("This is my Client Site program");

try {
Socket soc = new Socket("localhost",6666);
ObjectOutputStream out = new ObjectOutputStream(soc.getOutputStream());

out.writeUTF("Hello Server");
out.flush(); out.close();
soc.close();
}
catch(Exception e)
{
System.out.println(e);
}}
Server-Side Program:

package Networking; import


java.net.*; import java.io.*; public class
MyServer { public static void
main(String[] args) {
System.out.println("This is my Server Site program"); try {
ServerSocket sos = new ServerSocket(6666);
Socket soc = sos.accept();
ObjectInputStream ois = new ObjectInputStream(soc.getInputStream());
String str = (String)ois.readUTF();
System.out.println("Message ="+str); sos.close();
}

catch(Exception e)
{
System.out.println(e);
}
}
}

OUTPUT:

This is my Server Site program


Message =Hello Server
EXPERIMENT - 3

Objective:
To write a program for simulating arp/rarp protocols

ALGORITHM:
server
1. Create a server socket and bind it to port.
2. Listen for new connection and when a connection arrives, accept it.
3. Send server‟s date and time to the client.
4. Read client‟s IP address sent by the client.
5. Display the client details.
6. Repeat steps 2-5 until the server is terminated.
7. Close all streams.
8. Close the server socket.
9. Stop.

Client
1. Create a client socket and connect it to the server‟s port number.
2. Retrieve its own IP address using built-in function.
3. Send its address to the server.
4. Display the date & time sent by the server.
5. Close the input and output streams.
6. Close the client socket.
7. Stop.

(i)Program for Address Resolutuion Protocol (ARP) using TCP

Client: import java.io.*; import java.net.*; import java.util.*; class


Clientarp
{ public static void main(String
args[])
{ try {
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
Socket clsct=new Socket("127.0.0.1",139);
DataInputStream din=new DataInputStream(clsct.getInputStream());
DataOutputStream dout=new DataOutputStream(clsct.getOutputStream());
System.out.println("Enter the Logical address(IP):"); String str1=in.readLine(); dout.writeBytes(str1+'\n');
String str=din.readLine();
System.out.println("The Physical Address is: "+str); clsct.close();
} catch (Exception
e)
{
System.out.println(e);
}
}
}

Server: import java.io.*; import java.net.*; import


java.util.*;

class Serverarp
{ public static void main(String
args[])
{ try
{
ServerSocket obj=new ServerSocket(139);
Socket obj1=obj.accept(); while(true) {
DataInputStream din=new DataInputStream(obj1.getInputStream());
DataOutputStream dout=new DataOutputStream(obj1.getOutputStream()); String
str=din.readLine();
String ip[]={"165.165.80.80","165.165.79.1"}; String mac[]={"6A:08:AA:C2","8A:BC:E3:FA"}; for(int
i=0;i<ip.length;i++)
{ if(str.equals(ip[i]))
{ dout.writeBytes(mac[i]+'\n'); break; } }
obj.close();
} } catch(Exception
e)
{
System.out.println(e);
}
}
}

(ii)Program for Reverse Address Resolutuion Protocol (RARP) using UDP

Client:
import java.io.*; import java.net.*; import java.util.*; class Clientrarp12
{ public static void main(String
args[])
{ try
{
DatagramSocket client=new DatagramSocket(); InetAddress addr=InetAddress.getByName("127.0.0.1");
byte[] sendbyte=new byte[1024]; byte[] receivebyte=new byte[1024]; BufferedReader in=new
BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the Physical address (MAC):");
String str=in.readLine(); sendbyte=str.getBytes();
DatagramPacket sender=new
DatagramPacket(sendbyte,sendbyte.length,addr,1309); client.send(sender);
DatagramPacket receiver=new DatagramPacket(receivebyte,receivebyte.length); client.receive(receiver);
String s=new String(receiver.getData());
System.out.println("The Logical Address is(IP): "+s.trim()); client.close();
} catch(Exception
e)
{
System.out.println(e);
}
}
}

Server:
import java.io.*; import java.net.*; import java.util.*; class Serverrarp12
{ public static void main(String
args[])
{ try
{
DatagramSocket server=new DatagramSocket(1309); while(true) { byte[]
sendbyte=new byte[1024]; byte[] receivebyte=new byte[1024];
DatagramPacket receiver=new
DatagramPacket(receivebyte,receivebyte.length);
server.receive(receiver);
String str=new String(receiver.getData());
String s=str.trim();
//System.out.println(s);
InetAddress addr=receiver.getAddress(); int port=receiver.getPort();

String ip[]={"165.165.80.80","165.165.79.1"}; String mac[]={"6A:08:AA:C2","8A:BC:E3:FA"}; for(int


i=0;i<ip.length;i++)
{ if(s.equals(mac[i]))
{ sendbyte=ip[i].getBytes();
DatagramPacket sender=new
DatagramPacket(sendbyte,sendbyte.length,addr,port); server.send(sender); break; } } break; } }
catch(Exception e)
{
System.out.println(e);
}
}
}

Conclusion: Successfully simulated arp/rarp protocol.


EXPERIMENT - 4

Objective: To Write The java program for simulating ping and traceroute commands.

Concept:

PING Command

The ping command is a very common method for troubleshooting the accessibility of devices.
It uses a series of Internet Control Message Protocol (ICMP) Echo messages to determine:
1.Whether a remote host is active or inactive.
2.The round-trip delay in communicating with the host.
3.Packet loss.

The ping command first sends an echo request packet to an address, and then waits for a reply.
The ping is successful only if:
1.The echo request gets to the destination, and
2.The destination is able to get an echo reply back to the source within a predetermined time called a
timeout. The default value of this timeout is two seconds on Cisco routers.

TRACEROUTE Command

1.The trace route command is used to discover the routes that packets actually take when traveling to their
destination. The device (for example, a router or a PC) sends out a sequence of User Datagram Protocol
(UDP) data grams to an invalid port address at the remote host.
2.Three data grams are sent, each with a Time-To-Live (TTL) field value set to one. The TTL value of 1
causes the datagram to “timeout” as soon as it hits the first router in the path; this router then responds
with an ICMP Time Exceeded Message (TEM) indicating that the datagram has expired.
3.Another three UDP messages are now sent, each with the TTL value set to 2, which causes the second
router to return ICMP TEMs. This process continues until the packets actually reach the other destination.
4.Since these data grams are trying to access an invalid port at the destination host, ICMP Port
Unreachable Messages are returned, indicating an unreachable port; this event signals the Trace route
program that it is finished.

ALGORITHM:

1.Start the program.


2.Get the frame size from the user
3.To create the frame based on the user request.
4.To send frames to server from the client side.
5.If your frames reach the server it will send ACK signal to client otherwise it will send NACK signal to
client. 6.Stop the program
Program:

//pingclient.java import java.io.*; import java.net.*; import java.util.Calendar; class pingclient


{
public static void main(String args[])throws Exception {
String str; int c=0;
long t1,t2;
Socket s=new Socket("127.0.0.1",5555);
DataInputStream dis=new DataInputStream(s.getInputStream()); PrintStream out=new
PrintStream(s.getOutputStream()); while(c<4)
{
t1=System.currentTimeMillis();
str="Welcome to network programming world"; out.println(str);
System.out.println(dis.readLine()); t2=System.currentTimeMillis();
System.out.println(";TTL="+(t2-t1)+"ms"); c++;
}
s.close();
}
}
//pingserver.java import java.io.*; import java.net.*; import java.util.*; import java.text.*; class
pingserver
{
public static void main(String args[])throws Exception {
ServerSocket ss=new ServerSocket(5555);
Socket s=ss.accept();
int c=0; while(c<4)
{
DataInputStream dis=new DataInputStream(s.getInputStream());
PrintStream out=new PrintStream(s.getOutputStream());
String str=dis.readLine();
out.println("Reply from"+InetAddress.getLocalHost()+";Length"+str.length()); c++;
}
s.close();
}
}

Conclusion: Simulated the ping and traceroute commands.


EXPERIMENT - 5

Objective: To learn handling and configuration of networking hardware like RJ-45 connector, CAT-6
cables, crimping tool, etc.

Apparatus (Components): RJ-45 connector, Crimping Tool, Twisted pair Cable.

Brief Theory
RJ 45- Registered Jack 45 (RJ45) is a standard type of physical connector for network cables. RJ45
connectors are most commonly seen with Ethernet cables and networks. Modern Ethernet cables feature
small plastic plugs on each end that are inserted into the RJ45 jacks of Ethernet devices.

CAT-6 Cable- Category 6 Cable (Cat 6), is a standardized twisted pair cable for Ethernet and other
network physical layers.

Crimping Tool- Crimping Tool is a device used to conjoin two pieces of metal by deforming one or both
of them in a way that causes them to hold each other.

Result: Configuration of networking hardware like RJ-45 connector, CAT-6 cable, crimping tool, etc. is
learned
EXPERIMENT - 6

Objective: Configuration of router, hub, switch etc. (using real devices or simulators).
Apparatus (Components): Cisco Packet Tracer

Procedure:
Configuration of Hub using Star Topology
Step 1: Open Cisco packet Tracer Software and choose Generic Hub on workspace.
Step 2: Now choose end device as Generic. Connect end devices with Hub (Choose automatic
connection type).
Step 3 - Now click on each end device and enter IP address such as 10.0.0.1 and label the device with
corresponding IP address using text tool available in cisco packet tracer.
Step 4: Now select Simple Message(PDU) from right side of window and click over sender
node and on receiver node.
Step 5: Now click on simulation and click on AutoPlay to see effect.

Configuration of Switch using Star Topology


Step 1: Open cisco packet tracer and choose generic switch on workspace.
Step 2: Now choose end device as generic. Connect end devices with switch.
Step 3: Now click on simulation and click on AutoPlay to see effect.

Configuration of Roter

Step 1: Open Cisco Packet Tracer software and then click on Router and then over Generic, then drag it
over workspace.
Step 2: Design topology as shown in the diagram above.
Step 3: Now click on each end device and enter IP address such as 10.0.0.1 and label the device with
corresponding IP address using text tool available in cisco packet tracer. Be ensure that router should
connect two different networks.

Step 4: Double click router and type router commands to configure router at interface fa0/0 and fa0/1
Router>enable
Router#configure terminal
Router(config)#hostname R1
Router(config)#interface fastethernet 0/0
Router(config-if)# 10.0.0.1 255.0.0.0
Router(config-if)# no shut down

Step 5: Now select Simple Message from right side of window and click over sender node and on receiver
node.
Step 6: Now click on simulation and click on AutoPlay to see effect.

Result: Configuration of router, hub, switch is performed.


EXPERIMENT - 7

Objective: Running and using services/commands like ping, traceroute, nslookup, arp, telnet, ftp, etc.
Apparatus (Components): Cmd, Cisco Packet Tracer
Procedure: In this experiment students must understand basic networking commands e.g. ping, tracert
etc.
All commands related to Network configuration which includes how to switch to privilege mode and
normal mode and how to configure router interface and how to save this configuration to flash memory or
permanent memory.
This command includes
• Configuring the Router commands • General Commands to configure network • Privileged Mode
commands of a router Router Processes &amp; Statistics IP Commands • Other IP Command e.g. show ip
route etc.
ping:
Verifies IP-level connectivity to another TCP/IP computer by sending Internet Control Message Protocol
(ICMP) Echo Request messages. The receipt of corresponding Echo Reply messages is displayed, along
with round-trip times. Ping is the primary TCP/IP command used to troubleshoot connectivity,
reachability, and name resolution.

You can use ping to test both the computer name and the IP address of the computer. If pinging the IP
address is successful, but pinging the computer name is not, you might have a name Cesolution problem.
In this case, ensure that the computer name you are specifying can b resolved through the local Hosts file,
by using Domain Name System (DNS) queries, or through NetBIOS name resolution techniques.

Traceroute:
Determines the path taken to a destination by sending Internet Control Message Protocol
(ICMP) Echo Request messages to the destination with incrementally increasing Time to Live (TTL) field
values. The path displayed is the list of near-side router interfaces of the routers in the path between a
source host and a destination. The near-side interface is the interface of the router that is closest to the
sending host in the path. Used without parameters, tracert displays help.
To trace the path to the host named www.google.co.in use following command

tracert www.google.co.in
Arp:
Displays and modifies entries in the Address Resolution Protocol (ARP) cache, which contains one or
more tables that are used to store IP addresses and their resolved Ethernet or Token Ring physical
addresses. There is a separate table for each Ethernet or Token Ring network adapter installed on your
computer.
To display the ARP cache tables for all interfaces use following command
arp -a

Nslookup (stands for "Name Server Lookup") is a useful command for getting information from DNS
server. It is a network administration tool for querying the Domain Name System (DNS) to obtain domain
name or IP address mapping or any other specific DNS record. It is also used to troubleshoot DNS related
problems.

Netstat:
Displays active TCP connections, ports on which the computer is listening, Ethernet statistics,
the IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for the
IPv6, ICMPv6, TCP over IPv6, and UDP over IPv protocols).

Result: Successfully ran and used services/commands like ping, traceroute, nslookup, arp, telnet, ftp, etc.
EXPERIMENT - 8

Objective: Network packet analysis using tools like Wireshark, tcpdump, etc.
Apparatus (Components): Wireshark, tcpdump

1. TCPDUMP:
The fundamental tool of almost all network traffic collection is tcpdump. It is an open-source application
that comes installed on almost all Unix-like operating systems. Tcpdump is an excellent collection tool
and comes complete with a very complex filtering language. It's important to know how to filter the data
at collection time in order to end up with a manageable chunk of data to analyze. Capturing all data from
a network device on even a moderately busy network can create too much data to analyze easily.
In some rare cases, allowing tcpdump to output its capture directly to your screen may be enough to find
what you're looking for. For example, in writing this article, I captured some traffic and noticed that my
machine was sending traffic to an IP I did not recognize. It turns out that my machine was sending data to
a Google IP address of 172.217.11.142. Since I did not have any Google products running, nor Gmail
open, I did not know why this was happening. I examined my system and found this:
[~]$ ps -ef | grep google
user 1985 1881 0 10:16? 00:00:00/opt/google/chrome/chrome --type-service
It seems that even when Chrome not running in the foreground it remains running as a service. I would
not have necessarily noticed this without a packet analysis to tip me off. I re- captured some more
tcpdump data but this time told tcpdump to write the data to a file that I opened in Wireshark (more on
that later).

Tcpdump is a favorite tool among sysadmins because it is a command-line tool. This means that it doesn't
require a full-blown desktop to run. It is unusual for production servers to provide a desktop because of
the resources that would take, so command-line tools are preferred. As with many advanced tools,
tcpdump has a very rich and arcane language that takes some time to master. A few of the very basic
commands involve selecting the network interface from which to collect data, and writing that data to a
file so it can be exported for analysis elsewhere. The -i and -w switches are used for this.
# tcpdump -i eth0 -w tcpdump_packets
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes "C51 packets
captured
This produces a capture file:
file tcpdump_packets
tcpdump packets: tcpdump capture file (little-endian) - version 2.4 (Ethernet, capture length 262144)
The standard TCP capture file is a pcap file. It is not text so it can only be read by an analysis program
that knows how to read pcap files.
2. WinDump
Most useful open source tools are eventually cloned to other operating systems. When this happens, the
application is said to have been ported over. Windump is a port of tcpdump and behaves in very similar
ways.
One major difference between WinDump and tcpdump is that Windump needs the WinpCap library
installed prior to being able to run WinDump. Despite both WinDump and WinpCap being provided by
the same maintainer, they are separate downloads.
WinpCap is an actual library that needs to be installed. But, once it is installed, WinDump is an .exe file
that needs no installation so it can just run. That may be something to keep in mind if you're running a
Windows network. You don't necessarily need WinDump installed on every machine since you can just
copy it over as needed, but you will want WinpCap installed in order to support WinDump.
As with tcpdump, WinDump can output network data to the screen for analysis, be filtered in the same
way, and also write data to a pcap file for analysis offsite.
3. Wireshark
wireshark is probably the next best-known tool in any sysadmin's toolkit. It can not only capture data, but
also provides some advanced analysis tools. Adding to its appeal, Wireshark is open source, and has been
ported over to almost every server operating system that exists. Starting life named Etheral, Wireshark
now runs everywhere, including as a standalone portable app.
If you're analyzing traffic on a server with a desktop installed, Wireshark can do it all for you. It can
collect the data, and then analyze it all in one spot. However, desktops are not common on servers, so in
many cases, you'll want to capture the network data remotely and then pull the resulting pcap file into
Wireshark.
At first launch, Wireshark allows you to either load an existing pcap file, or start capturing. If you elect to
capture network traffic, you can optionally specify filters to pare down the amount of data Wireshark
collects. Since its analysis tools are so good, it's less important to ensure you surgically identify the data
at collection time with Wireshark. If you don't specify a filter, Wireshark will simply collect all network
data that your selected interface observes.

Result: Network packet analysis using tools like Wireshark, tcpdump, etc. is done and understood.
EXPERIMENT - 9

Objective: Network simulation using tools like Cisco Packet Tracer, NetSim, OMNeT++, NS2, NS3, etc.
Apparatus (Components): Wireshark, tcpdump

Brief Theory:
Network simulation- In computer network research, network simulation is a technique whereby a
software program models the behavior of a network by calculating the interaction between the different
network entities.

Cisco Packet Tracer- Packet Tracer allows users to create simulated network topologies by dragging and
dropping routers, switches and various other types of network devices. A physical connection between
devices is represented by a 'cable' item. Cisco Systems claims that Packet Tracer is useful for network
experimentation.

NetSim-NetSim is an end-to-end, full stack, packet level network simulator and emulator. It provides
network engineers with a technology development environment for protocol modeling, network R&D and
military communications.
A network simulator enables users to virtually create a network comprising of devices, links, applications
etc, and study the behavior and performance of the Network.

Some example applications of network simulators are


• Protocol performance analysis
• Application modeling and analysis
• Network design and planning
• Research and development of new networking technologies
• Test and verification
The typical steps followed when simulating any network are:
Building the model - Create a network with devices, links, applications etc
Running the simulation - Run the discrete event simulation (DES) and log different performance metrics
Visualizing the simulation - Use the packet animator to view the flow of packets
Analyzing the results - Examine output performance metrics such as throughput, delay, loss etc. at
multiple levels - network, link, queue, application etc.
Developing your own protocol / algorithm - Extend existing algorithms by modifying the simulator's
source C code.

OMNeT++ - OMNeT++ (Objective Modular Network Testbed in C++)is a modular, component-based


C++ simulation library and framework, primarily for building network simulators.OMNeT++ itself is a
simulation framework without models for network protocols like IP or HTTP. The main computer
network simulation models are available in several external frameworks. The most commonly used one is
INETwhich offers a variety of models for all kind of network protocols and technologies like for IPv6,
BGP etc. INET also offers a set of mobility models to simulate the node movement in simulations. The
INET models are licensed under the LGPL or GPL.

Components
The main ingredients of OMNeT++ are:
• Simulation kernel library (C++)
• The NED topology description language
• Simulation IDE based on the Eclipse platform
• Interactive simulation runtime GUI (Qtenv)
• Command-line interface for simulation execution (Cmdenv) Utilities (makefile creation tool, etc.)
• Documentation, sample simulations, etc.

NS2- NS2 stands for Network Simulator Version 2. It is an open-source event-driven simulator designed
specifically for research in computer communication networks.Ns2 is an event driven simulator, which is
a open source simulator mainly used for academic research in the areas of Computer Networks,
MANETS, WSNs.NS-2 can be used to implement 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 and many more. In ns2, C++ is used for detailed protocol
implementation and Otel is used for the setup.

Features of NS2
1. It is a discrete event simulator for networking research.
2. It provides substantial support to simulate bunch of protocols like TCP, FTP, UDP, https and DSR.
3. It simulates wired and wireless network.
4. It is primarily Unix based.
5. Uses TCL as its scripting language.
6. Otel: Object oriented support
7. Telcl: C++ and otel linkage
8. Discrete event scheduler

NS3- Computer network simulation in the sense connection of two or more computer system linked
together for communication. Networking is the practice of interfacing two or more computing devices
with each other for the purpose of sharing data. Computer networks are built with a combination of
hardware and software.ns-3 is a discrete-event network simulator, 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.
NS-3 is intended to provide better support than in NS-2 for the following items:
• Modularity of components
• Scalability of simulations
• Integration/reuse of externally developed code and software utilities
• Emulation
• Tracing and statistics
• Validation

Result- Network simulation is done using tools like Cisco Packet Tracer, NetSim, OMNeT++, NS2, NS3,
etc.
EXPERIMENT - 10

Objective:
To implement socket programming date and time display from client to server using TCP
and UDP Sockets.

Concept:

Socket Programming
Sockets provide the communication mechanism between two computers. A client program
creates a socket on its end of the communication and attempts to connect that socket to a
server.
When the connection is made, the server creates a socket object on its end of the
communication.
The client and server can now communicate by writing to and reading from the socket.

Client–server model
The client–server model of computing is a distributed application structure that partitions
tasks or workloads between the providers of a resource or service, called servers, and service
requesters, called clients.
Often clients and servers communicate over a computer network on separate hardware, but
both client and server may reside in the same system.
A server host runs one or more server programs which share their resources with clients. A
client does not share any of its resources, but requests a server's content or service function.
Clients therefore initiate communication sessions with servers which await incoming
requests.

Examples of computer applications that use the client–server model are Email, network printing, and
the World Wide Web.

Algorithm:
Server:
Step1: Create a server socket and bind it to port.
Step 2: Listen for new connection and when a connection arrives, accept it.
Step 3: Send server’s date and time to the client.
Step 4: Read client’s IP address sent by the client.
Step 5: Display the client details.
Step 6: Repeat steps 2-5 until the server is
terminated. Step 7: Close the server socket.
Client
Step1: Create a client socket and connect it to the server’s port number.
Step2: Retrieve its own IP address using built-in function.
Step3: Send its address to the server.
Step4: Display the date & time sent by the server.
Step5: Close the client socket

TCP Program: dateserver.java //import java packages

import java.net.*; import java.io.*; importjava.util.*;


/*… Register service on port
8020…*/ ss=new
ServerSocket(8020);
/*… Wait and accept a connection…*/ s=ss.accept();
/*… Get a communication stream associated with the socket…*/
ps=new PrintStream(s.getOutputStream());
/* …To get system time…*/
Date d=new
Date(); ps.println(d);

dis=newDataInputStream(s.getInputStream());inet=dis.readLine(); System.out.println("THE
CLIENT SYSTEM ADDRESS IS :"+inet);
/* …This method is used to request for closing or terminating an
object…*/ ps.close();}} dateclient.java

/* …Socket class is having a constructor through this Client program can request to server to
get connection…*/ Socket soc;
DataInputStream dis;
String sdate;
PrintStreamps;
/*…getLocalHost() method: Returns the name of the local computer…*/
InetAddressia=InetAddress.getLocalHost();
/*… Open your connection to a server, at port 8020…*/ soc=new
Socket(ia,8020);
/*… Get an input file handle from the socket and read the input…*/
/*…getInputStream()-This method take the permission to write the data from client program
to server program and server program to client program…*/
dis=new DataInputStream(soc.getInputStream()); sdate=dis.readLine();
System.out.println("THE date in the server is:"+sdate);
/* …getOutputStream()-This method is used to take the permission to read data from client system
by the server or from the server system by the client…*/ ps=new
PrintStream(soc.getOutputStream()); ps.println(ia);}
UDP Program:

Server.java
/*…import java packages…*/ import java.net.*;
import java.io.*; importjava.util.*;
/*..receiving the packet from client…*/

DatagramPacketrp=new DatagramPacket(rd,rd.length); ss.receive(rp);


InetAddress ip= rp.getAddress(); int port=rp.getPort();
/*… getting system time…*/ Date d=new Date();
/*… converting it to String…*/ String
time= d + "";

/*… converting that String to byte…*/ sd=time.getBytes();


/*…sending the data to the client…*/

DatagramPacketsp=new DatagramPacket(sd,sd.length,ip,port); ss.send(sp);


Clientnew.java

/*…send the data to the server(data,length,ip address and port number)…*/


DatagramPacketsp=new DatagramPacket(sd,sd.length,ip,1234);
DatagramPacketrp=new DatagramPacket(rd,rd.length);
/*…To Send the data…*/

cs.send(sp); cs.receive(rp);
String time=new String(rp.getData()); System.out.println(time);
/*…This method is used to request for closing or terminating an object…*/ cs.close(); } }

Conclusion: Implemented socket programming date and time display from client to server using TCP
and UDP Sockets.
Exp 01 upar-> Exp 05 niche

Exp 06 eske niche


Now exp 7 eske baad
Now exp 8 eske baad
now exp 9 eske baad
now exp 10

You might also like