CN Lab Manual
CN Lab Manual
SERKKADU
VELLORE – 632 115
PREPARED BY
V.JANANI
DEPARTMENT OF COMPUTER SCIENCE
II SEMESTER – PRACTICAL - V
I-M.SC CS
2020 – 2021
NAME : ………………………………
REG. NO : ………………………………
SUB.CODE : ………………………………
THIRUVALLUVAR UNIVERSITY
SERKKADU
VELLORE – 32 115
V. JANANI, M.C.A., M.Phil., NET., Dr. B. SENTHILKUMAR, M. Sc., Ph.D. M.A (Yoga)
PAGE.
S.NO DATE LIST OF EXPERIMENTS SIGN
NO
4 HTTP PROTOCOL
7 ARP/RARP PROTOCOL
----------------------------------------------------------------------------------------------------
System administrator:
System administrator, or sysadmin, is a person who is responsible for the upkeep, configuration,
and reliable operation of computer systems; especially multi-user computers, such as servers.The
system administrator seeks to ensure that the uptime, performance, resources, and security of the
computers he or she manages meet the needs of the users, without exceeding the budget.
Skills:
Network administration:
Network admins juggle several projects, people and problems simultaneously. This means it’s
essential to be organized in the present and looking ahead to prepare for what’s coming next. It’s
like spinning plates with a little practice a network admin can keep everything balanced.
Interpersonal skills
Network admins work with a range of people, from network engineers to help desk employees to
end users, explains Eric Jeffery, founder of IT solutions firm Gungon Consulting. He says
bridging the gap between diverse groups of people requires patience and understanding.
Lifelong learning
The technology field is constantly changing, which means network admins must be willing to
learn and evolve with it. Good network admins are able to adapt to new techniques and
technologies throughout their careers.
Each task area corresponds to a phase in the continuing life cycle of a network. You might be
responsible for all the phases, or you might ultimately specialize in a particular area, for
example, network maintenance.
The first phase in the life cycle of a network involves creating its design, a task not usually
performed by new network administrators. Designing a network involves making decisions
about the type of network that best suits the needs of your organization. In larger sites this task is
performed by a senior network architect: an experienced network administrator familiar with both
network software and hardware.
After the new network is designed, the second phase of network administration begins, which involves
setting up and configuring the network. This consists of installing the hardware that makes up the
physical part of the network, and configuring the files or databases, hosts, routers, and network
configuration servers. The tasks involved in this phase are a major responsibility for network
administrators. You should expect to perform these tasks unless your organization is very large, with an
adequate network structure already in place.
"Configuring Network Clients" explains how to set up new hosts on an existing network. "General
Troubleshooting Tips" contains hints for solving network problems.
The longer a network is in place and functioning properly, the more your organization might want to
expand its features and services. Initially, you can increase network population by adding new hosts and
expanding network services by providing additional shared software. But eventually, a single network
will expand to the point where it can no longer operate efficiently. That is when it must enter the fourth
phase of the network administration cycle: expansion.
RESULT
The program was executed successfully
----------------------------------------------------------------------------------------------------
Ex: No: 2 SCOCKET PROGRAM USING TCP AND UDP
----------------------------------------------------------------------------------------------------
Algorithm:
Server:
Step1:Create a server socket and bind it to port.
Step 2:Listen for new connection and when a connection arrives, accept it.
Step 3:Send server’s date and time to the client.
Step 4:Read client’s IP address sent by the client.
Step 5:Display the client details.
Step 6:Repeat steps 2-5 until the server is terminated.
Step 7:Close the server socket.
Client
Step1:Create a client socket and connect it to the server’s port number.
Step2:Retrieve its own IP address using built-in function.
Step3:Send its address to the server. Step4:Display
the date & time sent by the server. Step5:Close the
client socket
TCP Program:
dateserver.java
//import java packages
import java.net.*; import java.io.*; importjava.util.*;
/*… Register service on port 8020…*/
ss=new ServerSocket(8020);
dateclient.java
/* …Socket class is having a constructor through this Client program can request to server to get
connection…*/
Socket soc;
DataInputStream dis;
String sdate;
PrintStreamps;
/*… Get an input file handle from the socket and read the input…*/
/*…getInputStream()-This method take the permission to write the data from client program to server
program and server program to client program…*/
dis=new DataInputStream(soc.getInputStream());
sdate=dis.readLine();
System.out.println("THE date in the server is:"+sdate);
/* …getOutputStream()-This method is used to take the permission to read data from client system by
the server or from the server system by the client…*/
ps=new PrintStream(soc.getOutputStream());
ps.println(ia);}
UDP Program:
Server.java
/*…import java packages…*/
import java.net.*; import java.io.*; importjava.util.*;
/*..receiving the packet from client…*/
DatagramPacketrp=new DatagramPacket(rd,rd.length); ss.receive(rp);
InetAddress ip= rp.getAddress(); int port=rp.getPort();
/*… getting system time…*/
Date d=new Date();
Clientnew.java
UDP Output:
TCP Output
RESULT
----------------------------------------------------------------------------------------------------
Algorithm:
Server
Step1: Start the program and create server and client sockets.
Step2: Use input streams to get the message from user.
Step3: Use output streams to send message to the client.
Step4: Wait for client to display this message and write a new one to be displayed by the server.
Step5: Display message given at client using input streams read from socket.
Step6: Stop the program.
Client
Step1: Start the program and create a client socket that connects to the required host and port.
Step2: Use input streams read message given by server and print it.
Step3: Use input streams; get the message from user to be given to the server.
Step4: Use output streams to write message to the server.
Step5: Stop the program.
Program
GossipServer.java
GossipClient.java
Socket sock = new Socket("127.0.0.1", 3000);
RESULT
----------------------------------------------------------------------------------- --- -- -- --
Algorithm:
PROGRAM
Client.java
Server.java
//…Create Server Socket…//
ServerSocket server=null; Socket
socket;
//…Register Service port to 4000…// 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);
intlen = dis.readInt();
System.out.println("Image Size: " + len/1024 + "KB"); byte[]
data = new byte[len];
dis.readFully(data);
//…method is used to request for closing or terminating an object…//
dis.close();
in.close();
InputStreamian = new ByteArrayInputStream(data);
BufferedImagebImage = ImageIO.read(ian);
//…create a frame window entitled “server”…//
JFrame f = new JFrame("Server"); ImageIcon
icon = new ImageIcon(bImage);
OUTPUT
RESULT
---------------------------------------------------------------------------------------- -- -- --
Algorithm:
RESULT
----------------------------------------------------------------------------------------------------
PROGRAM
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
/**
* A program that demonstrates how to upload files from local computer
* to a remote FTP server using Apache Commons Net API.
* @author www.codejava.net
*/
public class FTPUploadFileDemo {
ftpClient.connect(server, port);
ftpClient.login(user, pass);
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
RESULT
----------------------------------------------------------------------------------------------------
ALGORITHM:
Client
1. Start the program
2. Using socket connection is established between client and server.
3. Get the IP address to be converted into MAC address.
4. Send this IP address to server.
5. Server returns the MAC address to client.
Server
1. Start the program
2. Accept the socket which is created by the client.
3. Server maintains the table in which IP and corresponding MAC addresses are stored.
4. Read the IP address which is send by the client.
5. Map the IP address with its MAC address and return the MAC address to client. PROGRAM
Program
Client:
import java.io.*;
import java.net.*;
import java.util.*;
class Clientarp
{
public static void main(String args[])
{
try
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
Socket clsct=new Socket("127.0.0.1",5604);
DataInputStream din=new DataInputStream(clsct.getInputStream());
DataOutputStream dout=new
DataOutputStream(clsct.getOutputStream());
System.out.println("Enter the Logical address(IP):");
String str1=in.readLine();
dout.writeBytes(str1+'\n');
String str=din.readLine();
System.out.println("The Physical Address is: "+str);
clsct.close();
}
catch (Exception e)
{
System.out.println(e);
}
}
}
Server:
import java.io.*;
import
java.net.*;
import
java.util.*;
class Serverarp
{
public static void main(String args[])
{
try
{
ServerSocket obj=new
ServerSocket(5604);
Socket obj1=obj.accept();
while(true)
{
DataInputStream din=new DataInputStream(obj1.getInputStream());
DataOutputStream dout=new
DataOutputStream(obj1.getOutputStream()); String str=din.readLine();
String ip[]={"165.165.80.80","165.165.79.1"};
String mac[]={"6A:08:AA:C2","8A:BC:E3:FA"};
for(int i=0;i<ip.length;i++)
{
if(str.equals(ip[i]))
{
dout.writeBytes(mac[i]+'\n');
break;
}
}
obj.close();
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
OUTPUT
E:\networks>java Serverarp
E:\networks>java Clientarp
Enter the Logical address(IP):
165.165.80.80
The Physical Address is: 6A:08:AA:C2
RESULT
OUTPUT
RESULT:
Thus the program was successfully executed.
----------------------------------------------------------------------------------------------------
Ex: No: 9 SIMULATOR - WIRED NETWORK
----------------------------------------------------------------------------------------------------
Ethernet is a LAN (Local area Network) protocol operating at the MAC (Medium Access Control)
layer. Ethernet has been standardized as per IEEE 802.3. The underlying protocol in Ethernet is known as
the CSMA / CD – Carrier Sense Multiple Access / Collision Detection. The working of the Ethernet
protocol is as explained below, A node which has data to transmit senses the channel. If the channel is idle
then, the data is transmitted. If the channel is busy then, the station defers transmission until the channel is
sensed to be idle and then immediately transmitted. If more than one node starts data transmission at the
same time, the data collides. This collision is heard by the transmitting nodes which enter into contention
phase. The contending nodes resolve contention using an algorithm called Truncated binary exponential
back off.
ALGORITHM:
1. Create a simulator object
2. Define different colors for different data flows
3. Open a nam trace file and define finish procedure then close the trace file,
and execute nam on trace file.
4. Create six nodes that forms a network numbered from 0 to 5
5. Create duplex links between the nodes and add Orientation to the nodes for setting a
LANtopology
6. Setup TCP Connection between n(0) and n(4)
7. Apply FTP Traffic over TCP
8. Setup UDP Connection between n(1) and n(5)
9. Apply CBR Traffic over UDP.
10. Apply CSMA/CA and CSMA/CD mechanisms and study their performance
11. Schedule events and run the program.
PROGRAM
CSMA/CA
set ns [new Simulator]
#Define different colors for data flows (for NAM)
$ns color 1 Blue
$ns color 2 Red #Open the Trace files
set file1 [open out.tr w]
set winfile [open WinFile w]
$ns trace-all $file1
#Open the NAM trace file set file2 [open out.nam w]
$ns namtrace-all $file2 #Define a 'finish' procedure proc finish {} {
global ns file1 file2
$ns flush-trace close $file1 close $file2
exec nam out.nam & exit 0
}
#Create six nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set
n4 [$ns node] set n5 [$ns node]
$n1 color red
$n1 shape box
#Create links between the nodes
$ns duplex-link $n0 $n2 2Mb 10ms DropTail
$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns simplex-link $n2 $n3 0.3Mb 100ms DropTail
$ns simplex-link $n3 $n2 0.3Mb 100ms DropTail
set lan [$ns newLan "$n3 $n4 $n5" 0.5Mb 40ms LL Queue/DropTail MAC/Csma/Ca
Channel]
Setup a TCP connection
set tcp [new Agent/TCP/Newreno]
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink/DelAck]
$ns attach-agent $n4 $sink
$ns connect $tcp $sink
$tcp set fid_ 1
$tcp set window_ 8000
$tcp set packetSize_ 552
#Setup a FTP over TCP connection set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP #Setup a UDP connection set udp [new Agent/UDP]
$ns attach-agent $n1 $udp set null [new Agent/Null]
$ns attach-agent $n5 $null
$ns connect $udp $null
$udp set fid_ 2
#Setup a CBR over UDP connection set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packet_size_ 1000
$cbr set rate_ 0.01mb
$cbr set random_ false
$ns at 0.1 "$cbr start"
$ns at 1.0 "$ftp start"
$ns at 124.0 "$ftp stop"
$ns at 124.5 "$cbr stop"
# next procedure gets two arguments: the name of the # tcp source node, will be called here
"tcp",
# and the name of output file.
proc plotWindow {tcpSource file} { global ns
set time 0.1
set now [$ns now]
set cwnd [$tcpSource set cwnd_] set wnd [$tcpSource set window_] puts $file "$now $cwnd"
$ns at [expr $now+$time] "plotWindow $tcpSource $file" }
$ns at 0.1 "plotWindow $tcp $winfile"
$ns at 5 "$ns trace-annotate \"packet drop\"" # PPP
$ns at 125.0 "finish"
$ns run
OUTPUT
RESULT
A mobile ad hoc network or MANET does not depend on a fixed infrastructure for its
networkingoperation. MANET is an autonomous and short-lived association of group of mobile
nodes that communicate with each other over wireless links. A node can directly communicate to
the nodes that lie within its communication range. If a node wants to communicate with a node
that is not directly within its communication range, it uses intermediate nodes as routers.
ALGORITHM:
1. Create a simulator object
2. Set the values for the parameter
3. Open a nam trace file and define finish procedure then close the trace file, and execute nam on trace
file.
4. Create the nodes that forms a network numbered from 0 to 3
5. Schedule events and run the program.
PROGRAM
set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_11
set val(ifq) Queue/DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(ifqlen) 50
set val(nn) 3
set val(rp) DSDV
set ns [new Simulator]
set tf [open output.tr w]
$ns trace-all $tf
set tf1 [open output.nam w]
$ns namtrace-all-wireless $tf1 100 100
set topo [new Topography]
$topo load_flatgrid 100 100
create-god $val(nn)
$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace OFF \
-macTrace OFF \
-movementTrace OFF
set node0 [$ns node]
set node1 [$ns node]
set node2 [$ns node]
$ns initial_node_pos $node0 10
$ns initial_node_pos $node1 10
$ns initial_node_pos $node2 10
$node0 set X_ 25.0
$node0 set Y_ 50.0
$node0 set Z_ 0.0
$node1 set X_ 50.0
$node1 set Y_ 50.0
$node1 set Z_ 0.0
$node2 set X_ 65.0
$node2 set Y_ 50.0
$node2 set Z_ 0.0
set tcp1 [new Agent/TCP]
$ns attach-agent $node0 $tcp1
set ftp [new Application/FTP]
$ftp attach-agent $tcp1
set sink1 [new Agent/TCPSink]
$ns attach-agent $node2 $sink1
$ns connect $tcp1 $sink1
$ns at 10.0 "$node1 setdest 50.0 90.0 0.0"
$ns at 50.0 "$node1 setdest 50.0 10.0 0.0"
$ns at 0.5 "$ftp start"
$ns at 1000 "$ftp stop"
$ns at 1000 "finish"
proc finish {} {
global ns tf tf1
$ns flush-trace
close $tf
exec nam output.nam &
exit 0
}
$ns run
OUTPUT
RESULT