CN Practical
CN Practical
AIM:
HOW TO EXECUTE:
COMMAND DESCRIPTION
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:
9
HOST PC1 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.
11
HOST PC1 TO HOST PC2:
12
RESULT:
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:
15
PC1 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
17
%LINEPROTO-5-UPDOWN: Line protocol on Interface
FastEthernet1/0, changed state to up
Router(config-if)#exit
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:
22
PC1 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
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
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
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
HOW TO EXECUTE:
Double click the file and open it using any available browser
29
CODE:
<html>
<body bgcolor="skyblue">
ENGINE</b></font><br>
<br>
THE WEB
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:
38
RESULT:
39
Exp No: 7 UDP ECHO SERVER AND CLIENT
AIM:
To implement an echo server and client in java using UDP sockets.
PROCEDURE:
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:
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
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());
}
}
}
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:
63
HOW TO EXECUTE
For Server:
For Client:
64
SOURCE CODE:
import java.io.*;
import java.net.*;
while(true){
BufferedReader in =
newBufferedReader( newInputStreamReader(sock
et.getInputStream()));
//client address
InetAddressremoteIp = socket.getInetAddress();
65
out.println(fact);
int n = Integer.parseInt(input);
int f = 1;
f *= i;
return f;
66
TCP FACTORIAL CLIENT:
import java.net.*;
import java.io.*;
args){ try{
BufferedReader in = new
BufferedReader( newInputStreamReader(socket.getInputStream())
BufferedReaderinFromUser =
newBufferedReader(new InputStreamReader(System.in));
out.println(msg);
msg = in.readLine();
}catch(IOExceptionioe){
ioe.printStackTrace();
67
OUTPUTS:
For Server
For Client:
68
RESULT:
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:-
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.*;
try
System.out.println("server:"+msg);
catch(IOExceptionioe)
ioe.printStackTrace();
72
TCPHelloServer:-
import java.io.*;
import java.net.*;
classTCPEchoServer
while(true)
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