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

CN_record

The document is a record notebook for the CS3591 - Computer Networks course at the University College of Engineering, Nagercoil, detailing various experiments conducted during the academic year 2024-2025. It includes a list of experiments such as basic networking commands, HTTP web client implementation, echo client and server applications, and chat applications using TCP sockets. Each experiment outlines the aim, algorithm, and program code used for practical learning in computer networking.

Uploaded by

simba.mk71
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)
9 views

CN_record

The document is a record notebook for the CS3591 - Computer Networks course at the University College of Engineering, Nagercoil, detailing various experiments conducted during the academic year 2024-2025. It includes a list of experiments such as basic networking commands, HTTP web client implementation, echo client and server applications, and chat applications using TCP sockets. Each experiment outlines the aim, algorithm, and program code used for practical learning in computer networking.

Uploaded by

simba.mk71
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/ 74

UNIVERSITY COLLEGE OF ENGINEERING

NAGERCOIL
(ANNA UNIVERSITY CONSTITUENT COLLEGE)
KONAM, NAGERCOIL – 629 004

RECORD NOTE BOOK

CS3591 – COMPUTER NETWORKS

REGISTER NO:
UNIVERSITY COLLEGE OF ENGINEERING
NAGERCOIL
(ANNA UNIVERSITY CONSTITUENT COLLEGE)
KONAM, NAGERCOIL – 629 004

Register No:

Certified that, this is the bonafide record of work done by


Mr./Ms. ………………………………………………………. of V Semester in
Computer Science and Engineering of this college, in the
CS3591- Computer Networks during academic year 2024-2025
in partial fulfillment of the requirements of the B.E Degree course of
the Anna University Chennai.

Staff-in-charge Head of the Department

This record is submitted for the University Practical Examination


held on …………………………

Internal Examiner External Examiner


LIST OF EXPERIMENTS

Exp Page
No. Date Name of the Experiments No. Sign.

01 13-08-2024 Basic Networking Commands 01

02 27-08-2024 Implementation of HTTP Web Client to 08


download a web page using TCP Sockets

3A 03-09-2024 Implementation of Echo Client and Echo 10


Server Application using TCP Socket

3B 03-09-2024 Implementation of Chat Application Using 16


TCP Sockets

4 09-09-2024 Simulation of DNS Using UDP Socket 21

5 10-09-2024 Capturing and Examining the Packets using 25


Wireshark

6A 21-09-2024 Simulating ARP Protocol 39

6B 21-09-2024 Simulating RARP Protocol 43

7 01-10-2024 Study of Network Simulators (NS) and 47


Simulation of Congestion Control Algorithms
using NS

8 08-10-2024 Study of TCP/UDP Performance using 56


Simulation tool

9A 15-10-2024 Simulation of Distance Vector Routing 60


Algorithm

9B 15-10-2024 Simulation of Link State Routing Algorithm 64

10 22-10-2024 Simulation of an Error Correction Code 68


(Like CRC)
Exno:1 Basic Networking Commands
Date:13-08-24

Aim:
To learn to use commands like tcpdump, netstat, ifconfig, nslookup, and traceroute.
1. Tcpdump:
The tcpdump utility allows you to capture packets that flow within your network to
assist in network troubleshooting. The following are several examples of using tcpdump with
different options. Traffic is captured based on a specified filter.
Options Description
-D Print a list of network interfaces.

-i Specify an interface on which to capture


-c Specify the number of packets to receive
-v, -vv, -vvv Increase the level of detail (verbosity).

-w Write captured data to a file.


-r Read captured data from a file.

Many other options and arguments can be used with tcpdump. The following are some
specific examples of the power of the tcpdump utility.
1. Display traffic between 2 hosts
To display all traffic between two hosts (represented by variables host1 and host2):
#tcpdump host host1 and host2
2. Display traffic from a source or destination host only
To display traffic from only a source (src) or destination (dst) host:
#tcpdump src host
#tcpdump dst host
3. Display traffic for a specific protocol
Provide the protocol as an argument to display only traffic for a specific protocol, for
example tcp, udp, icmp, arp:
#tcpdump protocol
For example, to display traffic only for the tcp traffic:
#tcpdump tcp
4. Filtering based on source or destination port
To filter on source or destination port:
#tcpdump src port ftp
#tcpdump dst port http
2. Netstat
Netstat is a common command-line TCP/IP networking utility available in most versions of
Windows, Linux, UNIX, and other operating systems. Netstat provides information and
statistics about protocols in use and current TCP/IP network connections. The Windows help
screen analogous to a Linux or UNIX for netstat reads as follows:
Displays protocol statistics and current TCP/IP network connections.
NETSTAT -a -b -e -n -o -p proto -r -s -v -interval
-a Displays all connections and listening ports.
-b Displays the executable involved in creating each connection or
listening port. In some cases well-known executables host multiple
independent components, and in these cases the sequence of
components involved in creating the connection or listening port is
displayed. In this case the executable name is in [ ] at the bottom, on top
is the component it called, and so forth until TCP/IP was reached. Note
that this option can be time-consuming and will fail unless you have
sufficient permissions.
-e Displays Ethernet statistics. This may be combined with the -s option.
-n Displays addresses and port numbers in numerical form.
-o Displays the owning process ID associated with each connection.

