You are on page 1of 55

GNANAMANI COLLEGE OF TECHNOLOGY

GNANAMANI COLLEGE
NAMAKKAL OF TECHNOLOGY,
– 637018
NAMAKKAL - 637 018

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

INSTITUTE

VISION

Emerging as a technical institution of high standard and excellence to produce quality Engineers,
Researchers, Administrators and Entrepreneurs with ethical and moral key values to contribute the
sustainable development of the society.

MISSION

We facilitate our students

MI1: To have in-depth domain knowledge with analytical and practical skills in cutting edge technologies
by imparting quality technical education.

MI2: To be industry ready and multi-skilled personalities to transfer technology to industriesand rural areas
by creating interests among students in Research and Development and Entrepreneurship.

DEPARTMENT

VISION

To evolve as a Centre of Excellence to produce the most competent software professionals,


researchers, entrepreneurs and academicians with ethical key values in Computer Science and Engineering.

MISSION

• Imparting quality education through latest technologies to prepare Students as software developer
and system analyst.

• Inculcating the technological transformations for the sustainable development of society.

• Promoting excellence towards higher education, research, employability and entrepreneurship.


GNANAMANI COLLEGE OF TECHNOLOGY,
NAMAKKAL - 637 018

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

PROGRAM EDUCATIONAL OBJECTIVES (PEOs)

Graduates of Computer Science and Engineering will


PEO-1: Be capable of design by applying the concepts of science, mathematics, engineering
fundamentals and computing for the rapid change of society requirements.

PEO-2: Demonstrate ethical keys, effective communication and team skills in their profession and
adapt to current trends through lifelong learning.

PEO-3: Be expert in profession, higher education, research and entrepreneurship.

PROGRAM SPECIFIC OUTCOMES (PSOs)

Graduates of the program will be able to


PSO-1: Understand, analyze and develop computer applications in data Mining/ Analytics, Cloud
Computing, Networking, Security, etc. to meet the requirements of industry and society.
PSO-2: Enrich the ability to design and develop software and qualify for Employment, Higher studies and
Research.

PROGRAM OUTCOMES (PO)

Engineering Graduates will be able to:

1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and
an engineering specialization to the solutionof complex engineering problems.

2. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and
engineering sciences.

3. Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the public
health and safety, and the cultural, societal, and environmental considerations

4. Conduct investigations of complex problems: Use research-based knowledge and research methods
including design of experiments, analysis and interpretation of data, and synthesis of the information to
provide keyid conclusions.

5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering
and IT tools including prediction and modeling to complex engineering activities with an understanding of
the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional
engineering practice.

7. Environment and sustainability: Understand the impact of the professional engineering solutions in
societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.

8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the
engineering practice.

9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse
teams, and in multidisciplinary settings.

10. Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports and
design documentation, make effective presentations, and give and receive clear instructions.

11. Project management and finance: Demonstrate knowledge and understanding of the engineering and
management principles and apply these to one’s own work, as a member and leader in a team, to manage
projects and in multidisciplinary environments.

12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technologicalchange.
CS3591 COMPUTER NETWORKS LAB LT PC
3 0 2 4
COURSE OBJECTIVES:
At the end of this course, the students will be able to:
CO1: To learn and use network commands.
CO2: To learn socket programming.
CO3: To implement and analyze various network protocols.
CO4: To learn and use simulation tools.
CO5:To use simulation tools to analyze the performance of various network protocols.

PRACTICAL EXERCISES: 30 PERIODS

1. Learn to use commands like tcpdump, netstat, ipconfig, nslookup and traceroute.
Capture ping and trace route PDUs using a network protocol analyzer and examine.
2. Write a HTTP web client program to download a web page using TCP sockets.
3. Applications using TCP sockets like: a) Echo client and echo server b) Chat
4. Simulation of DNS using UDP sockets.
5. Use a tool like Wireshark to capture packets and examine the packets
6. Write a code simulating ARP /RARP protocols.
7. Study of Network simulator (NS) and Simulation of Congestion Control Algorithms using NS.
8. Study of TCP/UDP performance using Simulation tool.
9. Simulation of Distance Vector/ Link State Routing algorithm.
10. Simulation of an error correction code (like CRC)

