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

CN Practical

The document outlines various experiments related to networking, including familiarization with Windows network commands, setting up Local Area Networks (LANs) using Cisco Packet Tracer, and implementing a mini search engine and a simple web server in Java. Each experiment details the aim, requirements, procedures, and results, demonstrating successful execution and verification of network configurations and protocols. The document serves as a comprehensive guide for practical networking exercises and programming implementations.

Uploaded by

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

CN Practical

The document outlines various experiments related to networking, including familiarization with Windows network commands, setting up Local Area Networks (LANs) using Cisco Packet Tracer, and implementing a mini search engine and a simple web server in Java. Each experiment details the aim, requirements, procedures, and results, demonstrating successful execution and verification of network configurations and protocols. The document serves as a comprehensive guide for practical networking exercises and programming implementations.

Uploaded by

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

Exp No: 1

Date : Familiarizing with Windows Network Commands

AIM:

To familiarize with windows network commands and their outputs.

HOW TO EXECUTE:

1. Open the Command prompt by typing “CMD” in the Run Dialogue

2. Once the Command prompt opens type the commands

COMMAND DESCRIPTION

S.no Command Use


1. ipconfig This command can be utilized to verify a network
connection as well as verify your network settings
2. Netstat Displays active e TCP connections, ports on which the
computer is listening, Ethernet statistics, the IP
routing
table etc.
3. Tracert The tracert command is used to visually see a network
packet being sent and received and the amount of
hops
required for that packet to get to its destination.
4. Ping Helps in determining TCP/IP networks ip address as well
as determine issues with the network and assists in
resolving them.
5. Pathping Provides information about network latency and network
loss at intermediate hops between a source
and destination pathping sends.
6. Nslookup Displays information that you can use to diagnose
Domain Name System (DNS) infrastructure
1
7. Nbtstat MS_DOS utility that displays protocol statistics &
current TCP/IP connections using NBT
8. getmac DOS command used to show both local & remote MAC
addresses when run with no parameters (i.egetmac) it
displays MAC addresses for the local system. When run
with the /s parameter (eg. Getmac /s \\too> it displays
MAC address for the remote computer.

Output:

ipconfig

2
3
4
5
6
Result:

Thus the various network commands are executed and the output is verified.

7
Exp No: 2 ANALYZING THE PERFORMANCE OF VARIOUS
CONFIGURATIONS AND PROTCOLS OF LAN
Date :
ESTABLISHING A LOCAL AREA NETWORK (LAN)

AIM
To set up a Local Area Network using Cisco Packet Tracer.

REQUIREMENTS:
 Three Windows PC or 3 Linux PC.
 One Switch or One Hub.
 Three Copper-Straight Line LAN (cat-5) Cables.
 Power Supply.
 Cisco Packet Tracer 6.0.1

PROCEDURES:
1. Open CISCO PACKET TRACER software.
2. Draw The Three PC using END Device Icons.
3. Draw The CISCO 24 Port Switch Using Switch icon lists.
4. Make The Connections using Copper-Straight-Through Ethernet Cables.
5. Enter The IP Address To Each Machine.
6. Check the Network Connections using Add Simple PDU(P).

8
NETWORK TOPOLOGY:

HOST PC0 IP ADDRESS:

9
HOST PC1 IP ADDRESS:

HOST PC2 IP ADDRESS:

10
VERIFY LAN NETWORK CONNECTIVITY:
Using Add Simple PDU(p), Click the mail icon and then drop one mail to PC0
and another mail to PC1. If the resultant window show the successful delivery then
network connectivity is successful or up.

HOST PC0 TO HOST PC1:

11
HOST PC1 TO HOST PC2:

12
RESULT:

Thus the LAN connection is established, hosts are configured, the


communications among the machines are verified and manipulated successfully.

13
Exp No: 3 ANALYZING THE PERFORMANCE OF VARIOUS
CONFIGURATIONS AND PROTCOLS IN LAN
Date :
CONNECTING TWO LANs USING ROUTER WITH STATIC ROUTER

OBJECTIVE
To establish connection between two LANs by extending routing connection
using router.

REQUIREMENTS:
 Four windows PC or Four Linux PC.
 Two Switch (8 port) or 2 Hub.
 Six Straight Line LAN (cat-5) Cables with RJ-45 Sockets.
 Power supply
 Basic Network Configuration Commands. For Router, Switch and PCs.
 Cisco Packet Tracer 6.0.1
 Cisco Router(Model 1841)
 One console connection of router with PC to configure router.

PROCEDURES:
 Open the CISCO PACKET TRACER software.
 Draw the 4 PC using End Device Icons.
 Draw the 2 CISCO 24 Port Switch using Switch icon lists.
 Draw the Cisco Generic Routers using Router icon lists.
 Make the Connections using Straight-Through Ethernet Cables.
 Configure Router R0.
 Enter the IP Address to Each Machine.
 Check the Connections using Add Simple PDU(P).

14
NETWORK TOPOLOGY:

PC0 IP CONFIGURATION ADDRESS:

15
PC1 IP CONFIGURATION ADDRESS:

PC2 IP CONFIGURATION ADDRESS:

16
PC3 IP CONFIGURATION ADDRESS:

ROUTER 0 CONFIGURATION:

Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with
CNTL/Z.
Router(config)#interface fastethernet 0/0
Router(config-if)#ip address 1.0.0.1 255.0.0.0
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface
FastEthernet0/0, changed state to up
Router(config-if)#exit

Router(config)#interface fastethernet 0/0


Router(config-if)#interface fastethernet 1/0
Router(config-if)#ip address 2.0.0.1 255.0.0.0
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up

17
%LINEPROTO-5-UPDOWN: Line protocol on Interface
FastEthernet1/0, changed state to up
Router(config-if)#exit

VERIFY LAN NETWORK CONNECTIVITY


Using Add Simple PDU(p), Click the mail icon and then drop one mail to one
of the PC in first LAN and another mail to PC in another LAN. If the resultant
window show the successful delivery of the mail then network connectivity is
successful.

PC0 TO PC2

18
PC1 TO PC3

19
CONCLUSION:

Thus two LANs are connected using router with static routes and the
communication between LANs is checked successfully.

20
Exp No: 4 ANALYZING THE PERFORMANCE OF VARIOUS
CONFIGURATIONS AND PROTCOLS IN LAN
Date :
MULTI-ROUTING CONNECTION WITH STATIC ROUTER

OBJECTIVE
To establish connection between two LANs by extending multi-routing
connection with static router.

REQUIREMENTS:
 Four windows PC or Four Linux PC.
 Two Switch (8 port).
 Six Straight Line LAN (cat-5) Cables with RJ-45 Sockets.
 Power supply
 Basic Network Configuration Commands. For Router, Switch and PCs.
 Cisco Packet Tracer 6.0.1
 Two Cisco Routers (Model 1841)

PROCEDURES:
 Open the CISCO PACKET TRACER software.
 Draw the 4 PC using End Device Icons.
 Draw the 2 CISCO 24 Port Switch using Switch icon lists.
 Draw the two Cisco Generic Routers using Router icon lists.
 Make the Connections using Straight-Through Ethernet Cables.
 Configure Routers R0 and R1.
 Enter the IP Address to Each Machine.
 Configuring Static Routing for Each routers.
 Check the Connections using Add Simple PDU(P).

21
NETWORK TOPOLOGY:

PC0 IP CONFIGURATION ADDRESS:

22
PC1 IP CONFIGURATION ADDRESS:

PC2 IP CONFIGURATION ADDRESS:

23
PC3 IP CONFIGURATION ADDRESS:

ROUTER 0 CONFIGURATION:
1
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface fastethernet 0/0
Router(config-if)#ip address 1.0.0.1 255.0.0.0
Router(config-if)#no shutdown

Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to
up

%LINEPROTO-5-UPDOWN: Line protocol on Interface


FastEthernet0/0, changed state to up

24
Router(config-if)#exit
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface serial 2/0
Router(config-if)#ip address 3.0.0.1 255.0.0.0
Router(config-if)#clock rate 64000
Router(config-if)#no shutdown

%LINK-5-CHANGED: Interface Serial2/0, changed state to down


Router(config-if)#exit
Router(config)#ip route 2.0.0.0 255.0.0.0 3.0.0.0

ROUTER 1 CONFIGURATION:
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface fastethernet 0/0
Router(config-if)#ip address 2.0.0.1 255.0.0.0
Router(config-if)#no shutdown

Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to
up

%LINEPROTO-5-UPDOWN: Line protocol on Interface


FastEthernet0/0, changed state to up

Router(config-if)#exit
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface serial 2/0
Router(config-if)#ip address 3.0.0.0 255.0.0.0
Bad mask /8 for address 3.0.0.0
Router(config-if)#ip address 3.0.0.1 255.0.0.0
Router(config-if)#clock rate 64000
Router(config-if)#no shutdown
%LINK-5-CHANGED: Interface Serial2/0, changed state to down
Router(config-if)#exit
Router(config)#ip route 1.0.0.0 255.0.0.0 3.0.0.0

25
VERIFY LAN NETWORK CONNECTIVITY
Using Add Simple PDU(p), Click the mail icon and then drop one mail to one of
the PC in first LAN and another mail to PC in another LAN. If the resultant windows show
the successful delivery of the mail then network connectivity is successful.

PC0 TO PC2

26
PC1 TO PC3

27
CONCLUSION

Thus two LANs are connected using router with static routes and the communication
between LANs is checked successfully.

28
Exp No: 5 IMPLEMENTING MINI SEARCH ENGINE
Date :

AIM:
To implement Google search in a web page

PROCEDURE

 Create a HTML File.


 In the html file create a form using the <form > tag.
 Set the action attribute of the <form> as http://www.google.com/search.
 Inside the form create a text box for entering the search parameter
 Set the value of the “GoogleSearch”.
 Create two radio buttons with name as “sitesearch” and one with value as null
and the other with value as “srmuniv.ac.in”.
 Save the file with .html or .htm extension.

HOW TO EXECUTE:

 Double click the file and open it using any available browser

29
CODE:

<html>

<body bgcolor="skyblue">

<center><font size="36" color = "blue" face="Arial"><b>SEARCH

ENGINE</b></font><br>

<br>

<form method="get" action ="http://www.google.com/search">

<input type="text" name="q" size="31" maxlength="255" value=""/>

<input type="Submit" value="Google Search"/>

<input type="radio" name="sitesearch" value=""/>

THE WEB

<input type="radio" name="sitesearch" value="srmuniv.ac.in" checked />SRM

UNIVERSITY<br>

</form></center>

<center><imgsrc="E:\Networkslab\srmlogo.gif"></center><center>

</body>

</html>

30
OUTPUTS:

31
32
RESULT:

Thus the program to implement a mini search engine is executed successfully and the
output is verified.

33
Exp No: 6 IMPLEMENTING SIMPLE WEB SERVER
Date :

AIM:
To write a java web server that will read and process simple HTTP requests
from the client

PROCEDURE:
 In the main method of the java class, create a server socket and bind it to the
port
 Read the HTTP request from the client
 Depending on the type of file requested, retrieve the appropriate file
 Send the file back to the client.
 Close the streams
 Close the server socket.

HOW TO EXECUTE:
 Open the command prompt
 Save and Compile the java file using the command javac<file name>.java
 Run the server program using the command java <classname>
 Open the browser and type the url of the server in the browsers address bar
 The URL is of the form http://localhost:portno/file.html
 Note the web server is developed only to support html, gif and jpeg file types.

34
Source Code:

WebServer.java:

import java.io.*;
import java.net.*;
importjava.util.*;
classWebServer
{
public static void main(String args[]) throws Exception
{
String request;
String file;
ServerSocket server = new ServerSocket(6001);
Socket socket = server.accept();
BufferedReader in = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
request = in.readLine();
StringTokenizer token = new StringTokenizer(request);
if (token.nextToken().equals("GET")){
file = token.nextToken();
if (file.startsWith("/") == true )
file = file.substring(1);
File filef = new File(file);
intlen = (int) filef.length();
FileInputStreaminFile = new FileInputStream (filef);
byte[] byt = new byte[len];
inFile.read(byt);
out.writeBytes("HTTP/1.0 200 Document Follows\r\n");
if (file.endsWith(".jpg"))

35
out.writeBytes("Content-Type: image/jpeg\r\n");
if (file.endsWith(".gif"))
out.writeBytes("Content-Type: image/gif\r\n");
out.writeBytes("Content-Length: " + len + "\r\n");
out.writeBytes("\r\n");
out.write(byt, 0, len);
socket.close();
}
else
System.out.println("Bad Request Message");
}
}

HtmlPage.html:

<html>
<head>
<title>Web Server</title>
</head>
<body>
<h1>Hello SRM!!!!</h1>
</body>
</html>

36
OUTPUTS:

37
Working with HTML page:

Working with Image:

38
RESULT:

Thus the program for implementing a simple web server is successfully


executed and the output is verified.

39
Exp No: 7 UDP ECHO SERVER AND CLIENT

AIM:
To implement an echo server and client in java using UDP sockets.

PROCEDURE:

FOR CREATING SERVER:


 Create a server socket and bind it to port.
 Listen for new connection and when a connection arrives, accept it.
 Read Client's message
 Echo back the same message to the client
 Close all streams
 Close the sockets

FOR CREATING CLIENT:


 Create a client socket and connect it to the server’s port number
 Get a message from user and send it to server
 Read server's response and display it
 Close all input/output streams
 Close the client socket

HOW TO EXECUTE:
For Server:
 Open the command prompt
 Compile the java file using the command javac<file name>.java
 Run the server program using the command java <classname>
 The server will start and wait for the clients request to come
50
For Client:
 Open the command prompt
 Compile the java file using the command javac<file name>.java
 Run the client program using the command java <classname>
 Type any text on the client window
 Response from the server will be displayed as an echo

51
SOURCE CODE

UDP SERVER:

import java.io.*;
import java.net.*;
classUDPServer
{
public static void main(String args[])throws Exception
{
DatagramSocketserverSocket=new DatagramSocket(9876);
byte[] receiveData=new byte[1024];
byte[] sendData=new byte[1024];
while(true)
{
DatagramPacketreceivePacket=new DatagramPacket(receiveData,
receiveData.length);
serverSocket.receive(receivePacket);
String sentence=new String(receivePacket.getData());
InetAddressIPAddress=receivePacket.getAddress();
int Port=receivePacket.getPort();
String CapitalizedSentence=sentence.toUpperCase();
sendData=CapitalizedSentence.getBytes();
DatagramPacketsendPacket=new
DatagramPacket(sendData,sendData.length,IPAddress,Port);
serverSocket.send(sendPacket);
}
}
}

52
UDP CLIENT:

import java.io.*;
import java.net.*;
classUDPClient
{
public static void main(String args[]) throws Exception
{
System.out.println("Enter the Data to be sent:");
BufferedReaderinFromUser=new BufferedReader(new
InputStreamReader(System.in));
DatagramSocketclientSocket=new DatagramSocket();
InetAddressIPAddress=InetAddress.getByName("localhost");
byte[] sendData=new byte[1024];
byte[]receiveData=new byte[1024];
String sentence=inFromUser.readLine();
sendData=sentence.getBytes();
DatagramPacketsendPacket=new
DatagramPacket(sendData,sendData.length,IPAddress,9876);
clientSocket.send(sendPacket);
DatagramPacketreceivePacket=new DatagramPacket(receiveData,
receiveData.length);
clientSocket.receive(receivePacket);
String modifiedSentence=new String(receivePacket.getData());
System.out.println("From Server:"+modifiedSentence);
clientSocket.close();
}
}

53
OUTPUT:

Server:

54
Client:

55
RESULT:

Thus the program for implementing UDP Echo Server/Client is exceuted successfully
and the output is verified.

56
Exp No: 8 TCP DATE TIME SERVER AND CLIENT

AIM:
To implement a server accept a request from client sends back current data and
time to the client using java and TCP sockets.

PROCEDURE:

FOR CREATING SERVER:


 Create a server socket and bind it to port
 Listen for new connection and when a connection arrives, accept it.
 Read Client's message
 Calculate factorial and write it to clients socket
 Close all streams
 Close the sockets

FOR CREATING CLIENT:


 Create a client socket and connect it to the server’s port number
 Get a number as input from user and send it to server
 Read server's response and display it
 Close all input/output streams
 Close the client socket

HOW TO EXECUTE:
For Server:
 Open the command prompt
 Compile the java file using the command javac<file name>.java
 Run the server program using the command java <classname>
 The server will start and wait for the clients request to come

57
For Client:
 Open the command prompt
 Compile the java file using the command javac<file name>.java
 Run the client program using the command java <classname>
 Input the number for which factorial needs to be calculated
 The Server will respond with the factorial of the number

58
SOURCE CODE

TCP DATE SERVER:

import java.net.*;
import java.io.*;
importjava.util.Date;
public class TCPDateserver{
public static void main(String args[])throws Exception
{
ServerSocket server=new ServerSocket(8888);
while(true)
{
System.out.println("Waiting for Client to connect...");
Socket socket=server.accept();
PrintWriter out=new PrintWriter(socket.getOutputStream(),true);
InetAddressremoteIP=socket.getInetAddress();
out.println("Todays Date is:"+new Date());
}
}
}

TCP DATE CLIENT:

import java.io.*;
import java.net.*;
public class TCPDateClient{
public static void main(String args[]){
try{
Socket socket=new Socket("localhost",8888);
BufferedReader in=new BufferedReader(new

59
InputStreamReader(socket.getInputStream()));
String msg=in.readLine();
System.out.println("Server:"+msg);
}catch(IOExceptionioe)
{
ioe.printStackTrace();
}
}
}

60
OUTPUTS:

61
RESULT:

Thus the program to receive the current date and time by using TCP Server/Client is
successfully executed and the output is verified.

62
Exp No: 09 TCP FACTORIAL SERVER AND CLIENT

AIM:

To implement a server that will read the number sent by the client, computes
factorial and sends back to client using java and TCP sockets.

PROCEDURE:

FOR CREATING SERVER:

 Create a server socket and bind it to port.


 Listen for new connection and when a connection arrives, accept it.
 Read Client's message
 Calculate factorial and write it to client’s socket. Close all streams
 Close the sockets

FOR CREATING CLIENT:

 Create a client socket and connect it to the server’s port number


 Get a number as input from user and send it to server
 Read server's response and display it
 Close all input/output streams
 Close the client socket

63
HOW TO EXECUTE

For Server:

 Open the command prompt


 Compile the java file using the command javac<file name>.java
 Run the server program using the command java <classname>
 The server will start and wait for the clients request to come

For Client:

 Open the command prompt


 Compile the java file using the command javac<file name>.java
 Run the client program using the command java <classname>
 Input the number for which factorial needs to be calculated
 Response from the server will be displayed as an echo

64
SOURCE CODE:

TCP FACTORIAL SERVER:

import java.io.*;

import java.net.*;

public class TCPFactorialServer {

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

//Create server socket listening on port 8888

ServerSocket server = new ServerSocket(8888);

while(true){

System.out.println("Waiting for client to connect...");

Socket socket = server.accept();

//Create read/write from socket

PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

BufferedReader in =

newBufferedReader( newInputStreamReader(sock

et.getInputStream()));

//client address

InetAddressremoteIp = socket.getInetAddress();

//Receiving from client

String msg = in.readLine();

System.out.println("Client " + remoteIp + " : " + msg);

int fact= factorial(msg);

65
out.println(fact);

private static int factorial(String input) {

int n = Integer.parseInt(input);

int f = 1;

for (int i=1; i<=n; i++)

f *= i;

return f;

66
TCP FACTORIAL CLIENT:

import java.net.*;

import java.io.*;

public class TCPFactorialClient

{ public static void main(String[]

args){ try{

Socket socket = new Socket("localhost", 8888);

PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

BufferedReader in = new

BufferedReader( newInputStreamReader(socket.getInputStream())

); System.out.println("Enter the Data To Be Sent : ");

BufferedReaderinFromUser =

newBufferedReader(new InputStreamReader(System.in));

String msg = inFromUser.readLine();

out.println(msg);

msg = in.readLine();

System.out.println("Factorial of number is: " + msg);

}catch(IOExceptionioe){

ioe.printStackTrace();

67
OUTPUTS:

For Server

For Client:

68
RESULT:

Thus the program to compute the factorial of a number by Using TCP


Server/Client is successfully executed and the output is verified.

69
Exp No: 10 TCP HELLO SERVER AND CLIENT

AIM:-

To implement TCP server and TCP client which will display a “hello
welcome” message.

PROCEDURE:-

FOR CREATING SERVER:


 Create a server socket and bind it to port.
 Listen for new connection and when a connection arrives, accept it.
 Send a Welcome message to the client
 Close all streams
 Close the sockets

FOR CREATING CLIENT:


 Create a client socket and connect it to the server’s port number
 Read server's response and display it
 Close all input/output streams
 Close the client socket

HOW TO EXECUTE:
For Server:
1. Open the command prompt
2. Compile the java file using the command javac<file name>.java
3. Run the server program using the command java <classname>
4. The server will start and wait for the clients request to come

70
For Client:
1. Open the command prompt
2. Compile the java file using the command javac<file name>.java
3. Run the client program using the command java <classname>
4. Response from the server will be displayed as an echo

71
SOURCE CODE:-

TCPHelloClient:-

import java.net.*;

import java.io.*;

public class TCPHelloClient

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

try

Socket socket = new Socket("localhost",8888);

BufferedReader in = new BufferedReader(new


InputStreamReader(socket.getInputStream()));

String msg = in.readLine();

System.out.println("server:"+msg);

catch(IOExceptionioe)

ioe.printStackTrace();

72
TCPHelloServer:-

import java.io.*;

import java.net.*;

classTCPEchoServer

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

ServerSocket server = new ServerSocket(8888);

while(true)

System.out.println("Waiting for client to connect...");

Socket socket = server.accept();

PrintWriter out = new PrintWriter(socket.getOutputStream(),true);

BufferedReader in =new BufferedReader(new


InputStreamReader(socket.getInputStream()));

InetAddressremoteIp = socket.getInetAddress();

out.println("hello Welecome");

73
OUTPUTS:-

Server:-

Client:-

74
Result:

Thus the program for implementing a TCP Server/Client is executed successfully and
the output is verified .

75
76

You might also like