-p proto Shows connections for the protocol specified by proto; proto may be
any of: TCP, UDP, TCPv6, or UDPv6. If used with the -s option to
display per-protocol statistics, proto may be any of: IP, IPv6, ICMP,
ICMPv6, TCP, TCPv6, UDP, or UDPv6.
-r Displays the routing table.
-s Displays per-protocol statistics. By default, statistics are shown for IP,
IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6; the -p option
may be used to specify a subset of the default.

-v When used in conjunction with -b, will display sequence of components


involved in creating the connection or listening port for all executables.

-interval Redisplays selected statistics, pausing interval seconds between each


display. Press CTRL+C to stop redisplaying statistics. If omitted, netstat
will print the current configuration information once.
3. Ipconfig
In Windows, ipconfig is a console application designed to run from the Windows
command prompt. This utility allows you to get the IP address information of a Windows
computer. It also allows some control over active TCP/IP connections. Ipconfig replaced the
older winipcfg utility.
Using ipconfig
From the command prompt, type ipconfig to run the utility with default options. The
output of the default command contains the IP address, network mask, and gateway for all
physical and virtual network adapters.
Syntax:
ipconfig [/all] [/renew [Adapter]] [/release [Adapter]] [/flushdns] [/displaydns] [/registerdns]
[/showclassid Adapter] [/setclassid Adapter [ClassID]]
Parameters Used Displays the IP address, subnet mask, and default gateway for all
without Parameters adapters.
/all Displays the full TCP/IP configuration for all adapters. Without this
parameter, ipconfig displays only the IP address, subnet mask, and
default gateway values for each adapter. Adapters can represent
physical interfaces, such as installed network adapters, or logical
interfaces, such as dial-up connections.
/renew [Adapter] Renews DHCP configuration for all adapters (if an adapter is not
specified) or for a specific adapter if the Adapter parameter is
included. This parameter is available only on computers with
adapters configured to automatically obtain an IP address. To
specify an adapter name, type the adapter name that appears when
you use ipconfig without parameters.
/release [Adapter] Sends a DHCPRELEASE message to the DHCP server to release
the current DHCP configuration and discard the IP address
configuration for either all adapters (if an adapter is not specified) or
for a specific adapter if the Adapter parameter is included. This
parameter is useful for adapters configured to obtain an IP address
automatically. To specify an adapter name, type the adapter name
that appears when you use ipconfig without parameters.
/flushdns Flushes and resets the contents of the DNS client resolver cache.
During DNS troubleshooting, you can use this procedure to discard
negative cache entries from the cache, as well as any other entries
that have been added dynamically.
/displaydns Displays the contents of the DNS client resolver cache, which
includes both entries preloaded from the Hosts file and any recently
obtained resource records for name queries resolved by the
computer. The DNS Client service uses this information to resolve
frequently queried names quickly, before querying its configured
DNS servers.
/registerdns Initiates manual dynamic registration for the DNS names and IP
addresses that are configured on a computer. You can use this
parameter to troubleshoot a failed DNS name registration or resolve
a dynamic update problem between a client and the DNS server
without restarting the client computer. The DNS settings on the
advanced properties of the TCP/IP protocol determine which names
are registered in DNS.
/showclassid Adapter Displays the DHCP class ID for a specified adapter. To see
the DHCP class ID for all adapters, use the asterisk (*) wildcard
character in place of the Adapter. This parameter is available only
on computers with adapters configured to automatically obtaining Ip
address
/setclassid Adapter [ClassID] Configures the DHCP class ID for a specified
adapter. To set the DHCP class ID for all adapters, use the asterisk
(*) wildcard character in place of the Adapter. This parameter is
available only on computers with adapters configured to
automatically obtain an IP address. If a DHCP class ID is not
specified, the current class ID is removed.
Example:
ipconfig To display the basic TCP/IP configuration for
all adapters.
ipconfig /all To display the full TCP/IP configuration for
all adapters.
ipconfig /renew To renew a DHCP-assigned IP address
"Local Area configuration for only the Local Area
Connection" Connection adapter.
ipconfig /flushdns To flush the DNS resolver cache when
troubleshooting DNS name resolution
problems.
ipconfig To display the DHCP class ID for all adapters
/showclassid Local with names that start with Local.
ipconfig /setclassid To set the DHCP class ID for the Local Area
"Local Area Connection adapter to TEST.
Connection" TEST
4. Nslookup
The nslookup (which stands for name server lookup) command is a network utility
program used to obtain information about internet servers. It finds name server information
for domains by querying the Domain Name System.

