CN Lab Manual
CN Lab Manual
CN Lab Manual
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
replywith “Hello” on the other end. Computers make phone calls to each other over a network by
usinga Ping command. The Ping commands main purpose is to place a phone call to another
computeron 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:
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 Client{
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();
CS3591 – COMPUTER NETWORKS LABORATORY
411621104011
SERVER PROGRAM
import java.net.*;
import java.io.*;
import java.awt.image.*;
import javax.imageio.*;
import javax.swing.*;
class Server {
f.pack();
f.setVisible(true); }}
OUTPUT
RESULT:
The webpage is successfully downloaded and the contents are displayed and verified.
AIM:
To write a socket program for implementation of echo.
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 a data to server.
4. Receive and print the same data from server.
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 the data from client.
5. Print and send the same data to client.
6. Close the socket.
7. End the program.
PROGRAM:
ECHO CLIENT
import java.io.*;
import java.net.*;
public class eclient
{
public static void main(String args[])
{
Socket c=null;
String line;
DataInputStream is,is1;
PrintStream os;
try
{
c=new Socket("localhost",8080);
}
catch(IOException e)
{
System.out.println(e);
}
try
{
os=new PrintStream(c.getOutputStream());
is=new DataInputStream(System.in);
is1=new DataInputStream(c.getInputStream());
do
{
System.out.println("client");
line=is.readLine();
os.println(line); if(!
line.equals("exit"))
System.out.println("server:"+is1.readLine());
}while(!line.equals("exit"));
}
catch(IOException e)
{
System.out.println("socket closed");
}}}
Echo Server:
import java.io.*;
import java.net.*;
import java.lang.*;
public class eserver
{
public static void main(String args[])throws IOException
{
ServerSocket s=null;
String line;
DataInputStream is;
PrintStream ps;
Socket c=null;
try
{
s=new ServerSocket(8080);
}
catch(IOException e)
{
System.out.println(e);
}
try
{
c=s.accept();
is=new DataInputStream(c.getInputStream());
ps=new PrintStream(c.getOutputStream());
while(true)
{
line=is.readLine();
System.out.println("msg received and sent back to client");
ps.println(line);
}
}
catch(IOException e)
{
System.out.println(e);
}
}
}
OUTPUT:
CLIENT
SERVER
CONNECTION ACCEPTED
Server received CSE
RESULT:
DATE:
AIM:
To write a client-server application for chat using TCP
ALGORITHM:
CLIENT
1. Start the program
2. Include necessary package in java
3. To create a socket in client to server.
4. The client establishes a connection to the server.
5. The client accept the connection and to send the data from client to server.
6. The client communicates the server to send the end of the message
7. Stop the program.
SERVER
1. Start the program
2. Include necessary package in java
3. To create a socket in server to client
4. The server establishes a connection to the client.
5. The server accept the connection and to send the data from server to client and
6. vice versa
7. The server communicate the client to send the end of the message.
8. Stop the program.
PROGRAM:
TCPserver1.java
import java.net.*;
import java.io.*;
System.out.println(e);
}
try
{
c=s.accept();
is=new DataInputStream(c.getInputStream());
is1=new DataInputStream(System.in);
os=new PrintStream(c.getOutputStream());
do
{
line=is.readLine();
System.out.println("Client:"+line);
System.out.println("Server:");
line=is1.readLine();
os.println(line);
}
while(line.equalsIgnoreCase("quit")==false);
is.close();
os.close();
}
catch(IOException e)
{
System.out.println(e);
}
}
}
TCPclient1.java
import java.net.*;
import java.io.*;
do
{
System.out.println("Client:");
line=is.readLine();
os.println(line);
System.out.println("Server:" + is1.readLine());
}
while(line.equalsIgnoreCase("quit")==false);
is1.close();
os.close();
}
catch(IOException e)
{
System.out.println("Socket Closed!Message Passing is over");
}}
OUT PUT :
SERVER
Client:Hai Server
Server: Hai Client
Client:How are you
Server: Fine
Client:quit
Server: quit
RESULT:
Thus the above program a client-server application for chat using TCP / IP was
executed and successfully
RESULT:
Thus the above program a client-server application for chat using TCP / IP was
executed and successfully.
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 theserver for the
‘put’ instruction.
5. Exit upon client’s request.
6. Stop.
PROGRAM:
CLIENT SIDE
import java.net.*;
import java.io.*;
current = bytesRead;
// thanks to A. Cádiz for the bug fix do {
bytesRead =is.read(mybytearray,
current, (mybytearray.length-
current));if(bytesRead >= 0) current
+= bytesRead;
} while(bytesRead > -1);
B os.write(mybytearray, 0 ,
current);bos.flush(); long end =
System.currentTimeMillis();
System.out.println(end-start);
bos.close();
sock.close();
}}
SERVER SIDE
import java.net.*;
import java.io.*;
OUTPUT:
SERVER OUTPUT
Connection Established
Client wants
file:network.txt
CLIENT OUTPUT
RESULT:
ALGORITHM:
PROGRAM:
String capsent;
System.out.println("Request for host " + sen);
OUTPUT :
Server
javac udpdnsserver.java
java udpdnsserver
Press Ctrl + C to Quit Request for host yahoo.com
Request for host cricinfo.com
Request for host youtube.com
Client
javac udpdnsclient.java
java udpdnsclient
Enter the hostname :
yahoo.com IP Address:
68.180.206.184
java udpdnsclient
Enter the hostname : cricinfo.com
IP Address: 80.168.92.140
java udpdnsclient
Enter the hostname : youtube.com
IP Address: Host Not Found
RESULT:
Thus the above program a client-server application for chat using UDP was executed
and successfully
CS3591 – COMPUTER NETWORKS LABORATORY
411621104011
EX.NO: 5 Use a tool like Wireshark to capture packets and examine the
packets
DATE:
Wireshark is an open-source network protocol analysis software program, widely considered the
industry standard. A global organization of network specialists and software developers supports
Wireshark and continues to make updates for new network technologies and encryption methods.
Wireshark can be used to understand how communication takes place across a network and to
analyse what went wrong when an issue in communication arises. It helps
Installing Wireshark
The view above shows The Main Window, which is broken into different sections:
The Menu: This is broken into the following 11 headings:
File, Edit, View, Go, Capture, Analyze, Statistics, Telephony, Wireless, Tools, Help.
The Filter Toolbar: This has a filter pane when you type in the protocol that you want to view.
The Packet List: This shows all packets that are captured and is shown in blue in the
preceding image.
The Packet Details Pane: This is the gray area that shows the protocol fields of the packet.
The Packet Bytes Pane: This shows a canonical hex dump of the packet data.
One of the core functions of Wireshark as a network analysis tool is to capture packets
of data. Before you start to capture packets, there are three things you need to do:
Make sure that you have the administrative privileges to start a live capture on your
device
Once these three things are done, you’re ready to start the capture process. When you use
Wireshark to capture packets, they are displayed in a human-readable format to make them legible
to the user. You can also break packets down with filters and color-coding if you wish to see
more specific information.When you first open up Wireshark, you’ll be met by the following
launch screen:
The first thing you need to do is look at the available interfaces to capture. To do this,
select Capture > Options. The “Capture Interfaces” dialog box will then open as shown below:
Check the box of the interface you want to capture and press the Start button to start. You can
select multiple interfaces if you want to capture data from multiple sources simultaneously.
On Unix or Linux, the dialog box is shown in a similar style like this:
To activate promiscuous mode, click on the Capture Options dialog box and click
promiscuous mode. In theory, this should show you all the traffic active on your network. The
promiscuous mode box is shown below:
However, this often isn’t the case. Many network interfaces are resistant to
promiscuous mode, so you need to check the Wireshark website for information on your specific
hardware.
On Windows, it’s useful to open Device Manager and check whether you have your
settings configured to reject promiscuous mode. For example:
(Simply click on network and then make sure that your promiscuous mode
setting are setto Allow All).
If you have your settings set to “reject” promiscuous mode, then you’re going to
limit thenumber of packets Wireshark captures. So even if you have promiscuous mode
enabled on Wiresharkcheck your Device Manager to make sure that your interface isn’t
blocking any data from coming through.
Taking the time to check through your network infrastructure will ensure
Wireshark receives all the necessary packets of data.
Once you’ve captured your network data, you’ll want to look at your captured
packets. In the screenshot below you’ll see three panes, the packet list pane, the packet
bytes pane, andthe packet details pane.
If you want more information, you can click on any of the fields in each packet to
see more. When you click on a packet, you’re shown a breakdown of its internal bytes in the
byte viewsection.
Packet List
The packet list pane is shown at the top of the screenshot. Each piece is broken
down toa number with time, source, destination, protocol and support information.
Packet Details
Packet details can be found in the middle, showing the protocols of the chosen
packet. You can expand each section by clicking on the arrow next to your row of choice.
You can also applyadditional filters by right-clicking on the chosen item.
Packet Bytes
The packet bytes pane is shown at the bottom of the page. This pane shows the
internal data of your selected packet. If you highlight part of the data in this section, its
corresponding information is also highlighted in the packet details pane.
Result:
Thus Wireshark tool is used to Capture packets and examine the packets.
ALGORITHM
CLIENT SIDE
SERVER SIDE
PROGRAM
ARP CLIENT
import java.io.*;
import java.net.*;
class ArpClient
{
public static void main(String args[])throws IOException
{
try
{
Socket ss=new Socket(InetAddress.getLocalHost(),1100);
PrintStream ps=new PrintStream(ss.getOutputStream());
BufferedReader br=new
BufferedReader(newInputStreamReader(System.in)); String ip;
System.out.println("Enter the IPADDRESS:");
ip=br.readLine();
ps.println(ip);
String str,data;
BufferedReader br2=new
BufferedReader(newInputStreamReader(ss.getInputStream()));
System.out.println("ARP From Server::"); do
{
str=br2.readLine();
System.out.println(str);
}
while(!(str.equalsIgnoreCase("end")));
}
catch(IOException e)
{
System.out.println("Error"+e);
}}}
ARP SERVER
import java.io.*;
import java.net.*;
class ArpServer
{
public static void main(String args[])throws IOException
{
try
{
ServerSocket ss=new ServerSocket(1100);
Socket s=ss.accept();
PrintStream ps=new PrintStream(s.getOutputStream());
BufferedReader br1=new BufferedReader(newInputStreamReader(s.getInputStream()));
String ip;
ip=br1.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("arp -a "+ip);
BufferedReader br2=new BufferedReader(newInputStreamReader(p.getInputStream()));
String str;
while((str=br2.readLine())!=null)
{
ps.println(str);
}}
catch(IOException e)
{
System.out.println("Error"+e); }}}
OUTPUT
RESULT
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;
}
CS3591 – COMPUTER NETWORKS LABORATORY
411621104011
}
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
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
server- client base. For any topology user has to select one server and select the network type
whether it is LAN or WLAN. To understand the topology concept user can connect two or more
clients to hardware. Depending on the topology selected user will have option to select protocols
forthe 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
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
beingsent and analyze the effect of error on different protocols and hence find the effect on
throughput graph as well. Software is supported with neat operating instruction manual and online
help.
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
CS3591 – COMPUTER NETWORKS LABORATORY
411621104011
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.
RESULT:
The study of network simulator (ns) and simulation of congestion control algorithms
using ns is executed and verified.
TOOLS USED:
Opnet Simulator
INTRODUCTION:
The transport layer protocols provide connection- oriented sessions and reliable data delivery
services. This paper seeks to reflect a comparative analysis between the two transport layer protocols,
which are TCP/IP and UDP/IP, as well to observe the effect of using these two protocolsin a client
server network. The similarities and differences between TCP and UDP over the Internet are also
presented in our work. We implement a network structure using Opnet Modeler and finally, based 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
destinationmachine, independently of the physical network or networks currently in use.
TCP and UDP are transport layer components that provide the connection point through which
applications access network services. TCP and UDP use IP, which is a lower-layer best effort
delivery service. IP encapsulates TCP packets and UDP datagrams and delivers this information
across router- connected internet works.
The ultimate goal of the transport layer is to provide efficient, reliable, and cost-effective service 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.
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.
TCP
UDP
TCP
UDP
TCP TCP
UDP UDP
TCP
UDP
The main difference between these two protocols is that TCP provides reliability and
congestion control services, while UDP is orientated to improve performance.
The most important and common thing that TCP and UDP are using is the ability to set a
host- to-host communication channel, so the packets will be delivered between processes running
ontwo different computers. UDP is the right choice for application where reliability is not a must
but the speed and performance is. Instead, TCP, even if it takes more time for the processes, has
additional functions like same order delivery, reliability and flow control. As future work, we planto
conduct several studies regarding packets routing in computer networks to improve the fairnessof
data transmissions using different network protocols.
RESULT:
Thus the TCP/UDP performance has been simulated successfully using OPNET.
APPARATUS REQUIRED:
1. VI-RTSIM software.
2. Personal computer.
THEORY:
A Distance vector routing, each router periodically share its knowledge about the entire
network with it’s neighbors.
The three keys to under this algorithm are
1. Knowledge about the whole network.
2. Routing only to neighbor.
3. Information sharing at regular intervals.
Knowledge about the whole work:
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:
link.
The efficiency of transmission is a function only of the number of links required to reach
a destination. In this, the cost on hop count.
Routing Table:
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
RESULT:
Thus Distance Vector routing algorithm has been implemented and shortest-path has been
circulated.
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
itup, we cannot assign any cost to a packet.
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
RESULT:
Thus Link-State routing algorithm has been implemented and shortest-path has been circulated.
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:
else
{
dw[i]=data[k];
k++;
}
}
for(i=0;j<4;i++)
{
count=0;
for(j=(int)pow(2,i);j<12;j<12;j+=(int)pow(2,i))
{
for (k=0;k<(int)pow(2,i);k++)
{
if(dw[j]==’1’)count++;j++;
}
}
if(count%2==0)
dw[(int)pow(2,i)]=’0’;
else
dw[(int)pow(2,i)]=’1’;
}
printf(“in code word is\n\n”);
for(i=1;i<12;i++)
printf(“%c”,dw[i]);
printf(“\n\n enter the received hamming code\n\n”);
scanf(“%s”,cw);
for(i=12;i>0;i--)
cw[i]=cw[i-1];
for(i=0;i<4;i++)
{
count=0;
for(j=(int)pow(2,i);j<12;j+=(int)pow(2,i))
{
for(k=0;k<(int)pow(2,i);k++)
{
if(cw[j]==’1’)count++;j++;
}
}
if (count%2!=0)
err-pos=err-post+(int)pow(2,i);
}
if(err-pos==0)
printf(“\n\n there is no error in received code word \n”);
else
{
if(cw[err-pos]==dw[err-pos])
{
printf(“\n\n there are 2 or more errors in received code……\n\n”);
printf(“sorry…! hamming code cannot correct 2 or more errors….\n”);
flag=1;
CS3591 – COMPUTER NETWORKS LABORATORY
411621104011
}
else
printf(“in there is an error in bit position %d of received code word \n”,err-pos);
if(flag==0)
{
cw[err-pos]=(cw[err-pos]==’1’)?’0’:’1’;
printf(“\n\n corrected code word is \n\n”);
for(i=1;i<12;i++)
printf(“%c”,cw[i]);
}
}
printf(“\n\n”);
}
OUTPUT:
1110110
Code word is
11101100110
10101100110
There is an error in bit position 2 of received code word corrected code word is
11101100110
11101110
Code word is
11101100110