COURSE OUTCOMES:
At the end of this course, the students will be able to:
• Implement various protocols using TCP and UDP.
• Compare the performance of different transport layer protocols.
• Use simulation tools to analyze the performance of various network protocols.
• Analyze various routing algorithms.
• Implement error correction codes.
GNANAMANI COLLEGE OF TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
NAME OF THE LAB : COMPUTER NETWORKS
SUBJECT CODE : CS3591 YEAR/BRANCH/SEM : III-B.E-CSE/V

COURSE OUTCOMES

At the end of this course, the students will be able to:


• Implement various protocols using TCP and UDP.
• Compare the performance of different transport layer protocols.
• Use simulation tools to analyze the performance of various network protocols.
• Analyze various routing algorithms.
• Implement error correction codes.

LIST OF EXPERIMENTS
S. BLOOMS
NAME OF EXPERIMENTS COs
NO LEVEL
Learn to use commands like tcpdump, netstat, ifconfig, nslookup and
1 traceroute. Capture ping and trace route PDUs using a network protocol L3 CO3
analyzer and examine.
Write a HTTP web client program to download a web page using TCP
2 L3 CO1
sockets.

3 Applications using TCP sockets like: a) Echo client & Echo server b) Chat L3 CO1

4 Simulation of DNS using UDP sockets. L3 CO1

5 Use a tool like Wireshark to capture packets and examine the packets L4 CO2

6 Write a code simulating ARP /RARP protocols. L4 CO3

Study of Network simulator (NS) and Simulation of Congestion Control


7 L4 CO2
Algorithms using NS.

8 Simulation of Distance Vector/ Link State Routing algorithm. L3 CO4

9 Study of TCP/UDP performance using Simulation tool. L3 CO2

10 Simulation of an error correction code (like CRC) L3 CO5


Content Beyond Experiment
11 Data Encryption and Decryption L3 CO1

*BL: (L1- Remembering, L2- Understanding, L3- Applying, L4- Analysing, L5- Evaluating, L6-Creating)
Ex. No: 1.(a) LEARN TO USE COMMANDS LIKE NSLOOKUP, NETSTAT, IPCONFIG,
Date: TRACEROUTE AND TCPDUMP

AIM

To Learn to use commands like nslookup, tcpdump, netstat, ifconfig and traceroute.

Tracert command
“tracert” in Windows stands for “Trace Route”. In Linux, the same command is
“traceroute”. The command traces the path that a TCP/IP packet takes towards a destination target
and shows some information (if available) of the routing nodes within this path.
Just like the “ping” command, “tracert” sends also ICMP echo packets to the destination with
varying Time-to-Live (TTL) values.
tracert [domain or IP] : Traces TCP/IP path to specified destination target IP or domain.
Example:
tracert [domain]
C:/> tracert www.google.com

Example:
tracert [IP Address]
C:/> tracert 172.16.26.163
Example:
tracert [IP address]
C:/> tracert 8.8.8.8

Nslookup command
“nslookup” stands for “Name System Lookup” and is very useful in obtaining Domain
Name System (DNS) related information about a domain or about an IP address.
nslookup [domain name]: This command is to find quickly the IP address of a specific domain
name (A-record) as shown below:
Example: nslookup [Domain name]
C:/> nslookup www.google.com
As shown above, the “nslookup” command followed by a domain name will show you the IPv4 and
IPv6 addresses (A records and AAAA records) assigned to the specific domain.
nslookup [IP Address]: This will perform a reverse-DNS lookup and will try to match the given IP
address in the command with its corresponding domain name.
Example: nslookup [IP address]
C:/> nslookup 8.8.8.8

IP address 8.8.8.8 is mapped with the name “google-public-dns-a.google.com”.

Ping command
Command that every computer user runs on the command line when having connectivity problems
is the “ping” command. This will quickly show you if can send and receive packets (icmp packets to be
exact) from your computer and hence shows whether you have network connectivity or not. Ping is useful
for testing connectivity for both the local computer from where you execute the command and also for a
remote computer or server which try to reach.

ping [IP Address] : By default it will send 4 ICMP packets to the stated IP address.

Example: C:/> ping 172.16.26.163


ping [hostname or domain] : When “pinging” a hostname or domain name, the command will resolve
first the name to IP address and then send the icmp packets to that IP.
Example: c:/> ping www.google.com

ping [IP address] -t : This will send ping packets (icmp echo requests) continuously to the target IP.

ping -n 10 [IP address] : This will send 10 ping packets (icmp echo requests) to the target IP.

ping -a [IP address]:


The -a switch tells the computer to try to find the hostname assigned to the specific IP
address and then ping the IP.
ipconfig: ipconfig (standing for "Internet Protocol configuration") is a console application program of
some computer operating systems that displays all current TCP/IP network configuration values

Netstat Command:
The netstat command generates displays that show network status and protocol statistics.

The network statistics ( netstat ) command is a networking tool used for troubleshooting and
configuration, that can also serve as a monitoring tool for connections over the network. Both
incoming and outgoing connections, routing tables, port listening, and usage statistics are common uses for
this command.
netstat -a: netstat –a Displays all active ports
netstat -e: netstat –e Shows statistics about your network connection (received and sent data packets)

netstat: netstat command allows Standard listing of all active connections

RESULT
Thus the Learning to use commands like nslookup, tcpdump, netstat, ifconfig and traceroute was
performed.
Ex. No: 1.(b)
CAPTURE PING PDUS USING A NETWORK PROTOCAL ANALYZER
Date:

AIM

To simulate ping command using java language.


ALGORITHM
1. Start the program
2. Create an object for the class process.
3. Get IP address from the user using getInputStream().
4. Execute the ping command using Runtime.getRuntime().
5. Stop the program.

PROGRAM

import java.util.*;
public class Ping {
public void ping(String host) {
try
{
Process p = Runtime.getRuntime().exec("ping"+host);
Scanner scan = new Scanner(p.getInputStream());
while(scan.hasNextLine())
{
System.out.println(scan.nextLine());
}}
catch(Exception ex){
System.out.println("Error "+ex);
}}
public static void main(String args[])
{
Ping p=new Ping();
p.ping(args[0]);
}}
OUTPUT

RESULT

Thus the java program to simulate ping command was executed successfully.
EX. NO:1(c)
Date: SIMULATION OF TRACEROUTE COMMAND

AIM

To simulate traceroute command using java language.

ALGORITHM

1. Start the program


2. Create an object for the class process.
3. Get IP address from the user using getInputStream().
4. Execute the Tracert command using Runtime.getRuntime().
5. Stop the program.

PROGRAM

import java.io.BufferedReader;
import java.io.InputStreamReader;
public class traceroutecmd
{
public static void runSystemCommand(String command)
{
try
{
Process p = Runtime.getRuntime().exec(command);
BufferedReader inputStream = new BufferedReader(new InputStreamReader(p.getInputStream()));
String s ="";
while((s = inputStream.readLine())!= null)
System.out.println(s);
}
catch (Exception e)
{ }
}
public static void main(String[] args)
{
String ip = "www.google.com";
runSystemCommand("tracert " + ip);
}
}

OUTPUT

RESULT

Thus the java program to simulate trace route command was executed successfully.
EX. NO:2
Date: DOWNLOADING A WEB PAGE

AIM

To Write a HTTP web client program to download a web page using Java Programming.

ALGORITHM

1. Start the program and Read the input file name.


2. Create connection with HTTP server
3. Login HTTP server with username and password
4. Set the upload file path in HTT server.
5. Upload the file.
6. Read the name of the file to be downloaded and the path at where file to be stored
7. Download the file stream and store in the file in specified path.

PROGRAM

import java.io.*;
import java.net.URL;
import java.net.MalformedURLException;
public class download {
public static void downloadpage(String webpage)
{
try {
URL url = new URL(webpage);
BufferedReader readr = new BufferedReader(new InputStreamReader(url.openStream()));
BufferedWriter writer = new BufferedWriter(new FileWriter("gk.html"));
String line;
while((line = readr.readLine()) != null) {
writer.write(line); }
readr.close();
writer.close();
System.out.println("Successfully Downloaded."); }
catch (MalformedURLException mue) {
System.out.println("Malformed URL Exception raised");
}
catch (IOException ie)
{
System.out.println("IOException raised");
} }
public static void main(String args[]) throws IOException
{ String url = "https://www.google.com";

downloadpage(url);

} }
OUTPUT

RESULT

Thus, the HTTP web client program to download a web page was executed successfully.
EX. NO:3a APPLICATIONS USING TCP SOCKETS LIKE:
Date: ECHO CLIENT & SERVER

AIM

To create the TCP socket for Echo Client and Server Application using java programming.

ALGORITHM

CLIENT SIDE

1. Create a socket which binds the IP address of server and the port address.
2. After establishing connection send a data to server.
3. Receive and print the same data from server.
4. Close the Socket & End the program.

SERVER SIDE

1. Create a server socket to activate the port address.


2. Create a socket for the server socket which accepts the connection.
3. After establishing connection receive the data from client.
4. Print and send the same data to client.
5. Close the Socket & End the program.

SERVER PROGRAM:

import java.io.*;
import java.net.*;
class echoserver
{
public static void main(String args[]) throws Exception
{
ServerSocket ss =new ServerSocket(111);
Socket s=ss.accept();
DataInputStream in= new DataInputStream(s.getInputStream());
DataOutputStream out=new DataOutputStream(s.getOutputStream());
String str;
System.out.println("\nSERVER SIDE!...");
while(true)
{
str=in.readLine();
out.writeBytes(str);
System.out.println("\nMsg from Client");
System.out.println(str+"\n");
}
}
}
CLIENT PROGRAM

import java.io.*;
import java.net.*;
class echoclient
{
public static void main(String args[]) throws Exception
{
DataInputStream in=new DataInputStream(System.in);
Socket s=new Socket("LocalHost",111);
DataInputStream inecho=new DataInputStream(s.getInputStream());
DataOutputStream out=new DataOutputStream(s.getOutputStream());
String str,str1;
System.out.println("\nCLIENT SIDE! \nEnter Client Msg");
while((str=in.readLine())!=null)
{
out.writeBytes(str+"\n");
}
}
}
SERVER OUTPUT

CLIENT OUTPUT

RESULT

Thus the TCP socket for Echo client and Echo Server Application using java programming was
performed.
EX. NO: 3b CHAT APPLICATION USING TCP SOCKETS
Date:

AIM

To create the TCP sockets for Chat Application using java programming.

ALGORITHM

1. Create Data InputStream and Data OutputStream objects for Data flow
2. Create a socket and include port number and local host IP address in client program.
3. Create a server socket and include port number.
4. Declare accept() in the server program and accept() are accessed by using server socket object.
5. Declare writeBytes() to write the messages sent between the client and server.
6. Declare readLine() to read the contents of client and server.

SERVER PROGRAM

import java.io.*;

import java.net.*;

class schat

public static void main(String args[]) throws Exception

ServerSocket ss=new ServerSocket(123);

Socket s=ss.accept();

DataInputStream in=new DataInputStream(System.in);

DataInputStream in1=new DataInputStream(s.getInputStream());

DataOutputStream out=new DataOutputStream(s.getOutputStream());

while(s!=null)

String m2;

System.out.println("Server:");
while(true)

String m1=in1.readLine();

System.out.println("Message from client:"+m1);

System.out.println("\nEnter the message:");

m2=in.readLine();

out.writeBytes(m2+"\n");

in1.close();

out.close();

s.close();

ss.close();

CLIENT PROGRAM

import java.io.*;
import java.net.*;
public class cchat
{
public static void main(String args[]) throws Exception
{
Socket s=new Socket("LocalHost",123);
DataInputStream in1=new DataInputStream(System.in);
DataInputStream in2=new DataInputStream(s.getInputStream());
DataOutputStream out=new DataOutputStream(s.getOutputStream());
if(s!=null)
{
String inp;
System.out.println("Enter the message:");
while((inp=in1.readLine())!=null)
{
if(inp.equals("exit"))
break;
out.writeBytes(inp+"\n");
System.out.println("Echo message from server:"+in2.readLine());
System.out.println("Enter ur message:");
}
}
}
}

SERVER OUTPUT
CLIENT OUTPUT

RESULT

Thus the TCP sockets for Chat Application using java programming was performed.
EX. NO: 4.a SIMULATING ARP PROTOCOL
Date:

AIM

To Simulate ARP protocol for client and server application using Java programming.

ALGORITHM

CLIENT SIDE

1. Establish a connection between the Client and Server.


2. Create instance output stream writer
3. Get the IP Address to resolve its physical address.
4. Send the IPAddress to its output Stream.ps.println(ip);
5. Print the Physical Address received from the server.

SERVER SIDE
1. Accept the connection request by the client.
2. Get the IP address from its inputstream.
3. During runtime execute the process using Process p=r.exec("arp -a "+ip);
4. Send the Physical Address to the client.

SERVER PROGRAM:

import java.io.*;
import java.net.*;
class arps
{
public static void main(String args[]) throws IOException
{
try
{
ServerSocket ss=new ServerSocket(111);
Socket s=ss.accept();
PrintStream ps=new PrintStream(s.getOutputStream());
BufferedReader br1=new BufferedReader(new InputStreamReader(s.getInputStream()));
String ip;
ip=br1.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("arp -a "+ip);
BufferedReader br2=new BufferedReader(new InputStreamReader(p.getInputStream()));
String str;
while((str=br2.readLine())!=null)
{
ps.println(str);
}}
catch(IOException e)
{
System.out.println("Error"+e);
}}}

CLIENT PROGRAM

import java.io.*;
import java.net.*;
class arpc
{
public static void main(String args[]) throws IOException
{
try
{
Socket ss=new Socket(InetAddress.getLocalHost(),111);
PrintStream ps=new PrintStream(ss.getOutputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String ip;
System.out.println("Enter the IP ADDRESS:");
ip=br.readLine();
ps.println(ip);
String str,data;
BufferedReader br2=new BufferedReader(new InputStreamReader(ss.getInputStream()));
System.out.println("ARP From Server:");
do
{
str=br2.readLine();
System.out.println(str);
}
while(!(str.equalsIgnoreCase("end")));
}
catch(IOException e)
{
System.out.println("Error"+e);
}}}

SERVER SIDE

CLIENT SIDE OUTPUT

RESULT

Thus the Simulation of ARP protocol for client and server application using Java
programming was performed.
EX. NO: 4.b SIMULATING ARP /RARP PROTOCOLS
Date:

AIM
To write a java program for simulating RARP protocols.

ALGORITHM

CLIENT SIDE
1. Start the program
2. using datagram sockets UDP function is established.
3. Get the MAC address to be converted into IP address.
4. Send this MAC address to server.
5. Server returns the IP address to client.

SERVER SIDE
1. Start the program.
2. Server maintains the table in which IP and corresponding MAC addresses are stored.
3. Read the MAC address which is send by the client.
4. Map the IP address with its MAC address and return the IP address to client.

SERVER PROGRAM

import java.io.*;
import java.net.*;
import java.util.*;
public class rarps
{
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();
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);
}}}

CLIENT PROGRAM

import java.io.*;
import java.net.*;
import java.util.*;
public class rarpc
{
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);
}
}
}

OUTPUT

RESULT

Thus the Simulation of RARP protocol using Java programming was performed.
EX. NO: 5 SIMULATION OF DNS USING UDP SOCKETS
Date:

AIM

To Simulate the concept of DNS using UDP Sockets using Java programming.

ALGORITHM

1. Start the program.


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

SERVER PROGRAM

dnsserver .java:
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 arg[])throws IOException
{
String[] hosts = {"yahoo.com", "gmail.com","cricinfo.com", "facebook.com"};
String[] ip = {"68.180.206.184", "209.85.148.19","80.168.92.140", "69.63.189.16"};
while(true)
{
DatagramSocket serversocket=new DatagramSocket(1362);
byte[] senddata = new byte[1021];
byte[] receivedata = new byte[1021];
DatagramPacket recvpack = new DatagramPacket(receivedata, receivedata.length);
serversocket.receive(recvpack);
String sen = new String(recvpack.getData());
InetAddress ipaddress = recvpack.getAddress();
int port = recvpack.getPort();
String capsent;
System.out.println("Request for host " + sen);
if(indexOf (hosts, sen) != -1)
capsent = ip[indexOf (hosts, sen)];
else
capsent = "Host Not Found";
senddata = capsent.getBytes();
DatagramPacket pack = new DatagramPacket (senddata, senddata.length,ipaddress,port);
serversocket.send(pack);
serversocket.close();
}
}
}

CLIENT PROGRAM

dnsclient.java:
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 pack = new DatagramPacket(senddata,senddata.length, ipaddress,portaddr);
clientsocket.send(pack);
DatagramPacket recvpack =new DatagramPacket(receivedata,receivedata.length);
clientsocket.receive(recvpack);
String modified = new String(recvpack.getData()); System.out.println("IP Address: " + modified);
clientsocket.close();
}
}
OUTPUT

SERVER SIDE

CLIENT SIDE

RESULT

Thus the Simulation of DNS using UDP Sockets using Java programming was performed.
EX. NO: 6 WIRESHARK TOOL TO CAPTURE AND EXAMINE PACKETS
Date:

AIM

To use a tool like wireshark to capture packets and examine the packets.

ALGORITHM

1. Open Wireshark.
2. Set a capture filter, and select the interface on which to capture.
3. Start the capture.
4. Generate traffic by connecting to a website.
5. Pinging a remote device or attempting any other network connection.
6. Stop the capture and Examine the Packets.

PROCEDURE

1. Select Capture | Interfaces

2. Select the interface on which packets need to be captured. This will usually be the interface where
the Packet/s column is constantly changing, which would indicate the presence of live traffic. If
multiple network interface cards (i.e. LAN card and Wi-Fi adapter) are there, Determine the right
interface.

3. Click the Start button to start the capture.

4. Recreate the problem. The capture dialog should show the number of packets increasing. Try to
avoid running any other internet applications while capturing, closing other browsers, Instant
messengers etc.

5. Once the problem which is to be analyzed has been reproduced, click on Stop. It may take a few
seconds for Wireshark to display the packets captured.

6. Save the packet trace in the default format. Click on the File menu option and select Save As. By
default Wireshark will save the packet trace in libpcap format. This is a filename with a.pcap
extension.
OUTPUT
RESULT
Thus the given procedure for wireshark tool to capture packets and examine the packets was
performed successfully.
EX. NO: 7 STUDY OF NETWORK SIMULATOR (NS)
Date:

AIM

To perform the study of Network Simulator (NS) like Cisco Packet Tracer.

DESCRIPTION
Cisco systems are used to design the Cisco packet tracer. It is a dominant network simulation
tool. These are used for designing network topologies and also allowed to imitate these designed
networks in modern computer networks. It is the most commonly used network simulation network.
Cisco Packet Tracer is a vital tool for Network learners as it helps them to prepare for the networking
exams such as CCNA (Cisco Certified Network Associate)
Cisco Packet Tracer is a powerful network simulation and visualization tool by Cisco to practice
networking, IoT, and cybersecurity skills. The virtual learning environment comes in handy to learn
courses, professional training, work planning, and so on.
This software is built by Cisco and can be used to practice Networking related labs virtually.
Packet tracer is an excellent tool for having hands-on experience on devices like Cisco Routers,
Switches, HUB, and end devices like PC, Laptop, Server, and many more.

Features of Cisco Packet Tracer


• E-learning
• Visualizing Networks
• Real-time and simulation mode
• Compatible on various platforms
• Support to all languages
• Most networking protocols are supported
• Environment is interactive
• Can be used on unlimited devices

Cisco Packet Tracer Download


Download the Cisco Packet Tracer tool directly from Cisco's official website. Follow the steps
mentioned to get started with the Packet Tracer Tool.
Choose the option according to device specification and download the Cisco packet tracer.

Cisco Packet Tracer Install


After the download is complete open the setup and install the Cisco Packet tracer on your device.
After opening the Packet Tracer, you'll see a window shown below.

Click on Cisco Networking Academy and log in to account to get started with the Cisco packet tracer.

How to Use Cisco Packet Tracer?


Key features of this simulator:
• This Cisco Packet Tracer software is free to use.
• You can use unlimited devices available in the packet tracer to practice networking labs.
• It supports the majority of networking protocols
Cisco Packet tracer's installation:
Step 1 - Open Packet Tracer and go to End Devices Category.

Step 2 - Click on PC and drag it to place it in the workspace. Place two PCs like this.

Step 3 - Click on PC 0 and go to the Desktop tab.

Step 4 - Click on IP Configuration and configure IP address: 192.168.10.1 as shown below.


Step 5 - Configure the IP address – 192.168.10.2 on PC 1

Step 6 - Go to Connections Category and select "Automatically Choose Connection type"

Step 7 - Click on PC0 and connect the cable to PC1

Now, these two PCs are connected, and in order to check the connectivity, follow the steps below:

Step 8 - Click on Add Simple PDU option.


Click on PC0, and a message appearing on PC0 as shown below; now click on PC1 to make the
communication between devices.

Check the action status in the PDU list window on the bottom right side.

Network Simulation:

Finally, Network with 4 hosts, 2 switches and 2 routers are configured like below:

RESULT
Thus the study of Network Simulator (NS) like Cisco Packet Tracer was performed successfully.
EX. NO: 8 SIMULATION OF DISTANCE VECTOR ROUTING
DATE: ALGORITHM

AIM
To simulate the concept of a Distance Vector/Link State Routing using the Cisco Packet Tracer.

PROCEDURE

1. Open Cisco Packet Tracer.


2. Choose the PCs and drag it to the work area.
3. Choose the Switches and drag it to the work area.
4. Choose the Routers and drag them to the work area.
5. After setting all the PCs, Switches and Routers to the work area, Connect all with the wire.

6. After that set the IP address of all the PCs by clicking on the PC and choose desktop option and
IP config to set the IP address and the default gateway address of the PCs.
7. Now set the IP address of the routers by click on the router and select config and choose Fast
Ethernet option and set the IP and on the Port status.

8. Now choose the Serial2/0 to set the IP address of the neighbor routers and for the second
define the Serial3/0 IP address as given in the Image.
9. Now click on the RIP option and give the neighbors IP address in all the Routers.
10. Now for check the connection we can send the message from one PC to another.

OUTPUT

RESULT

Thus the simulation of the Distance Vector using the Cisco Packet Tracer was performed.
EX. NO: 9 STUDY OF TCP/UDP PERFORMANCE USING
DATE: SIMULATION TOOL

AIM

To implement the study of TCP/UDP performance using Network Simulator.

ALGORITHM
1. Create a simulation object
2. Set routing protocol to routing
3. Trace packets and all links onto NAM trace and to trace file
4. Create right nodes
5. Describe their layout topology
6. Add a sink agent to node
7. Connect source and sink.
8. Observe the traffic route when link is up and down
9. View the simulated events and trace file analyze it
10. Start the scheduler

UDPTCP.TCL

set ns [new Simulator]

set nr [open thro_dt.tr w]

$ns trace-all $nr

set nf [open thro.nam w]

$ns namtrace-all $nf

proc finish { } {

global ns nr nf

$ns flush-trace

close $nf

close $nr

exec nam thro.nam &

exit 0 }
set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

set n4 [$ns node]

set n5 [$ns node]

set n6 [$ns node]

set n7 [$ns node]

$ns duplex-link $n0 $n3 1Mb 10ms DropTail

$ns duplex-link $n1 $n3 1Mb 10ms DropTail

$ns duplex-link $n2 $n3 1Mb 10ms DropTail

$ns duplex-link $n3 $n4 1Mb 10ms DropTail

$ns duplex-link $n4 $n5 1Mb 10ms DropTail

$ns duplex-link $n4 $n6 1Mb 10ms DropTail

$ns duplex-link $n4 $n7 1Mb 10ms DropTail

$ns duplex-link-op $n0 $n3 orient right-up

$ns duplex-link-op $n1 $n3 orient right

$ns duplex-link-op $n2 $n3 orient right-down

$ns duplex-link-op $n3 $n4 orient middle

$ns duplex-link-op $n4 $n5 orient right-up

$ns duplex-link-op $n4 $n7 orient right-down

$ns duplex-link-op $n6 $n4 orient left

set udp0 [new Agent/UDP]

$ns attach-agent $n2 $udp0

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 500

$cbr0 set interval_ 0.005

$cbr0 attach-agent $udp0


set null0 [new Agent/Null]

$ns attach-agent $n5 $null0

$ns connect $udp0 $null0

set udp1 [new Agent/UDP]

$ns attach-agent $n1 $udp1

set cbr1 [new Application/Traffic/CBR]

$cbr1 set packetSize_ 500

$cbr1 set interval_ 0.005

$cbr1 attach-agent $udp1

set null0 [new Agent/Null]

$ns attach-agent $n6 $null0

$ns connect $udp1 $null0

set tcp0 [new Agent/TCP]

$ns attach-agent $n0 $tcp0

set cbr2 [new Application/Traffic/CBR]

$cbr2 set packetSize_ 500

$cbr2 set interval_ 0.005

$cbr2 attach-agent $tcp0

set tcpsink0 [new Agent/TCPSink]

$ns attach-agent $n7 $tcpsink0

$ns connect $tcp0 $tcpsink0

$udp0 set fid_ 1

$udp1 set fid_ 2

$tcp0 set fid_ 3

$ns color 1 Red

$ns color 2 Green

$ns color 3 blue

$ns at 0.2 "$cbr0 start"


$ns at 3.5 "$cbr0 stop"

$ns at 0.3 "$cbr1 start"

$ns at 4.5 "$cbr1 stop"

$ns at 0.4 "$cbr2 start"

$ns at 4.5 "$cbr2 stop"

$ns at 5.0 "finish"

$ns run

OUTPUT

RESULT

Thus, the performance of TCP/UDP using Network Simulator was studied and output is
verified successfully
EX. NO: 10
SIMULATION OF ERROR DETECTION CODE (LIKE CRC)
DATE:

AIM

To Simulate the concept of Error Detection & Correction code like CRC using Java.

ALGORITHM
1. Open the editor and type the program for error detection
2. Get the input in the form of bits.
3. Append the redundancy bits.
4. Divide the appended data using a divisor polynomial.
5. The resulting data should be transmitted to the receiver.
6. At the receiver the received data is entered.
7. The same process is repeated at the receiver.
8. If the remainder is zero there is no error otherwise there is some error in the received bits
9. Run the program.

PROGRAM
import java.io.*;
class crc
{
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(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 errors.");
else
System.out.println("The received code word contains errors.");
}
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.length());
remainder = remainder + String.valueOf(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,remainder.length());
}
}

OUTPUT
Enter Generator:
1011
Enter Data:
1001010
The transmitted Code Word is: 1001010111
Please enter the received Code Word:
1110110111
The received code word contains errors.

RESULT
Thus the simulation of Error correction Code(CRC) was executed and output is verified
successfully.
CONTENT BEYOND SYLLABUS

Ex. No: 11
DATA ENCRYPTION AND DECRYPTION
Date:

AIM

To implement the simple substitution technique named Caesar cipher using C language.

ALGORITHM

Step-1: Read the plain text from the user.


Step-2: Read the key value from the user.
Step-3: If the key is positive then encrypt the text by adding the key with each character in the
plain text.
Step-4: Else subtract the key from the plain text.
Step-5: Display the cipher text obtained above.
PROGRAM caesar.c

#include <stdio.h>
#include <string.h>
#include<conio.h>
#include <ctype.h>
void main()
{
char plain[10], cipher[10];
int key,i,length;
int result;
clrscr();
printf("\n Enter the plain text:");
scanf("%s", plain);
printf("\n Enter the key value:");
scanf("%d", &key);
printf("\n \n \t PLAIN TEXt: %s",plain);
printf("\n \n \t ENCRYPTED TEXT: ");
for(i = 0, length = strlen(plain); i < length; i++)
{
cipher[i]=plain[i] + key;
if (isupper(plain[i]) && (cipher[i] > 'Z'))
cipher[i] = cipher[i] - 26;
if (islower(plain[i]) && (cipher[i] > 'z'))
cipher[i] = cipher[i] - 26;
printf("%c", cipher[i]);
}
printf("\n \n \t AFTER DECRYPTION : ");
for(i=0;i<length;i++)
{
plain[i]=cipher[i]-key;
if(isupper(cipher[i])&&(plain[i]<'A'))
plain[i]=plain[i]+26;
if(islower(cipher[i])&&(plain[i]<'a'))
plain[i]=plain[i]+26;
printf("%c",plain[i]);
}
getch();
}
OUTPUT
Enter the Plain Text: ZEBRA
Enter the key value: 3
PLAIN TEXT: ZEBRA
ENCRYPTED TEXT: CHEUD
AFTER DECRYPTION: ZEBRA
Enter the Plain Text: zebra
Enter the key value: 3
PLAIN TEXT: zebra
ENCRYPTED TEXT: cheud
AFTER DECRYPTION: zebra

RESULT
Thus the implementation of Caesar cipher has been executed successfully.

You might also like