5. Traceroute
Traceroute is a network diagnostic tool used to track the pathway taken by a packet on
an IP network from source to destination. Traceroute also records the time taken for each hop
the packet makes during its route to the destination.
Traceroute uses Internet Control Message Protocol (ICMP) echo packets with variable
time-to-live (TTL) values. The response time of each hop is calculated. To guarantee
accuracy, each hop is queried multiple times (usually three times) to better measure the
response of that particular hop.
tracert www.google.com
With the tracert command shown above, we’re asking tracert to show us the path from the
local computer all the way to the network device with the hostname www.google.com.
Tracing route to www.google.com
[209.85.225.104] over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms 10.1.0.1
2 3 ms 19 ms 29 ms 98.245.140.1
3 1 ms 27 ms 9 ms te-0-3-0.dfw.comcast.net [68.85.105.201]
...
11 81 ms 76 ms 75 ms 209.85.241.37
14 84 ms 91 ms 87 ms 209.85.248.102
15 76 ms 112 ms 76 ms y-f104-le100.net [209.85.225.104]
Trace complete.
tracert j 10.12.0.1 10.29.3.1 10.44.1 www.google.com
Result:
Thus the basic networking commands were executed successfully.
Ex. No: 2
Implementation of HTTP web client to download a web page using TCP sockets
Date: 27-08-2024

Aim:
To write a java program for socket for HTTP for webpage upload and download.
Algorithm:
Step 1: Start.
Step 2: Get the frame size from the user.
Step 3: To create the frame based on the user request.
Step 4: To send frames to server from client side.
Step 5: If your frames reach the server, it will send ACK signal to client otherwise, it
will send NACK signal to client.
Step 6: Stop.

Program:
import java.io.*;
import java.net.*;
public class SocketHTTPClient
{
public static void main(String[] args)
{
String hostName="www.google.com";
int portNumber=80;
try
{
Socket socket=new Socket(hostName,portNumber);
PrintWriter out=new PrintWriter(socket.getOutputStream(),true);
BufferedReader in=new BufferedReader(new InputStreamReader(socket.getInputStream()));
out.println("GET/HTTP/1.1\nHost:www.google.com\n\n");
String inputLine;
while((inputLine=in.readLine())!=null)
{
System.out.println(inputLine);
}
}
catch(IOException e)
{
System.out.println("Couldn't get I/O for the connection to "+hostName);
System.exit(1);
}
}
}
Output:

Result:
Thus the program for creating sockets HTTP web page to download was implemented successfully.
Implementation of Echo Client and Echo Server Application
Ex No : 3A
Date : 03-09-2024 Using TCP Socket

Aim :
To write a program to develop application using TCP sockets like Echoclient and Echoserver.

Algorithm :

Step 1: Start.
Step 2: Get the frame size from the user.
Step 3: To create the frame based on the user request.
Step 4: To send frames to server from the client side.
Step 5: If your frames reach the server it will send ACK signal to the client otherwise it will
send NACK signal to client.
Step 6: Stop.
Program :
Echoclient.java
import java.io.*;
import java.net.*;
public class Echoclient{
public static void main(String[] args){
try{
Socket s=new Socket("127.0.0.1",9999);
BufferedReader r=new BufferedReader(new InputStreamReader(s.getInputStream()));
PrintWriter w=new PrintWriter(s.getOutputStream(),true);
BufferedReader con= new BufferedReader(new InputStreamReader(System.in));
String line;
do{
{
line=r.readLine();
if(line!=null)
System.out.println(line);
line=con.readLine();
w.println(line);
}
}
while(!line.trim().equals("bye"));
}catch(Exception err){
System.err.println(err);
}
}
}
Echoserver.java
import java.io.*;
import java.net.*;
public class Echoserver{
public Echoserver(int portnum){
try{
server=new ServerSocket(portnum);
}
catch(Exception err)
{
System.out.println(err);
}
}
public void server(){
try{
while(true)
{
Socket client=server.accept();
BufferedReader r=new BufferedReader(new InputStreamReader(client.getInputStream()));
PrintWriter w=new PrintWriter(client.getOutputStream(),true);
w.println("Welcome to the java Echoserver type bye to close");
String line;
do{
line=r.readLine();
if(line!=null)
w.println("GOT:"+line);
System.out.println(line);
}
while(!line.trim().equals("bye"));
client.close();
}
}
catch(Exception err)
{
System.err.println(err);
}
}
public static void main(String[] args){
Echoserver echoserver=new Echoserver(9999);
echoserver.server();
}
private ServerSocket server;
}
Output :
Result :
Thus a program to develop an application using TCP sockets like Echoclient and Echo server
was written and executed successfully.
Ex No : 3B IMPLEMENTATION OF CHAT APPLICATION USING TCP SOCKETS
Date : 03/09/2024

Aim :
To implement a chat application using TCP socket.

Concept :

1.) It uses TCP sockets communication. We have a server as well as a client.


2.) Both can be run in the same machine or different machines, the address to be given at the
client side is local host address.
3.) If both are running in different machines, then in the client side we need to specify the
IP address of machine in which server application is running.
Program :
chatserver.java
import java.net.*;
import java.io.*;
public class chatserver
{
public static void main(String args[])throws Exception
{
ServerSocket ss=new ServerSocket(2000);
Socket sk=ss.accept();
BufferedReader cin=new BufferedReader(new InputStreamReader(sk.getInputStream()));
PrintStream cout=new PrintStream(sk.getOutputStream());
BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
String s;
while(true)
{
s=cin.readLine();
if(s.equalsIgnoreCase("END"))
{
cout.println("BYE");
break;
}
System.out.print("Client:"+s+"\n");
System.out.print("Server:");
s=stdin.readLine();
cout.println(s);
}
ss.close();
sk.close();
cin.close();
cout.close();
stdin.close();
}
}

chatclient.java
import java.net.*;
import java.io.*;
public class chatclient
{
public static void main(String args[])throws Exception{
Socket sk=new Socket("127.0.0.1",2000);
BufferedReader sin=new BufferedReader(new InputStreamReader(sk.getInputStream()));
PrintStream sout=new PrintStream(sk.getOutputStream());
BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
String s;
while(true)
{
System.out.print("Client::");
s=stdin.readLine();
sout.println(s);
s=sin.readLine();
System.out.print("Server:"+s+"\n");
if(s.equalsIgnoreCase("BYE"))
break;
}
sk.close();
sin.close();
sout.close();
stdin.close();
}
}
Output :
Result:
Thus the program for chat application using TCP socket was written and executed successfully.
EX.NO: 4
Simulation of DNS Using UDP Sockets
DATE:09/09/24

AIM:

To write a java program stimulation of DNS using UDP Sockets.

ALGORITHM:

Step 1: Start
Step 2: Get the frame size from the user.
Step3: To create the frame based on the user request
Step 4: To send frames to server from the client side.
Step 5: If your frames reach the server it will send Ack signal to client otherwise it will
Send Send NACK signal to client.
Step 6: Stop.
PROGRAM:

UDP DNS Server:

import java.io.*;
import java.net.*;
public class DNSServer {
private static int indexOf(String[] array, String str) {
str = str.trim();
for (int i = 0; i < array.length; i++) {
if (array[i].equals(str)) return i;
}
return -1;
}
public static void main(String args[]) throws IOException {
String[] hosts = {"zoho.com", "gmail.com", "google.com", "facebook.com"};
String[] ip = {"172.28.251.59", "172.217.11.5", "172.217.11.14", "31.13.71.36"};
System.out.println("Press Ctrl + C to Quit");
DatagramSocket serverSocket = new DatagramSocket(1362);
byte[] sendData = new byte[1021];
byte[] receiveData = new byte[1021];
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
while (true) {
serverSocket.receive(receivePacket);
String sentence = new String(receivePacket.getData());
InetAddress ipAddress = receivePacket.getAddress();
int port = receivePacket.getPort();
System.out.println("Request for host " + sentence);
if (indexOf(hosts, sentence) != -1) {
String capsent = ip[indexOf(hosts, sentence)];
sendData = capsent.getBytes();
} else {
String capsent = "Host Not Found";
sendData = capsent.getBytes();
}
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length,
ipAddress, port);
serverSocket.send(sendPacket);
}
}
}
UDP DNS Client:

import java.io.*;
import java.net.*;
public class DNSClient {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
DatagramSocket clientSocket = new DatagramSocket();
InetAddress ipAddress;
if (args.length == 0) {
ipAddress = InetAddress.getLocalHost();
} else {
ipAddress = InetAddress.getByName(args[0]);
}
byte[] sendData = new byte[1024];
byte[] receiveData = new byte[1024];
int portAddr = 1362;
System.out.print("Enter the hostname: ");
String sentence = br.readLine();
sendData = sentence.getBytes();
DatagramPacket packet = new DatagramPacket(sendData, sendData.length, ipAddress,
portAddr);
clientSocket.send(packet);
DatagramPacket receivePacket = new DatagramPacket(receiveData,
receiveData.length);
clientSocket.receive(receivePacket);
String modified = new String(receivePacket.getData());
System.out.println("IP Address: " + modified);
clientSocket.close();
}
}
OUTPUT:

UDP DNS Server:

UDP DNS Client:

RESULT:

Thus the program for DNS application using UDP socket was executed successfully.
Ex No: 05 Capturing and Examining the Packets using Wireshark

Date: 10-09-2024

Aim:
To capture and examine the packets using the wireshark tool.

Installation of Wireshark Software


Below are the steps to install the Wireshark software on the computer.
• Open the web browser.
• Search for ‘Download Wireshark’
• Select the Windows installer according to your system configuration, either 32-bit or 64-
bit. Save the program and close the browser.
• Now, open the software, and follow the instructions by accepting the license.
• The Wireshark is ready for use.
• The version used here is 3.0.3. This version will open as:
• On the network and Internet settings option, we can check the interface connected to
our computer.

If you are a Linux user, you will find Wireshark in its package repositories.

By selecting the current interface, we can get the traffic traversing through that interface. The version used
here is 3.0.3. This version will open as:
The Wireshark software window is shown above, and all the processes on the network are carried
within this screen only.
The options given on the list are the Interface list options. A number of interface options will be
present. The selection of any option will determine all the traffic.

The above arrow shows the packet content written in hexadecimal or ASCII format.
And the information above the packet content is the details of the packet header.

It will continue listening to all the data packets, and you will get a lot of data. If you want to see a
particular data, then you can click on the red button. The traffic will be stationary, and you can note the
parameters like time, source, destination, the protocol being used, length, and the Info. To view in-depth
details, you can click on that particular address; a lot of the information will be displayed below that.

There will be detailed information on HTTP packets, TCP packets, etc. The red button is shown below:
The screen/interface of the Wireshark is divided into five parts:

o The first part contains a menu bar and the options displayed below it. This part is at the top
of the window. File and capture menu options are commonly used in Wireshark. The capture
menu allows you to start the capturing process. The File menu is used to open and save a
capture file.
o The second part is the packet listing window. It determines the packet flow or the captured
packets in the traffic. It includes the packet number, time, source, destination, protocol,
length, and info. We can sort the packet list by clicking on the column name.
o Next comes the packet header- a detailed window. It contains detailed information
about the components of the packets. The protocol info can also be expanded or
minimized according to the information required.
o The bottom window called the packet contents window, displays the content in
ASCII and hexadecimal format.
o At last, is the filter field which is at the top of the display. The captured packets on the
screen can be filtered based on any component according to your requirements. For
example, if we want to see only the packets with the HTTP protocol, we can apply
filters to that option. All the packets with HTTP as the protocol will only be displayed
on the screen, shown below:

You can also select the connection to which your computer is connected. For example, in this PC, we
have chosen the current network, i.e., the ETHERNET.

After connecting, you can watch the traffic below:


In the view option on the menu bar, we can also change the view of the interface. You can change
the number of things in the view menu. You can also enable or disable any option according to the
requirements.

There is a filter block below the menu bar, from where a large amount of data can be filtered. For
example, if we apply a filter for HTTP, only the interfaces with the HTTP will be listed.
If you want to filter according to the source, right-click on the source you want to filter select 'Apply
as Filter' and choose '...and filter.'

Steps for the permanent colorization are: click on the 'View' option on the menu bar and select
'Colouring Rules.' The table will appear like the image shown below:
For the network administrator job, advanced knowledge of Wireshark is considered a requirement. So,
it is essential to understand the concepts of the software. It contains these 20 default coloring rules
which can be added or removed according to the requirements.

Select the option 'View' and then choose 'Colorize Packet List,' which is used to
toggle the color on and off.

Basic Concepts of Network Traffic

IP Addresses: It was designed for the devices to communicate with each other on a local network or
over the Internet. It is used for host or network interface identification. It provides the location of the
host and the capacity to establish the path to the host in that network. Internet Protocol is the set of
predefined rules or terms under which the communication should be conducted. The types of IP
addresses are IPv4 and IPv6.

• IPv4 is a 32-bit address in which each group represents 8 bits ranging from 0 to 255.
• IPv6 is a 128-bit address.
IP addresses are assigned to the host either dynamically or static IP address. Most private users have
dynamic IP addresses while business users or servers have static IP addresses. Dynamic address changes
whenever the device is connected to the Internet.

Computer Ports: The computer ports work in combination with the IP address directing all outgoing
and incoming packets to their proper places. There are well-known ports to work with like FTP (File
Transfer Protocol), which has port no. 21, etc. All the port have the purpose of directing all packets in
the predefined direction.

Protocol: The Protocol is a set of predefined rules. They are considered as the standardized way of
communication. One of the most used protocols is TCP/IP. It stands for Transmission Control Protocol/
Internet Protocol.

OSI model: OSI model stands for Open System Interconnect. OSI model has seven layers,namely, the
Application layer, the Presentation layer, the Session layer, the Transport layer, the Network layer,
the Data link layer, and the physical layer. OSI model gives a detailed representation and explanation
of the transmission and reception of data through the layers. OSI model supports both connection less and
connection-oriented communication modes over the network layer. The OSI model was developed by the
ISO (International Standard Organization).

Most used Filters in Wireshark

Whenever we type any commands in the filter command box, it turns green if your command is correct.
It turns red if it is incorrect or the Wireshark does not recognize your command.
Wireshark packet sniffing

Wireshark is a packet sniffing program that administrators can use to isolate and troubleshoot problems on
the network. It can also be used to capture sensitive data like usernames and passwords. It can also be used
in the wrong way (hacking) to eavesdrop.

Packet sniffing is defined as the process of capturing the packets of data flowing across a computer network.
The Packet sniffer is a device or software used for the process of sniffing.

Below are the steps for packet sniffing:


o Open the Wireshark Application.
o Select the current interface. Here in this example, interface is Ethernet that we would
be using.
o The network traffic will be shown below, which will be continuous. To stop or watch
any particular packet, you can press the red button below the menu bar.

The above screen is blank, i.e.; there is no network traffic as of now.


Open the browser. In this example, we have opened the 'Internet Explorer.' You can choose any browser.

As soon as we open the browser, and type any address of the website, the traffic will start showing, and the
exchange of the packets will also start. The image for this is shown below:

The above process explained is called packet sniffing.

Username and password sniffing

It is the process used to know the passwords and usernames for the particular website. Let’s take an
example of gmail.com. Below are the steps:

o Open the Wireshark and select the suitable interface.


o Open the browser and enter the web address. Here, we have entered gmail.com, which
is highly secured. Enter your email address and the password. The image is shown
below:
o Now, go to the Wireshark and on the filters block, enter 'frame
contains gmail.com.' Then you can see some traffic.

o Right-click on the particular network and select 'Follow', and then 'TCP Stream.' You can see that
all the data is secured in the encrypted form.
In the arrow shown above, the 'show and save data as' has many choices. These options are- ASCII, C
Arrays, EBCDIC (Extended Binary Coded Decimal Interchange Code), etc. EBCDIC is used in
mainframe and mid-range IBM computer operating systems.

Wireshark Statistics

The Wireshark provides a wide domain of statistics. They are listed below:
I/O Graphs

It shows the graph for the network traffic. The graph will look similar but changes as per the traffic
involved. There is a table below the figure, which has some filters. Using the'+' sign, you can add more
filters and using the '-sign you can remove the existing filters.
You can also change the color. For every particular filter, you can add a coloured layer, which increases
the visibility of the graph.

The tick option under the 'Enabled,' displays the layer according to your requirements.

Result:
Thus the packets were successfully captured and examined using the Wireshark tool..
Ex No: 6A Simulating ARP Protocols
Date:21/9/24

Aim:
To write a program for simulating ARP protocols.

Algorithm:
Client:
Step 1: Start.
Step 2: Accept the socket connection is established between client and server.
Step 3: Get IP address to be connected into mac.
Step 4: Send this IP address to server.
Step 5: Server returns MAC address to client.

Server:

Step 1: Start.
Step 2: Accept the socket which is created by client.
Step 3: Server maintains table in which IP and corresponding MAC address.
Step 4: Read IP address which is send by client.
Step 5: Map the IP address woth MAC addresss and return the MAC address to client.
PROGRAM:
Clientarp:
import java.io.*;
import java.net.*;
public class Clientarp{
public static void main(String[] args){
try {
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
Socket sok = new Socket(“127.0.01”,5604);
BufferedReader din = new BufferedReader(new
InputStreamReader(sok.getInputStream()));
PrintWriter dout = new PrinterWriter(sok.getOutSTream(),true);
System.out.println(“Enter the logical address (IP):”);
String str1 = buff.readLine();
Dout.println(str1);
String str = din.readLine();
System.out.println(“The physical address is:” +str);
Sok.close();
}
Catch (Exception e){
System.out.println(e);
}
}
}

Serverarp:
import java.io.*;
import java.net.*;
public class Serverarp{
public static void main(String[] args){
try{
ServerSocket serverSocket = new ServerSocket(5604)){
System.out.println(“server is renning…”);
While (true){
try (Socket clientSocket = serverSocket.accept();
BufferedReader din = new BufferedReader(new
InputStreamReader(clientSocket.getOutputStream()));
DataOutputStream dout = new
DataOutputStream(clientSocket.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”};
boolean found = false;
for(int I =0; i<ip.length; i++){
if(Str.equals(ip[i])){
dout.writeBytes(mac[i]+’\n’);
found = true;
break;
}
}
if (!found){
dout.writeBytes(“IP not found\n”);
}
}
Catch (IOException e){
System.out.println(“Error handling client:”+e.getMessage());
}
}
}
Catch (IOException e){
System.out.println(“Server error:”+e.getMessage());
}
}
}
OUTPUT:

RESULT:
Thus the program to concurrency communicate using TCP Soclet
Was executed successfully.
Ex.No:8 STUDY OF TCP/UDP PERFORMANCE USING SIMULATION TOOL
Date: 08/10/2024

AIM:
To the study of TCP/UDP performance using Simulation tool.

TOOLS USED:
Opnet Simulator.

INTRODUCTION:

The transport layer protocols provide connection- oriented sessions and reliable data delivery
services. This paper seeks to reflect a comparative analysis between the two transport layer protocols,
which are TCP/IP and UDP/IP, as well to observe the effect of using these two protocols in a client server
network. The similarities and differences between TCP and UDP over the Internet are also presented in our
work. We implement a network structure using Opnet Modeler and finally, based on the practical results
obtained we present the conclusions-showing the difference between these two protocols and how they
work.

The transport layer is not just another layer. It is the heart of the whole protocol hierarchy. Its task is
to provide reliable, cost-effective data transport from the source machine to the destination machine,
independently of the physical network or networks currently in use.

TCP and UDP are transport layer components that provide the connection point through which
applications access network services. TCP and UDP use IP, which is a lower-layer best effort delivery
service. IP encapsulates TCP packets and UDP datagrams and delivers this information across router-
connected internet works.

The ultimate goal of the transport layer is to provide efficient, reliable, and cost-effective service to
its users, normally processes in the application layer. To achieve this goal, the transport layer makes use of
the services provided by the network layer. Without the transport layer, the whole concept of layered
protocols would make little sense e.g. The Transport Layer prepares applications data for transport over the
network and processes network data to be used by applications. It is responsible for the end-to-end transfer
of data over the network and is the four of the OSI model. The Transport layer meets a number of
functions:

- enabling the applications to communicate over the network at the same time when using
a single device;

- ensure that all amount of data is receive by the correct application;

- responsible for fragmentation and reassembly;


- develop mechanism for handling errors

A big difference between TCP and UDP is the congestion control algorithm. For the TCP,
congestion algorithm prevents the sender from overrunning the network capacity, while TCP can adapt the
sender's rate with the network capacity and attempt to avoid potential congestions problems.

User Datagram Protocol (UDP), another transport protocol in IP networks, is described c.g. The
User Datagram Protocol (UDP) provides an unreliable connectionless delivery service using IP to transport
messages between machines e.g. [5]. It uses IP to carry messages, but adds the ability to distinguish among
multiple destinations within a given host computer. Is a connectionless protocol which doesn't provide flow
control, reliability or error recovery and the retransmissions of data in case of errors must be ordered by
other protocols. UDP is designed for applications that do not have to recompose the data segment that
arrives from the sender. In another way, application-level protocols are directly responsible for the security
of data transmitted.

Difference from the TCP is that there is no mechanism for error detections. If applications that use
UDP doesn't have their own mechanism for information retrieval can lose those data and be forced to
retransmitted again. On the other side this applications are not slow down by the confirmation process and
the memory will be available for work much faster.

SIMULATION RESULTS:
The simulation time is set for two hours data transfer between LAN network and the server with no
packet latency and packet discard ratio of 0% while packets traverse thru the WAN. The task response
time, in seconds, Fig. 1, shows how long the application need to be completed. The time hen using TCP to
complete the task is greater that the one using UDP. When using TCP, source and destination need to
perform a three-way handshake before starting sending data and all amount of data need to be acknowledge
by the destination when it is receive, so is taking more time than UDP, which doesn't perform this tasks.
The main difference between these two protocols is that TCP provides reliability and congestion
control services, while UDP is orientated to improve performance. The most important and common thing
that TCP and UDP are using is the ability to set a host-to-host communication channel, so the packets will
be delivered between processes running on two different computers. UDP is the right choice for application
where reliability is not a must but the speed and performance is. Instead, TCP, even if it takes more time for
the processes, has additional functions like same order delivery, reliability and flow control. As future
work, we plan to conduct several studies regarding packets routing in computer networks to improve the
fairness of data transmissions using different network protocols.

RESULT:
Thus the study of TCP/UDP performance using simulation tool was executed successfully.
Ex No:9A
Date:15/10/24 Simulation of Distance Vector Routing Algorithm

AIM:
TO simulate and study the distance vector routing using simulation using NS2.

ALGORITHM:
There are several various of flooding algorithm most work roughly as follows.
1) Each node act as both a transmitter and receiver.

2) Each node tries to forward every message to every one of its neighbours except the source
node. This results in every message eventually being delivered to all reachable parts of the
network.

PROGRAM:
set ns [new Simulator]
set nf [open out.nam w]
$ns namtrace-all $nf
set tr [open out.tr w]
$ns trace-all $tr
proc finish {} {
global nf ns tr
$ns flush-trace
close $tr
exec nam out.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
$ns duplex-link $n0 $n1 10Mb 10ms DropTail
$ns duplex-link $n1 $n3 10Mb 10ms DropTail
$ns duplex-link $n2 $n1 10Mb 10ms DropTail
$ns duplex-link-op $n0 $n1 orient right-down
$ns duplex-link-op $n1 $n3 orient right
$ns duplex-link-op $n2 $n1 orient right-up
set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
set ftp [new Application/FTP]
$ftp attach-agent $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n3 $sink
set udp [new Agent/UDP]
$ns attach-agent $n2 $udp
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
set null [new Agent/Null]
$ns attach-agent $n3 $null
$ns connect $tcp $sink
$ns connect $udp $null
$ns rtmodel-at 1.0 down $n1 $n3
$ns rtmodel-at 2.0 up $n1 $n3
$ns rtproto DV
$ns at 0.0 "$ftp start"
$ns at 0.0 "$cbr start"
$ns at 5.0 "finish"
$ns run
OUTPUT:
RESULT:
Thus the distance vector routing algorithm was simulated and studied.
Ex No:9B
Date:15/10/24 SIMULATION OF LINK STATE ROUTING ALGORITHM

AIM:
To simulate and study link state routing algorithm using NS2 simulation.

ALGORITHM:
Step 1: Create a simulator object.
Step 2: Define different colors for different data flows.
Step 3: Open a nam trace file and define finish procedure the close trace file.
Step 4: Create n numbers of nodes using for loop.
Step 5: Create duplex links between nodes.
Step 6: Setup UDP connection between n(1) and n(5).
Step 7: Setup another UDP connection between n(1) and n(5)
Step 8: Apply CBR traffic over both UDP connection.
Step 9: Choose link state routing protocol to transmit data.
Step 10: Run the program.

PROGRAM:
set ns [new Simulator]
set nf [open out.nam w]
$ns namtrace-all $nf
set tr [open out.tr w]
$ns trace-all $tr
proc finish {} {
global nf ns tr
$ns flush-trace
close $tr
exec nam out.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
$ns duplex-link $n0 $n1 10Mb 10ms DropTail
$ns duplex-link $n1 $n3 10Mb 10ms DropTail
$ns duplex-link $n2 $n1 10Mb 10ms DropTail
$ns duplex-link-op $n0 $n1 orient right-down
$ns duplex-link-op $n1 $n3 orient right
$ns duplex-link-op $n2 $n1 orient right-up
set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
set ftp [new Application/FTP]
$ftp attach-agent $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n3 $sink
set udp [new Agent/UDP]
$ns attach-agent $n2 $udp
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
set null [new Agent/Null]
$ns attach-agent $n3 $null
$ns connect $tcp $sink
$ns connect $udp $null
$ns rtmodel-at 1.0 down $n1 $n3
$ns rtmodel-at 2.0 up $n1 $n3
$ns rtproto LS
$ns at 0.0 "$ftp start"
$ns at 0.0 "$cbr start"
$ns at 5.0 "finish"
$ns run

OUTPUT:
RESULT:
Thus the program for creating simulation of link state routing was implemented
successfully.
Ex No:10 Simulation of an Error Correction Code (like CRC)
Date:22/10/24

AIM:
To Simulate the Cyclic Redundancy Check using data.
Algorithm:
Step 1: Start
Step 2: Open the editor and type the program.
Step 3: Get the input in the form of bits.
Step 4: Append the redundancy bits.
Step 5: Divide the append data using division polynomial.
Step 6: The resultant data should be transmitted both to the receiver.
Step 7: The same process repeated at receiver.
Step 8: Stop.
Program:
import java.io.*;
class CRC{
public static void main(String args[]) throws IOException{

BufferedReaderbr=newBufferedReader(newInputStreamReader(System.in));
System.out.println("Enter Generator:");
String gen=br.readLine();
System.out.println("Enter Data:");
String data=br.readLine();
String code=data;
while (code.length()<(data.length()+gen.length()-1))
code=code + "0";
code=data + div(code, gen);
System.out.println("The transmitted Code Word is: " + code);
System.out.println("Please enter the received Code Word:");
String rec=br.readLine();
if (Integer.parseInt(div(rec, gen))==0)
System.out.println("The received code word contains no error.");
else
System.out.println("The received code word contains error.");
}
static String div(String num1, String num2)
{ int pointer=num2.length();
String result=num1.substring(0, pointer);
String remainder="";
for (int i=0;i<num2.length(); i++) {
if (result.charAt(i)==
num2.charAt(i)) remainder += "0";
else
remainder += "1";
}
while (pointer<num1.length()) {
if (remainder.charAt(0)=='0')
{
remainder=remainder.substring(1);
remainder=remainder+ num1.charAt(pointer);
pointer++;
}
result=remainder;
remainder="";
for (int i=0;i<num2.length();i++){
if (result.charAt(i)==num2.charAt(i))
remainder+="0";

else
remainder+="1";
}
}
return remainder.substring(1);
}

}
OUTPUT:

Result:
Thus the error detection and error correction was implemented
successfully.

You might also like