CN Lab Manual
CN Lab Manual
TECHNOLOGY
(2021 Regulation )
LAB MANUAL
LIST OF EXPERIMENTS :
1. Learn to use commands like tcpdump, netstat, ifconfig, nslookup and traceroute. Capture ping
and traceroute PDUs using a network protocol analyzer and examine.
2. Write a HTTP web client program to download a web page using TCP sockets
TOTAL: 60 PERIODS
1.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 your
computer.
C:\>ipconfig: The ipconfig command displays information about the host (the computer your
sitting 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
in your 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 DHCP
server.
C:\>ipconfig /flushdns: This command is only needed if you’re having trouble with your networks
DNS 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. (Nbt
stands 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, and
FTP.
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.
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 reply with
“Hello” on the other end. Computers make phone calls to each other over a network by using a
Ping command. The Ping commands main purpose is to place a phone call to another computer on
the 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’t
pose 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 to
get from the computer where tracert is run to any other computer on the internet.
RESULT:
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 {
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(); l.setIcon(icon);
f.add(l);
f.pack();
f.setVisible(true);
}
}
OUTPUT SERVER
OUTPUT
C:\Program Files\Java\jdk1.5.0\bin>javac HTTPServer.java
C:\Program Files\Java\jdk1.5.0\bin>java HTTPServer
Server Waiting for image Client connected.
CLIENT OUTPUT
Client is running.
Reading image from disk.
Image size :29kb Viva
Questions and Answers:
5. Define URL.
URL stands for Uniform Resource Locator, and is used to specify addresses on the World
Wide Web. A URL is the fundamental network identification for any resource connected to the web
(e.g., hypertext pages, images, and sound files). The protocol specifies how information from the
link is transferred.
RESULT:
The webpage is successfully downloaded and the contents are displayed and verified.
3. a. 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)
{
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();
}
fromClient.close();
toClient.close();
client.close();
sock.close();
System.out.println("Client Disconnected");
}
catch (IOException ioe)
{
System.err.println(ioe);
}}}
OUTPUT:
Server
$ javac echoserver.java
$ java tcpechoserver
Server Ready
Client Connected
Client [ hello ]
Client [ how are you ]
Client [ i am fine ]
Client [ ok ]
Client Disconnected
Client
$ javac echoclient.java
$ java tcpechoclient
Type "bye" to quit
Enter msg to server : hello
Server [ hello ]
Enter msg to server : how are you
Server [ how are you ]
Enter msg to server : i am fine
Server [ i am fine ]
Enter msg to server : ok
Server [ ok ]
Enter msg to server : bye
Thus the program for simulation of echo server was written & executed.
3.B. 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")) 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.close(); Clt.close();
Srv.close();
}
catch (Exception E)
{
System.out.println(E.getMessage());
}}}
SERVER
$ javac tcpchatserver.java
$ java tcpchatserver
Server started
Client connected
Server <<< hi
Message to Client : hello Server
<<< how r u?
Message to Client : fine
Server <<< me too
Message to Client : bye
Client Disconnected
CLIENT
$ javac tcpchatclient.java
$ java tcpchatclient
Type "end" to Quit
Message to Server : hi
Client <<< hello
Message to Server : how r u?
Client <<< fine
Message to Server : me too
Client <<< bye
Message to Server : end
Viva Questions and Answers:
1. Define chat.
A real-time communication via keyboard between two or more users on a
local network (LAN) or over the Internet
2. Define TCP.
TCP/IP stands for Transmission Control Protocol/Internet Protocol, which is a set of
networking protocols that allows two or more computers to communicate. The Defense Data
Network, part of the Department of Defense, developed TCP/IP, and it has been widely adopted as
a networking standard.
3. what is socket API?
A socket API is an application programming interface (API), usually
provided by the operating system, that allows application programs to control and use
network sockets. Internet socket APIs are usually based on the Berkeley sockets standard.
RESULT:
Thus the above program a client-server application for chat using TCP / IP was executed
and successfully.
3.C. FILE TRANSFER IN CLIENT & SERVER
AIM:
To Perform File Transfer in Client & Server Using TCP/IP.
ALGORITHM:
CLIENT SIDE
1. Start.
2. Establish a connection between the Client and Server.
3. Socket ss=new Socket(InetAddress.getLocalHost(),1100); 4. Implement a client that can send
two requests.
i) To get a file from the server.
ii) To put or send a file to the server.
5. After getting approval from the server ,the client either get file from the server or send
6. file to the server.
SERVER SIDE
1. Start.
2. Implement a server socket that listens to a particular port number.
3. Server reads the filename and sends the data stored in the file for the‘get’ request. 4. It reads the
data from the input stream and writes it to a file in the server for the
‘put’ instruction.
5. Exit upon client’s request.
6. Stop.
PROGRAM:
CLIENT SIDE
import java.net.*; import java.io.*; class MyClient { public
static void main(String srgs[])throws IOException
{
Socket s=null;
BufferedReader get=null;
PrintWriter put=null;
try
{ s=new Socket("127.0.0.1",8081);
get=new BufferedReader(new InputStreamReader(s.getInputStream()));
put=new PrintWriter(s.getOutputStream(),true);
}
catch(Exception e)
{
System.exit(0);
}
String u,f;
System.out.println("Enter the file name to transfer from
server:"); DataInputStream dis=new
DataInputStream(System.in); f=dis.readLine(); put.println(f);
File f1=new File("f:\\output");
FileOutputStream fs=new FileOutputStream(f1);
while((u=get.readLine())!=null)
{ byte jj[]=u.getBytes();
fs.write(jj);
} fs.close();
System.out.println("File received");
s.close();
}
}SERVER SIDE
SERVER OUTPUT
C:\Program Files\Java\jdk1.6.0\bin>javac
FileServer.java
C:\Program Files\Java\jdk1.6.0\bin>java FileServer
Connection establishedSocket[addr=/127.0.0.1,port=50986,localport=8081]
The requested file is : network.txt File
transfered
CLIENT OUTPUT
C:\Program Files\Java\jdk1.6.0\bin>javac
MyClient.java C:\Program
Files\Java\jdk1.6.0\bin>java MyClient
RESULT:
AIM:
To write a program to Simulation of DNS using UDP sockets..
ALGORITHM:
PROGRAM:
A 1 – 126* 255.0.0.0
RESULT:
Thus the above program a client-server application for chat using UDP was executed and
successfully
ALGORITHM
CLIENT SIDE
SERVER SIDE
PROGRAM
ARP CLIENT
class ArpClient
{
public static void main(String args[])throws IOException
{ try
{
Socket ss=new Socket(InetAddress.getLocalHost(),1100);
PrintStream ps=new PrintStream(ss.getOutputStream());
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
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); }}}
OUTPUT
1. Define ARP.
The address resolution protocol (arp) is a protocol used by the Internet
Protocol (IP) [RFC826], specifically IPv4, to map IP network addresses to the
hardware addresses used by a data link protocol.
2. Define IPv4.
IPv4 (Internet Protocol Version 4) is the fourth revision of the Internet
Protocol (IP) used to to identify devices on a network through an addressing system.
RESULT
Thus the implementation of ARP is done & executed successfully.
CLIENT
SERVER
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);
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;
}
} break;
}}
catch(Exception e)
{
System.out.println(e);
}
}
}
OUTPUT:
I:\ex>java Serverrarp12 I:\ex>java
Clientrarp12
Enter the Physical address (MAC):
6A:08:AA:C2
The Logical Address is(IP): 165.165.80.80
1. DefineRARP.
RARP (Reverse Address Resolution Protocol) is a protocol by which a physical machine in a local
area network can request to learn its IP address from a gateway server's Address Resolution Protocol
(ARP) table
.
2. What is the use of RARP?
RARP is used for the opposite purpose; namely, to convert an ethernet address to an
IP address. Its linux-network-administration purpose is to enable diskless machines, such as X
workstations, to find out their IP address at boot time.
RESULT:
SYSTEM REQUIREMENTS:
Serial port, LPT port & USB port installed on system Operating
System: 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
either through 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 hence find the effect on through put graph as well.
Trainer and its various types of experimentation using this system. This system works into
serverclient 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
selected topology. 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
clients however 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 server and clients. Throughput v/s Packet size graph can be plotted for which at least two
file transfers should be carried out. This plot can be printed to attach in the lab exercise sheet.
For the LAN network LAN cards must be installed prior to start work on this trainer. For wire
less LAN 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 connected to hardware device.
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 being
sent 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.
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.
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 communication
system.
The trainer kit is highly innovative from a technological as well as an educational point of view.
The trainer kit is used as “basic unit” to examine all the peculiar operating standards of serial and
parallel communication system. The only external equipments required are two Computers with
serial and parallel communication ports and an Oscilloscope. Utmost care has been laid in the
design and 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
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 as
well 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 can
be serial or in parallel form.
Viva Questions and Answers:
1. Define NS.
A Network Simulator is an object oriented, event driven discrete simulator written in C++,
with an object oriented tool command language (OTCL) interpreter as a front end.
A lot! Almost all variants of TCP, several forms of multicast, wired networking, several ad hoc
routing protocols and propagation models (but not cellular phones), data diffusion, satellite, and other
stuff. See the documentation (described above) for details, or download ns and look.
Data communication is a term referred when the sender and receiver are digital devices, which
communicate with each other by means of binary information.
5. Define OPNET.
OPNET Network Simulator. OPNET Network simulator is a tool to simulate the behavior and
performance of any type of network. The main difference Opnet Network Simulator comparing to
other simulators lies in its power and versatility. IT Guru provides pre-built models of protocols and
devices.
RESULT:
The study of network simulator (ns) and simulation of congestion control algorithms
using ns is executed and verified.
8. Study of TCP/UDP performance using Simulation tool.
AIM:
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 protocols in 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 on
the 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 routerconnected internet works.
The ultimate goal of the transport layer is to provide efficient, reliable, and cost-effective service to
its 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 for
the end-to-end transfer of data over the network and is the four of the OSI model. The Transport
layer meets 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.
Flow controls The receiver can signal the ACKs, which are used in
sender to slow down. TCP to control packet flow, are not
returned.
Connection setup It takes time, but with No connection is required.
TCP 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 If ACK, are missing, the network
controls advantage of TCP ACK to control cannot signal congestion to the sender.
the behavior of sender.
A big difference between TCP and UDP is the congestion control algorithm. For the TCP,
congestion algorithm 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
User Datagram Protocol (UDP) provides an unreliable connectionless delivery service using IP to
transport messages 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’t provide flow control, reliability or error recovery and the retransmissions of data in
case of errors must be ordered by other protocols. UDP is designed for applications that do not have
to recompose the data segment 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
to retransmitted again. On the other side this applications are not slow down by the confirmation
process and 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 no packet latency and packet discard ratio of 0% while packets traverse
thru the WAN. The task response time, in seconds, Fig. 1, shows how long the application need to be
completed. The time when using TCP to complete the task is greater that the one using UDP. When
using TCP, source and destination need 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’t perform this tasks.
TC
UD
1. Response time for TCP and UDP
TC
UD
TC TC
UD UD
UD
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
hostto-host communication channel, so the packets will be delivered between processes running on
two 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 plan
to conduct several studies regarding packets routing in computer networks to improve the fairness of
data transmissions using different network protocols.
RESULT:
Thus the TCP/UDP performance has been simulated successfully using OPNET.
APPARATUS REQUIRED:
1. VI-RTSIM software.
2. Personal computer.
THEORY:
Each router shares its knowledge about entire network. It sends all of its collected knowledge
about the network to its neighbors. Routing only to neighbor:
Each router periodically sends its knowledge about the network only to those routers to which
it 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 its
neighbors.
Sharing Information:
Each router gets its initial knowledge about the internet work and how it uses shared
information 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 each
advertised router.
The router should apply the below rules to each router, if the advertised destination is not in
routing 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, the
router should replace the entry in the table with new one.
IF advertised hop count is not smaller, the router should do no routing.
PROCEDURE
Pathhor 2 t 5
s n o
In distance vector routing the least cost route between any two nodes is the route with
minimum distance. In this each node maintains a vector table of minimum
distances to every node. The table at each node also guides the packets to the
desired node by showing the next stop in the route.
In this each node shares its routing table with its immediate neighbors
periodically and when there is a change.
RESULT:
Thus Distance Vector routing algorithm has been implemented and shortest-path has been
circulated.
9.b Simulation of Link State Routing Algorithm.
AIM:
APPARATUS REQUIRED:
1. VI-RTSIM software.
2. Personal computer.
THEORY:
In Link state routing, each router share its information of its neighbors with every other router
in the inter-network. Knowledge about the neighborhood:
Instead of sending its entire routing table, a router sends information about its neighborhood
only. 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
it up, we cannot assign any cost to a packet.
Link state packet:
When a router floods the network with information about its neighborhood, it is said to be
advertising. The basis of this advertising is a short packet called a link state packet (LSP).
Advertiser Network Cost Neighbor
A router gets its information about its neighbors by periodically sending them a short greeting
packet.
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
to be deleted from the system, the whole database must be shared for fast updating.
PROCEDURE
Find Path
You should click on anp tno obiects to find the path
Node
Distance
Path
It has a different concept from that of distance vector routing. In this each node in the domain
has the entire topology of the domain-the list of nodes and links, how they are connected
including the type, cost and condition of the links.
Dijkstra’s algorithm.
A node sends its routing table, normally every 30’s in a periodic update. The period
depends on the protocol that is using distance vector routing.
RESULT:
Thus Link-State routing algorithm has been implemented and shortest-path has been circulated.
10. Simulation of error correction code (like CRC)
AIM:
To implement and check the error detection/error correction techniques in networks using a c program.
APPARATUS REQUIRED:
1. Pc-ino
2. C/c++compiler
THEORY:
Error Detection
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
technique involves 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 the
actual bits. Actual data bits plus the remainder is called a codeword. The sender transmits
data bits as code words.
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
considered as there some data corruption occurred in transit.
PROCEDURE:
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;
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];
}
}
OUTPUT:
F:\java>javac CRC.java
F:\java>java CRC
1. Define CRC.
Error detection is the detection of errors caused by noise or other impairments during
transmission from the transmitter to the receiver. Error correction is thedetection of errors and
reconstruction of the original, error-free data.3.Defne error correcting.
There are three main techniques for detecting errors in frames: Parity Check, Checksum and
Cyclic Redundancy Check (CRC).
A parity check is the process that ensures accurate data transmission between nodes during
communication. A parity bit is appended to the original data bits to create an even or odd bit number;
the number of bits with value one.
RESULT: