0% found this document useful (0 votes)
25 views54 pages

Computer Networks Student Manual

Uploaded by

gkeerthana
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)
25 views54 pages

Computer Networks Student Manual

Uploaded by

gkeerthana
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/ 54

NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY

VADAPUTHUPATTI, THENI

DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

STUDENTS LAB MANUAL

CS 3591 COMPUTER NETWORKS INTEGRATED LABORATORY


(Regulation 2021)
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
VADAPUTHUPATTI, THENI

DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

LAB MANUAL
SUBJECTCODE : CS3591
SUBJECTNAME : COMPUTER NETWORKS INTEGRATED LABORATORY
YEAR : II
DEPARTMENT : AI&DS
SEMESTER : IV
REGULATION : 2021
PREPAREDBY : Mr.J.VINOTH KUMAR,
ASSISTANT PROFESSOR/AI&DS
VERIFIEDAND : Mr.L.S.VIGNESH,
APPROVEDBY HOD/ AI&DS

STUDENT NAME:

REGISTERNUMBER:

YEAR/ DEPT/SEMESTER:
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

VISION
To establish ourselves as a leading technological institution.
MISSION
1. To provide professional, constructive and learner centered education.
2. To make learners contribute to the development of the nation through academic and
industrial excellence.
3. To encourage learners involve in innovative researches with ethics.
4. To produce competitive and confident graduates to face the ever growing challenges of the
labor market.

DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

VISION

To become a center of excellence in the field of artificial intelligence by promoting knowledge-based


education, innovation and cutting-edge research in artificial intelligence and data science.

MISSION

 To create an environment that encourages students to achieve their potential and pursue their
professional goals.

 In order to create and develop cutting-edge breakthroughs in artificial intelligence as a whole and as
they are connected with other disciplines, it is important to support ongoing research and development
efforts in partnership with prestigious enterprises and research centers.

 To improve students' interpersonal talents and human personalities in order to instill entrepreneurial
skills that can thrive national growth.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)


Graduates can
1. Utilize their proficiencies in the fundamental knowledge of basic sciences, mathematics, Artificial
Intelligence, data science and statistics to build systems that require management and analysis of large
volumes of data.
2. Advance their technical skills to pursue pioneering research in the field of AI and Data Science and
create disruptive and sustainable solutions for the welfare of ecosystems.
3. Think logically, pursue lifelong learning and collaborate with an ethical attitude in a
multidisciplinary team.
4. Design and model AI based solutions to critical problem domains in the real world.
5. Exhibit innovative thoughts and creative ideas for effective contribution towards economy building.

PROGRAMME OUTCOMES (POs):

Graduate Attribute Programme Outcome


1. Engineering knowledge Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of
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 Design solutions for complex engineering problems and
solutions 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 Use research-based knowledge and research methods including design
Complex problems of experiments, analysis and interpretation of data, and synthesis of the
information to provide valid 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.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

7. Environment and Understand the impact of the professional engineering


sustainability 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 teamwork 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 Demonstrate knowledge and understanding of the
finance 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
technological change.

PROGRAM SPECIFIC OUTCOMES (PSOs)

Graduates should be able to:


1. Evolve AI based efficient domain specific processes for effective decision making in several
domains such as business and governance domains.
2. arrive at actionable Foresight, Insight, hindsight from data for solving business and engineering
problems
3. create, select and apply the theoretical knowledge of AI and Data Analytics along with practical
industrial tools and techniques to manage and solve wicked societal problems
4. develop data analytics and data visualization skills, skills pertaining to knowledge acquisition,
knowledge representation and knowledge engineering, and hence be capable of coordinating complex
projects.
5. able to carry out fundamental research to cater the critical needs of the society through cutting edge
technologies of AI.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

CS3591 NETWORKS LABORATORY LTPC


3042

SYLLABUS

LIST OF EXPERIMENTS

1. Learn to use commands like tcpdump, netstat, ifconfig, 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)

TOTAL: 30 PERIODS
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

COMPUTER NETOWRKS

Computer Networks Laboratory appears to be a course focused on providing hands-on experience and
practical knowledge in the field of computer networks. In such a laboratory setting, students typically get
the opportunity to work with networking equipment, protocols, and software tools to gain a deeper
understanding of how computer networks function in real-world scenarios.

1. Network Configuration and Troubleshooting: You'll likely configure network devices such as routers,
switches, and firewalls. Troubleshooting network issues could involve diagnosing connectivity problems,
analysing network traffic, and implementing solutions.

2. Protocol Analysis: Understanding how various network protocols work is crucial in networking. You
might use tools like Wireshark to capture and analyse network traffic, helping you understand protocols
such as TCP/IP, HTTP, DNS, etc.

3. Network Security: Given the importance of security in modern networks, you may explore topics like
encryption, authentication, intrusion detection, and firewall configuration.

4. Network Design and Implementation: Depending on the level of the course, you might engage in
designing and implementing small-scale networks, considering factors like scalability, reliability, and
performance.

5. Wireless Networking: With the proliferation of wireless technologies, it's common for networking
courses to cover topics related to Wi-Fi, Bluetooth, and other wireless communication standards.

6. Cloud Networking: As cloud computing becomes increasingly prevalent, understanding how networks
interact with cloud services like AWS, Azure, or Google Cloud Platform could also be part of the
curriculum.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

CS3591 COMPUTER NETWORKS INTEGRATED LABORATORY

COURSE OBJECTIVES:
OB1: To understand the concept of layering in networks.
OB2: To know the functions of protocols of each layer of TCP/IP protocol suite.
OB3: To visualize the end-to-end flow of information.
OB4: To learn the functions of network layer and the various routing protocols
OB5: familiarize the functions and protocols of the Transport layer

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

Cos Course outcomes Level


CO1 Explain the basic layers and its functions in computer networks. L2
CO2 Understand the basics of how data flows from one node to another. L2
CO3 Analyze routing algorithms. L4
CO4 Describe protocols for various functions in the network. L4
CO5 Analyze the working of various application layer protocols. L4

PO-CO Correlation Matrix

CO-
PO, PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2 PSO3
PSO
CO1 3 1 2 3 - - - - 1 1 3 1 3 2 1
CO2 3 2 1 2 2 - - - 2 2 2 1 3 2 3
CO3 2 2 3 2 1 - - - 3 3 1 2 1 1 3
CO4 1 3 1 3 1 - - - 1 2 1 1 1 3 1
CO5 3 3 1 1 2 - - - 2 2 2 2 2 2 2
AVG 2 2 2 2 2 - - - 2 2 2 1 2 2 2
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
CS3591 COMPUTER NETWORKS INTEGRATED LABORATORY

CO–PO MAPPING WITH EXPERIMENTS

EXP NO NAME OF THE EXPERIMENT Cos Pos

Learn to use commands like tcpdump, netstat, ifconfig, nslookup and

1. traceroute. Capture ping and trace route PDUs using a network CO1 1,2,3,4,5,9
protocol analyzer and examine.
Write a HTTP web client program to download a web page using
2. TCP sockets
CO2 1,2,3,4,5,9

Applications using TCP sockets like: a) Echo client and echo server
3. b) Chat
CO2 1,2,3,4,5,9

4. Simulation of DNS using UDP sockets. CO2 1,2,3,4,5,9

5. Use a tool like Wireshark to capture packets and examine the packets CO4 1,2,3,4,5,9

6. Write a code simulating ARP /RARP protocols. CO3 1,2,3,4,5,9

Study of Network simulator (NS) and Simulation of Congestion


7. Control Algorithms using NS
CO4 1,2,3,4,5,9

8. Study of TCP/UDP performance using Simulation tool. CO4 1,2,3,4,5,9

9. Simulation of Distance Vector/ Link State Routing algorithm. CO3 1,2,3,4,5,9

10. Simulation of an error correction code (like CRC) CO5 1,2,3,4,5,9,10

List of Components/Hardware:

 Monitor/Keyboard/Mouse
 CPU-Processor : i3 processor
 Ram : 2 GB
 Hard Disk : 350 GB
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

CS3591 COMPUTER NETWORKS INTEGRATED LABORATORY

INDEX

EXP NO NAME OF THE EXPERIMENT MARKS SIGNATURE

Learn to use commands like tcpdump, netstat, ifconfig, nslookup and

1. traceroute. Capture ping and trace route PDUs using a network


protocol analyzer and examine.
Write a HTTP web client program to download a web page using
2. TCP sockets
Applications using TCP sockets like: a) Echo client and echo server
3. 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.

Study of Network simulator (NS) and Simulation of Congestion


7. 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)


NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Exp No: 1
DATE: NETWORKING COMMANDS
AIM:
To study the basic networking commands.

NETWORKING COMMANDS:

C:\>arp –a: ARP is short form of address resolution protocol, It will show the IP address of your
computer along with the IP address and MAC address of your router.

C:\>hostname: This is the simplest of all TCP/IP commands. It simply displays the name of yourcomputer.

C:\>ipconfig: The ipconfig command displays information about the host (the computer yoursitting
at)computer TCP/IP configuration.

C:\>ipconfig /all: This command displays detailed configuration information about your TCP/IP
connection including Router, Gateway, DNS, DHCP, and type of Ethernet adapter inyour system.

C:\>Ipconfig /renew: Using this command will renew all your IP addresses that you are currently(leasing)
borrowing from the DHCP server. This command is a quick problem solver if you are having connection
issues, but does not work if you have been configured with a static IP address.

C:\>Ipconifg /release: This command allows you to drop the IP lease from the DHCPserver.

C:\>ipconfig /flushdns: This command is only needed if you‟re having trouble with your networksDNS
configuration. The best time to use this command is after network configuration frustration sets in, and
you really need the computer to reply with flushed.

C:\>nbtstat –a: This command helps solve problems with NetBIOS name resolution. (Nbtstands
for NetBIOS over TCP/IP)

C:\>netdiag: Netdiag is a network testing utility that performs a variety of network diagnostic tests,allowing
you to pinpoint problems in your network. Netdiag isn‟t installed by default, but can be installed from the
Windows XP CD after saying no to the install. Navigate to the CD ROM drive letter and open the
support\tools folder on the XP CD and click the setup.exe icon in the support\tools folder.

C:\>netstat: Netstat displays a variety of statistics about a computers active TCP/IP connections. This tool
is most useful when you‟re having trouble with TCP/IP applications such as HTTP, andFTP.

C:\>nslookup: Nslookup is used for diagnosing DNS problems. If you can access a
resource by specifying an IP address but not it‟s DNS you have a DNS problem.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

C:\>pathping: Pathping is unique to Window‟s, and is basically a combination of the Ping and Tracert
commands. Pathping traces the route to the destination address then launches a 25 second test of each router
along the way, gathering statistics on the rate of data loss along each hop.

C:\>ping: Ping is the most basic TCP/IP command, and it‟s the same as placing a phone call to your best
friend. You pick up your telephone and dial a number, expecting your best friend to replywith “Hello” on the
other end. Computers make phone calls to each other over a network by usinga Ping command. The Ping
commands main purpose is to place a phone call to another computer onthe network, and request an answer.
Ping has 2 options it can use to place a phone call to another computer on the network. It can use the computers
name or IP address.

C:\>route: The route command displays the computers routing table. A typical computer, with a single
network interface, connected to a LAN, with a router is fairly simple and generally doesn‟tpose any
network problems. But if you‟re having trouble accessing other computers on your network, you can use
the route command to make sure the entries in the routing table are correct.

C:\>tracert: The tracert command displays a list of all the routers that a packet has to go through toget from
the computer where tracert is run to any other computer on the internet.

RESULT:

Thus the above list of primitive has been studied.


NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Exp No : 2
DATE: Write a HTTP web client program to download a web page using TCP
sockets
AIM:

To Write a HTTP web client program to download a web page using TCP sockets.

ALGORITHM:

CLIENT SIDE:
1) Start the program.
2) Create a socket which binds the Ip address of server and the port address to acquire
service.
3) After establishing connection send the url to server.
4) Open a file and store the received data into the file.
5) Close the socket.
6) End the program.

SERVER SIDE

1) Start the program.


2) Create a server socket to activate the port address.
3) Create a socket for the server socket which accepts the connection.
4) After establishing connection receive url from client.
5) Download the content of the url received and send the data to client.
6) Close the socket.
7) End the program.

PROGRAM
import javax.swing.*;
import java.net.*; import
java.awt.image.*;import
javax.imageio.*; import
java.io.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class HTTPClient
{
public static void main(String args[]) throws Exception

{
Socket soc; BufferedImage
img = null;soc=new
Socket("localhost",4000);
System.out.println("Client is running.");try
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
{
System.out.println("Reading image from disk.");
img = ImageIO.read(new File("digital-image-processing.jpg"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(img, "jpg", baos);
baos.flush();byte[] bytes = baos.toByteArray();
baos.close(); System.out.println("Sending image to
server."); OutputStream out = soc.getOutputStream();
DataOutputStream dos = new DataOutputStream(out);
dos.writeInt(bytes.length);
dos.write(bytes, 0, bytes.length);
System.out.println("Image sent to server.");
dos.close();
out.close();
}
catch (Exception e)
{
System.out.println("Exception: " + e.getMessage());
soc.close();
}
soc.close();
}
}

SERVER PROGRAM

import java.net.*;
import java.io.*;
import java.awt.image.*;
import javax.imageio.*;
import javax.swing.*;
class HTTPServer
{
public static void main(String args[]) throws Exception
{
ServerSocket server=null;
Socket socket;
server=new ServerSocket(4000);
System.out.println("Server Waiting for image");
socket=server.accept(); System.out.println("Client
connected."); InputStream in =
socket.getInputStream();
DataInputStream dis = new DataInputStream(in);int
len = dis.readInt();
System.out.println("Image Size: " + len/1024 + "KB");
byte[] data = new byte[len];
dis.readFully(data);
dis.close();
in.close();
InputStream ian = new ByteArrayInputStream(data);
BufferedImage bImage = ImageIO.read(ian); JFrame f =
new JFrame("Server");
ImageIcon icon = new ImageIcon(bImage);
JLabel l = new JLabel();
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
l.setIcon(icon);
f.add(l);
f.pack(); f.setVisible(true);
}
}

RESULT:
The webpage is successfully downloaded and the contents are displayed and verified.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
Exp No :3a
DATE: SOCKET PROGRAM FOR ECHO

Aim
To implement echo server and client in java using TCP sockets.

Algorithm :
Server
1. Create a server socket.
2. Wait for client to be connected.
3. Read text from the client
4. Echo the text back to the client.
5. Repeat steps 4-5 until „bye‟ or „null‟ is read.
6. Close the I/O streams
7. Close the server socket
8. Stop

Client
1. Create a socket and establish connection with the server
2. Get input from user.
3. If equal to bye or null, then go to step 7.
4. Send text to the server.
5. Display the text echoed by the server
6. Repeat steps 2-4
7. Close the I/O streams
8. Close the client socket
9. Stop

PROGRAM:

ECHO CLIENT
import java.net.*;
import java.io.*;
public class
echoclient
{
public static void main(String[] args) throws IOException
{
BufferedReader fromServer = null, fromUser = null;
PrintWriter toServer = null;
Socket sock =
null;try {
if (args.length == 0)
sock = new Socket(InetAddress.getLocalHost(), 4000);
else
sock = new Socket(InetAddress.getByName(args[0]), 4000);
fromServer = new BufferedReader(new InputStreamReader(sock.getInputStream()));
fromUser = new BufferedReader(new InputStreamReader(System.in));
toServer = new PrintWriter(sock.getOutputStream(), true
String Usrmsg, Srvmsg;
System.out.println("Type \"bye\" to quit");
while (true)
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
{

System.out.print("Enter msg to server : ");


Usrmsg = fromUser.readLine();
if (Usrmsg==null || Usrmsg.equals("bye"))
{

toServer.println("bye")
;break;
}
else
toServer.println(Usrmsg)
;
Srvmsg = fromServer.readLine();
System.out.println(Srvmsg);
}
fromUser.close();
fromServer.close(
);toServer.close();
sock.close();
}
catch (IOException ioe)
{
System.err.println(ioe);
}
Echo Server:
import java.net.*;
import java.io.*;
public class
echoserver
{
public static void main(String[] arg) throws IOException
{
ServerSocket sock = null;
BufferedReader fromClient = null;
OutputStreamWriter toClient = null;
Socket client = null;
try {
sock = new ServerSocket(4000);
System.out.println("Server Ready");
client = sock.accept();
System.out.println("Client Connected");
FromClient = new BufferedReader(new InputStreamReader(client.getInputStream()));
toClient = new OutputStreamWriter(client.getOutputStream());
String line;
while (true)
{
line = fromClient.readLine();
if ( (line == null) || line.equals("bye"))
break;
System.out.println ("Client [ " + line + " ]");
toClient.write("Server [ "+ line +" ]\n");
toClient.flush();
}
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

fromClient.close();toClient.close(); client.close(); sock.close();


System.out.println("Client Disconnected");
}
catch (IOException ioe)
{
System.err.println(ioe);
}}}

RESULT:

Thus the program for simulation of echo server was written & executed.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Exp No:3b
DATE: CLIENT- SERVER APPLICATION FOR CHAT

Aim
To implement a chat server and client in java using TCP sockets.
Algorithm
Server
1. Create a server socket
2. Wait for client to be connected.
3. Read Client's message and display it
4. Get a message from user and send it to client
5. Repeat steps 3-4 until the client sends "end"
6. Close all streams
7. Close the server and client socket
8. Stop
Client
1. Create a client socket and establish connection with the server
2. Get a message from user and send it to server
3. Read server's response and display it
4. Repeat steps 2-3 until chat is terminated with "end" message
5. Close all input/output streams
6. Close the client socket
7. Stop

PROGRAM:
// TCP Chat Server--tcpchatserver.java
import java.io.*;
import
java.net.*; class
tcpchatserver
{
public static void main(String args[])throws Exception
{
PrintWriter toClient;
BufferedReader fromUser,
fromClient;try
{
ServerSocket Srv = new
ServerSocket(5555);
System.out.print("\nServer started\n");
Socket Clt = Srv.accept();
System.out.println("Client connected");
toClient = new PrintWriter(new BufferedWriter(new OutputStreamWriter(Clt.getOutputStream())),
true);fromClient = new BufferedReader(new InputStreamReader(Clt.getInputStream()));
fromUser = new BufferedReader(new
InputStreamReader(System.in));String CltMsg, SrvMsg;
while(true)
{
CltMsg=
fromClient.readLine();
if(CltMsg.equals("end"))
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
break;
else
{
System.out.println("\nServer <<< " +
CltMsg);System.out.print("Message to
Client : "); SrvMsg = fromUser.readLine();
toClient.println(SrvMsg);
}}
System.out.println("\nClient
Disconnected");fromClient.close();
toClient.close();

fromUser.clos
e();Clt.close();

Srv.close();
}
catch (Exception E)
{
System.out.println(E.getMessage());
}}}

// TCP Chat Client--tcpchatclient.java


import
java.io.*;
import
java.net.*;class
tcpchatclient
{
public static void main(String args[])throws Exception
{
Socket Clt; PrintWriter toServer;
BufferedReader fromUser,
fromServer;try {
if (args.length > 1)
{
System.out.println("Usage: java
hostipaddr");System.exit(-1); }
if (args.length == 0)
Clt = new
Socket(InetAddress.getLocalHost(),5555);else
Clt = new Socket(InetAddress.getByName(args[0]), 5555);
toServer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(Clt.getOutputStream())),
true);fromServer = new BufferedReader(new InputStreamReader(Clt.getInputStream()));
fromUser = new BufferedReader(new
InputStreamReader(System.in));String CltMsg, SrvMsg;
System.out.println("Type \"end\" to Quit");
while (true) { System.out.print("\nMessage to Server :
");CltMsg = fromUser.readLine();
toServer.println(CltMsg);
if (CltMsg.equals("end"))
break; SrvMsg =
fromServer.readLine();
System.out.println("Client <<< " + SrvMsg);
}}
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

catch(Exception E) {
System.out.println(E.getMessage());
}}}

RESULT:
Thus the above program a client-server application for chat using TCP / IP was
executed and successfully.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
Exp No: 4
DATE: Simulation of DNS using UDP sockets.

AIM:
To write a program to Simulation of DNS using UDP sockets..

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
willsend NACK signal to client.
6. Stop the program

PROGRAM:

/ UDP DNS
Server
Udpdnsserver
java import
java.io.*;import
java.net.*;
public class udpdnsserver
{
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"};
System.out.println("Press Ctrl + C to Quit");
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);
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

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();
}
}
}

//UDP DNS Client –


Udpdnsclient
.java import java.io.*; import java.net.*;
public class udpdnsclient
{
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();
}
}
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

RESULT:

Thus the above program a client-server application for chat using UDP was executed and
successfully.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Exp No: 5
DATE : Use a tool like Wireshark to capture packets and examine the packets

AIM :

To Implement a tool like Wireshark to capture packets and examine the packets.

Algorithm:

Wireshark Packet Capture and Examination:

1. Initialization:

 Launch Wireshark application.

2. Select Network Interface:

 Prompt user to select the network interface(s) to capture packets from.


 Start capturing packets on the selected interface(s).

3. Optional: Apply Filters (if specified

 If the user specifies filter criteria, apply filters to capture packets based on the specified conditions (e.g.,
IP addresses, protocols, ports).
 Begin capturing packets based on the applied filters.

4. Capture Packets:

 Continuously capture packets from the selected network interface(s).


 Store captured packets in a buffer for analysis.

5. Examine Packets:

 Display captured packets in the Wireshark interface.


 Provide detailed packet information, including source and destination IP addresses, ports, protocols,
packet payloads, etc.
 Allow users to select individual packets to view detailed packet contents.

6. Display Summary Statistics:

 Calculate and display summary statistics on captured packets, such as total packets captured, packet
rate, protocol distribution, etc.
 Update statistics in real-time as new packets are captured.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

7. Stop Packet Capture:

 Provide an option to stop packet capture when desired.


 Release network interface(s) and stop capturing packets.

8. End Session:

 Close the Wireshark application.

Program :

import jpcap.*;
import jpcap.packet.*;

public class PacketCaptureExample {

public static void main(String[] args) {


try {
// Obtain a list of network interfaces
NetworkInterface[] devices = JpcapCaptor.getDeviceList();

// Select a network interface for packet capture (e.g., devices[0])


int index = 0; // Change this index as needed
NetworkInterface device = devices[index];

// Open a Jpcap capture session on the selected network interface


int snapshotLength = 65536; // Maximum packet length to capture
int timeout = 50; // Packet capture timeout in milliseconds
int promiscuousMode = Jpcap.MODE_PROMISCUOUS; // Capture mode
JpcapCaptor captor = JpcapCaptor.openDevice(device, snapshotLength, false, timeout);

System.out.println("Starting packet capture...");

// Start capturing packets


while (true) {
// Capture a single packet
Packet packet = captor.getPacket();

// Check if the packet is null (no packets captured within timeout)


if (packet == null) {
continue;
}

// Print out packet details


System.out.println("Packet Captured:");
System.out.println(packet.toString());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Result :

Thus the Wireshark to capture packets and examine the packets has been implemented.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Exp No : 6a

DATE: Write a code simulating ARP protocols.

AIM
To implement Address Resolution Protocol .

ALGORITHM

CLIENT SIDE

 Establish a connection between the Client and Server. Socket


ss=new Socket(Inet Address. get Local Host(),1100);
 Create instance output stream writer
 Print Writer ps=new PrintWriter(s. get Output Stream(),true);
 Get the IP Address to resolve its physical address.
 Send the IPAddress to its output Stream.ps.println(ip);
 Print the Physical Address received from the server.

SERVER SIDE

 Accept the connection request by the client.


 Server Socket ss=new Server Socket(2000);Socket s=ss.accept();
 Get the IP address from its input stream.
 Buffered Reader br1=new Buffered Reader(new Input Stream Reader
(s.getInputStream()));ip=br1.readLine();
 During runtime execute the process Runtime r=Runtime.get
Runtime();Process p=r.exec("arp -a "+ip);
 Send the Physical Address to the client.

PROGRAM ARP

CLIENT

import java.io.*;
import java.net.*;

class ArpClient
{
public static void main(String args[])throws IOException
{
try
{
Socket ss=new Socket(InetAddress.getLocalHost(),1100);
PrintStream ps=new PrintStream(ss.getOutputStream());
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

BufferedReader br=new BufferedReader(newInputStreamReader(System.in));String ip;


System.out.println("Enter the IPADDRESS:");

ip=br.readLine();
ps.println(ip);
String str,data;
BufferedReader br2=new
BufferedReader(newInputStreamReader(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);

}}}

ARP SERVER

import java.io.*; import


java.net.*;

class ArpServer
{
public static void main(String args[])throws IOException
{
try
{
ServerSocket ss=new ServerSocket(1100);
Socket s=ss.accept();
PrintStream ps=new PrintStream(s.getOutputStream());
BufferedReader br1=new BufferedReader(newInputStreamReader(s.getInputStream()));String ip;
ip=br1.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("arp -a "+ip);
BufferedReader br2=new BufferedReader(newInputStreamReader(p.getInputStream()));String
str;
while((str=br2.readLine())!=null)
{
ps.println(str);
}}
catch(IOException e)
{
System.out.println("Error"+e); }}}
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

RESULT
Thus the implementation of ARP is done & executed successfully.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Exp No : 6b
DATE: Write a code simulating RARP protocols.

AIM:
To write a java program for simulating RARP protocols.
ALGORITHM:

CLIENT

1. Start the program


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

SERVER

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.

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=newDatagramPacket(sendbyte,sendbyte.length,addr,1309);
client.send(sender);
DatagramPacket receiver=new DatagramPacket(receivebyte,receivebyte.length);
client.receive(receiver);
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

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();
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=newDatagramPacket(sendbyte,sendbyte.length,addr,port);

server.send(sender);
break;
}
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

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

}
}
}

RESULT:

Thus the implementation of RARP is done & executed successfully.


NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Exp No: 7
DATE: Study of Network simulator (NS) and Simulation of Congestion
Control Algorithms using NS.

OBJECTIVE:

To study of network simulator (ns) and simulation of congestion control algorithmsusing ns.

SYSTEM REQUIREMENTS:

 PC: Pentium or higher

 One LAN card onboard or on PCI slot with 10/100Mbps speed.128MB


RAM

 500MB free space on Harddrive


CD ROM drive

 Serial port, LPT port & USB port installed on system OperatingSystem:
Windows 2000 or higher

THEORY:

LTS-01 Local area network / wireless local area network trainer system:

It is designed to help students understand the basic concepts, modes of operation and protocols involved in
networking. The trainer has integrated hardware flow control on panel board for better understanding of different
types of LAN topologies involved in networking. The trainer system is provided with windows-based user friendly
software with analysis of protocols, different layers, network and measurement of error rate and throughput.

Students can easily do connections in different topologies and can learn actual data transfer eitherthrough hardware or
through simulated network concept. Facility is provided into system software to introduce errors into packets being
sent and analyze the effect of error on different protocols and hencefind the effect on through put graph as well.

Trainer and its various types of experimentation using this system. This system works into server-client base. For any
topology user has to select one server and select the network type whether it is LAN or WLAN. To understand the
topology concept user can connect two or more clients to hardware. Depending on the topology selected user will have
option to select protocols for the selectedtopology. Upon selection of protocol user can then create network of
connected computers.

In any network which is created by user server can send or can communicate with any of the clientshowever clients can
communicate only with server, no client to client communication is possible. Transmitter port protocol & network
analysis can be done after communication is over between serverand clients. Throughput v/s Packet size graph can be
plotted for which at least two file transfers shouldbe carried out. This plot can be printed to attach in the lab exercise
sheet.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

For the LAN network LAN cards must be installed prior to start work on this trainer. For wire lessLAN USB ports
should be available on the computers which are to be used for experimentation.In WLAN wireless access cards gets
connected to computer USB ports and access point gets connectedto hardware device.

L-SIM LAN Protocol Simulator & Analyzer Software:

It is designed to teach the basic concepts, topologies & various protocols involved in networking.The software is
provided with analysis of protocols, different layers, network and measurement of error rate and throughput. Facility
is provided to introduce errors into packets beingsent and analyze the effect of error on different protocols and hence
find the effect on throughput graph as well. Software is supported with neat operating instruction manual and online
help.

MODEL WINDOW DIAGRAM FOR L-SIM

N-S IM Network simulation software:

It is developed to provide basic understanding and implementation of various advanced conceptsin networking. The
software provides an opportunity to understand network fundamentals through animations & simulations. The
simulation provides for network experimentation with various LAN and WAN protocols, network devices, routers,
encryption, decryption, file transfer, error insertion andanalysis of error rate and throughput etc. This software covers
Ethernet LAN, wireless LAN and router. All networking theory is explained using simulation and animation.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

MODEL WINDOW DIAGRAM FOR N-SIM

Rapid advances in computer & communication technologies have resulted in the increasing merger of these two
fields. The lines have blurred among computing, switching & digital transmission equipment; and the same digital
techniques are being used for data, audio & video transmission. Merging & evolving technologies, coupled with
increasing demands for efficient & timely collection,processing & dissemination of information, have led to the
development of integrated systems that transmit & process all types of data.

These intgrated systems are broadly divided as follows

- DATA COMMUNICATION dealing with transmission, transmission media, signal decoding, interfacing, data
link control & multiplexing

- NETWORKING deals with the technology & architecture of communication network

- COMMUNICATION PROTOCOLS which covers the architecture as well


as analysis of individual protocols at various layers depending on the hardware & software Network laboratory is
designed & developed considering the curriculum offered by Anna University. Trainersoffered under network
laboratory are designed for students at all level to study and understand all theconcepts of data communication, data
transfer using serial and parallel ports, Ethernet and wireless LAN with complete protocol understanding and actual
hands on with hardware & software with ease.

Network laboratory consists of DCT-03 Data communication trainer kit, LTS- 01 LAN / Wireless LAN training
system, L-SIM LAN / WLAN protocol simulator and analyzer software & N-SIM Network simulation software.

The DCT-03: Data communication trainer is a unique trainer kit for the development of exercises and theoretical-
experimental courses to understand the basic concept and working of modes and protocols in serial and parallel
communication.

The trainer kit consists of functional blocks for serial and parallel communicationsystem.

The trainer kit is highly innovative from a technological as well as an educational point of view. Thetrainer kit is used
as “basic unit” to examine all the peculiar operating standards of serial and parallelcommunication system. The only
external equipments required are two Computers with serial and parallel communication ports and an Oscilloscope.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Utmost care has been laid in the designand quality control of all circuits, to ensure the repeatability of the results of
the experiments.

Data communication is a term referred when the sender and receiver are digital devices, which communicate with
each other by means of binary information. The objective of this trainer kit is to clear the various aspects of the data
communications which comprise of

 The information source or sender.


 The medium for carrying information.
 The information receiver.
 The communication protocols, which ensure proper transfer of data.

With an increasing demand in information exchange the field of data communication technique is emerging as the
only solution, to satisfy the various needs of today‟s communication sector and to achieve very high bandwidth along
with highest accuracy. The communication media is shifting from analog signal transfer towards digital
communication.

With PC becoming the biggest storage devices in digital form, it becomes the main source and destination for
information exchange. With rapid growth in both the communication technologies aswell as computer hardware and
software technologies, these two fields are merged to form a data communication network. Now the digital data is
used for data, voice and image transmission.

Depending upon the application the communication link can be of point to point communication between two devices
or a multipoint communication between at least 3 devices and data transfer canbe serial or in parallel form.

RESULT:

The study of network simulator (ns) and simulation of congestion control algorithmsusing
ns is executed and verified.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Exp No : 8
DATE: Study of TCP/UDP performance using Simulation tool.
AIM:

To 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 protocolsin 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 onthe 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 toits 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 forthe end-to-end transfer of data over the
network and is the four of the OSI model. The Transport layermeets 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.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Comparison Between TCP And UDP

Service TCP UDP


Flow controls The receiver can signal ACKs, which are used in
the sender to slow down. TCP to control packet flow, are not
returned.
Connection setup It takes time, but with TCP No connection is required.
reliability is ensured.

Guaranteed Returns acknowledgments. UDP does not return ACKs, the


message delivery receiver can‟t signal that packets have
been successfully
delivered.
Congestion Network devices can take advantage If ACK, are missing, the network
controls of TCP ACK to control the behavior cannot signal congestion to the sender.
of sender.

A big difference between TCP and UDP is the congestion control algorithm. For the TCP, congestionalgorithm 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 e.g. The UserDatagram Protocol
(UDP) provides an unreliable connectionless delivery service using IP to transportmessages 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‟tprovide flow control, reliability or error recovery and the retransmissions of
data in case of errors mustbe ordered by other protocols. UDP is designed for applications that do not have to recompose
the datasegment 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 toretransmitted again. On the other side
this applications are not slow down by the confirmation processand 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 nopacket latency and
packet discard ratio of 0% while packets traverse thru the WAN. The task responsetime, in seconds, Fig. 1, shows how
long the application need to be completed. The time when usingTCP to complete the task is greater that the one using
UDP. When using TCP, source and destinationneed 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‟tperform this tasks.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

TC

UD

1. Response time for TCP and UDP

TC

UD

2. Traffic received (packets/sec) for the server


NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

TC TC

UD UD

3. Traffic/Link utilization from the WAN to the server

TC

UD

Link utilization with a 0.5% packets discard ratio


NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

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 ontwo 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 planto conduct several studies regarding packets routing in computer
networks to improve the fairnessof data transmissions using different network protocols.

RESULT:

Thus the TCP/UDP performance has been simulated successfully using OPNET.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
Exp No : 9a
DATE: Simulation of Distance Vector Routing algorithm.

AIM:

To implement the Distance – Vector Routing Algorithm

APPARATUS REQUIRED:

1. VI-RTSIM software.

2. Personal computer.

THEORY:

Distance Vector Algorithm:

 A Distance vector routing, each router periodically share its knowledge about the
entirenetwork with it‟s neighbors.
 The three keys to under this algorithm are

 Knowledge about the whole network.


 Routing only to neighbor.
 Information sharing at regular intervals.
Knowledge about the whole work:

 Each router shares its knowledge about entire network. It sends all of its collected
knowledgeabout the network to its neighbors.
Routing only to neighbor:

 Each router periodically sends its knowledge about the network only to those routers to
whichit has direct links. It sends whatever knowledge it has.
Information sharing at regular intervals:

 The every 30 seconds, each router sends its information about the whole network

to itsneighbors.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Sharing Information:

 LAN‟s are connected by router, represented by the assuming A, B, C, D, E and F.


 Distance vector routing simplifies the routing process by assuming a lost of one unit for
everylink.
 The efficiency of transmission is a function only of the number of links required to
reach adestination. In this, the cost on hop count.

Routing Table:

 Each router gets its initial knowledge about the internet work and how it uses
sharedinformation to update that knowledge.
 The routing table has e columns network lost router ID.
 The first block is final destination of packet.
 The second block is no of hop count.
 The third block is that to which a packet delivers must.
Updating algorithm:

 Updating algorithm requires that the router first has one hop to the hop count field for
eachadvertised router.
 The router should apply the below rules to each router, if the advertised destination is
not inrouting table
 If next hop field is same, router should replace the entry in the table with advertised one.
 If next hop field is same, router should replace the entry in the table with advertised one.
 . If next hop field is not the same, advertised hop count is smaller than the one in the table,
therouter should replace the entry in the table with new one.
 IF advertised hop count is not smaller, the router should do no routing.
PROCEDURE

1. Open VI-RTSIM software from desktop


2. Click the Simulation menu bar
3. Select the “Distance – Vector Routing Algorithm” option from Routing algorithm menu bar.
4. Network with routers connected through link is drawn by using option in editor(add router,
joinlink, delete router, delete link, Add caption to link, add caption to router)
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

5. Select any two nodes to find the shortest distance between them.
6. Click the Find path Button to run the program.
7. Now the shortest paths between the two nodes are calculated.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

RESULT:

Thus Distance Vector routing algorithm has been implemented and shortest-path has been
circulated.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Exp No : 9b

DATE: Simulation of Link State Routing Algorithm.

AIM:

To implement the Link State Routing Algorithm

REQUIRED:

1. VI-RTSIM software.

2. Personal computer.

THEORY:

Link State Vector Algorithm:

 In Link state routing, each router share its information of its neighbors with every other
routerin the inter-network.
Knowledge about the neighborhood:

 Instead of sending its entire routing table, a router sends information about its neighborhoodonly.
To all router:

 Each router send this information to every other router on the internetworking, not just to its
neighbors.
 If s does so by a process called “flooding” it means that a router sends its information.
Information sharing when there is a Change:

 Each router sends out information about the neighbors when there is a change.
Information sharing:
 Link state routing process use the same internet work as distance vector algorithm.
 Here each other sends its knowledge about is neighbors to every other router in the internet work.
 Cost is applied only by routers and not by any other station on a network, if cost was added by every
station, instead of by routers alone, it would accumulate unpredictably.
 Cost is applied as a packet leaves the router rather then as if enters. Most networks are broadcast
networks. When a packet is in network every station, including the router, can pick itup, we cannot
assign any cost to a packet.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
Link state packet:

 When a router floods the network with information about its neighborhood, it is said
to beadvertising. The basis of this advertising is a short packet called a link state
packet (LSP).
Advertiser Network Cost Neighbor

Getting information about neighbors:

 A router gets its information about its neighbors by periodically sending them a short
greetingpacket.
 If the neighbor responds to the greeting as expected, it is assumed to be alive and functioning.
Initialization:

 Imagine that all routers in our sample internet work come up at the same time.
 Each router sends a greeting packet to its neighbors to find out the state of each link.
Link – State Database:

 Every router every LSP and puts the information into a link-state database.
 Because every router receives the same LSPs every router builds the same database.
 It stores this database on its disk and uses it to calculate its routing table. If a router is
added tobe deleted from the system, the whole database must be shared for fast updating.

PROCEDURE

1. Open VI-RTSIM software from desktop


2. Click the Simulation menu bar
3. Select the “Link State Routing Algorithm” option from Routing algorithm menu bar.
4. Network with routers connected through link is drawn by using option in editor(add
router, joinlink, delete router, delete link, Add caption to link, add caption to router)
5. Select any two nodes to find the shortest distance between them.
6. Click the Find path Button to run the program.
7. Now the shortest paths between the two nodes using link state routing
algorithm was calculated.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

RESULT:
Thus Link-State routing algorithm has been implemented and shortest-path has been circulated.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

Exp No : 10
DATE: Simulation of error correction code (like CRC)
AIM:

To implement and check the error detection/error correction techniques in networks using a c program.

Error Detection


Bit errors occur in frames due to electrical interference or thermal noise.

Detecting errors is one part of the problem; correcting errors is the other.

What happens when an error is detected?

Two basic approaches:
– Notify the sender that message is corrupt so the sender can retransmit it; ( most often
used in every day applications)
– Use an error-correcting code to reconstruct the correct message
Transmission Errors

· External electromagnetic signals can cause incorrect delivery of data

- · Data can be received incorrectly


- · Data can be lost
- · Unwanted data can be generated
· Any of these problems are called transmission errors

Error Detection

•Detecting Transmission Errors: basic idea is to add redundant information to a frame that can
determine if errors have been introduced.
Error Correction or Error Detection?

• When error is detected, frame is discarded and resent, using bandwidth and causing latency,
waiting for its arrival.
• Error correction requires additional bit to be sent with every frame.
• Correction is useful when
• 1) errors are probable or
• 2) the cost of retransmission is too high
Cyclic Redundancy Check (CRC)

CRC is a different approach to detect if the received frame contains valid data. This techniqueinvolves
binary division of the data bits being sent. The divisor is generated using polynomials. The sender
performs a division operation on the bits being sent and calculates the remainder. Before sending the
actual bits, the sender adds the remainder at the end of theactual bits. Actual data bits plus the remainder
is called a codeword. The sender transmits databits as code words.
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

At the other end, the receiver performs division operation on codewords using the same CRC divisor. If the
remainder contains all zeros the data bits are accepted, otherwise it is consideredas there some data corruption
occurred in transit.

PROCEDURE:

 Start the process.


 Give the data which is the message.
 Compile and run the program.
 Enter the received hamming code.
 The error is corrected codeword.

PROGRAM FOR CODE GENERATION FOR ERROR DETECTION AND CORRECTION

import java.util.Scanner;
class CRC
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int m,g[],n,d[],z[],r[],msb,i,j,k;

System.out.print("ENTER NUMBER OF DATA BITS:\n");


n=sc.nextInt();
System.out.print("ENTER NUMBER OF GENERATOR BITS:\n");
m=sc.nextInt();
d=new int[n+m];
g=new int[m];
System.out.print("ENTER DATA BITS:\n");
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

for(i=0;i<n;i++)
d[i]=sc.nextInt();
System.out.print("ENTER GENERATOR BITS:\n");

for(j=0;j<m;j++)
g[j]=sc.nextInt();

for(i=0;i<m-1;i++)
d[n+i]=0;
r=new int[m+n];

for(i=0;i<m;i++)
r[i]=d[i];
z=new int[m];

for(i=0;i<m;i++)
z[i]=0;

for(i=0;i<n;i++)
{
k=0;
msb=r[i];
for(j=i;j<m+i;j++)
{
if(msb==0)
r[j]=xor(r[j],z[k]);
else
r[j]=xor(r[j],g[k]);
k++;
}
r[m+i]=d[m+i];
}

System.out.print("\nTHE CODE BITS ADDED ARE:");


for(i=n;i<n+m-1;i++)
{
d[i]=r[i];
System.out.print(d[i]);
}
System.out.println("");

System.out.print("\nTHE CODE DATA IS:");


for(i=0;i<n+m-1;i++)
{
System.out.print(d[i]);
}
System.out.println("");
}
NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

public static int xor(int x,int y){


if(x==y)
return(0);
else
return(1);
}

RESULT:

Thus the error detection/error correction techniques were implemented successfully.


NADAR SARASWATHI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

You might also like