Chendu College of Engineering and Technology
Chendu College of Engineering and Technology
com
LAB MANUAL
Year / Semester: II / IV
Signature of HOD
www.vidyarthiplus.com
AIM:
To write a java program to perform sliding window.
ALGORITHM:
1.Start the program.
2.Get the frame size from the user
3.To create the frame based on the user request.
4.To send frames to server from the client side.
5.If your frames reach the server it will send ACK signal to client otherwise it will
send NACK signal to client.
6.Stop the program
Program : import
java.net.*; import
java.io.*; import
java.rmi.*;
public class slidsender
{
public static void main(String a[])throws Exception
{
ServerSocket ser=new
ServerSocket(10); Socket s=ser.accept();
DataInputStream in=new DataInputStream(System.in);
DataInputStream in1=new DataInputStream(s.getInputStream());
String sbuff[]=new String[8];
PrintStream p;
int sptr=0,sws=8,nf,ano,i;
String ch;
do
{
p=new PrintStream(s.getOutputStream());
System.out.print("Enter the no. of frames :
"); nf=Integer.parseInt(in.readLine());
p.println(nf);
if(nf<=sws-1)
{
System.out.println("Enter "+nf+" Messages to be send\n");
for(i=1;i<=nf;i++)
{
sbuff[sptr]=in.readLine();
p.println(sbuff[sptr]);
sptr=++sptr%8;
}
sws-=nf;
System.out.print("Acknowledgment received");
ano=Integer.parseInt(in1.readLine());
System.out.println(" for "+ano+" frames");
sws+=nf;
}
else
{
for(i=1;i<=nf;i++)
{
rptr=++rptr%8;
rbuf[rptr]=in.readLine();
System.out.println("The received Frame " +rptr+" is : "+rbuf[rptr]);
}
rws-=nf;
System.out.println("\nAcknowledgment
sent\n"); p.println(rptr+1); rws+=nf; }
else
break;
ch=in.readLine();
}
while(ch.equals("yes"));
}
}
OUTPUT:
//SENDER OUTPUT
Enter the no. of frames : 4
Enter 4 Messages to be send
hiii
how r u
i am fine
how is evryone
Acknowledgment received for 4 frames
Do you wants to send some more frames : no
//RECEIVER OUTPUT
The received Frame 0 is : hiii
The received Frame 1 is : how r u
The received Frame 2 is : i am fine
The received Frame 3 is : how is everyone
AIM:
www.vidyarthiplus.com
To implement socket programming date and time display from client to server using TCP
Sockets
ALGORITHM:
Server
1. Create a server socket and bind it to port.
2. Listen for new connection and when a connection arrives, accept it.
3. Send servers date and time to the client.
4. Read clients IP address sent by the client.
5. Display the client details.
6. Repeat steps 2-5 until the server is terminated.
7. Close all streams.
8. Close the server socket.
9. Stop.
Client
1. Create a client socket and connect it to the servers port number.
2. Retrieve its own IP address using built-in function.
3. Send its address to the server.
4. Display the date & time sent by the server.
5. Close the input and output streams.
6. Close the client socket.
7. Stop.
PROGRAM:
//TCP Date Server--tcpdateserver.java
import java.net.*;
import java.io.*;
import java.util.*;
class tcpdateserver
{
public static void main(String arg[])
{
ServerSocket ss = null;
Socket cs; PrintStream ps;
BufferedReader dis;
String inet; try
{
ss = new ServerSocket(4444);
System.out.println("Press Ctrl+C to quit"); while(true)
{
cs = ss.accept();
ps = new PrintStream(cs.getOutputStream());
www.vidyarthiplus.com
www.vidyarthiplus.com
$ javac tcpdateserver.java $
java tcpdateserver
Press Ctrl+C to quit Client System/IP address is : localhost.localdomain/127.0.0.1 Client
System/IP address is : localhost.localdomain/127.0.0.1
www.vidyarthiplus.com
Client: $
www.vidyarthiplus.com
javac tcpdateclient.java $ java tcpdateclient The date/time on server is: Wed Jul 06 07:12:03
GMT 2011
Every time when a client connects to the server, servers date/time will be returned to the
client for synchronization.
RESULT:
Thus the program for implementing to display date and time from client to server
using TCP Sockets was executed successfully and output verified using various samples.
www.vidyarthiplus.com
Aim:
To write a java program for simulating arp/rarp protocols
ALGORITHM:
server
1.
2.
3.
4.
5.
6.
7.
8.
9.
Program
Program for Address Resolutuion Protocol (ARP) using TCP
Client:
import java.io.*;
import java.net.*;
import java.util.*;
class Clientarp
{
public static void main(String args[])
{
try
www.vidyarthiplus.com
www.vidyarthiplus.com
if(str.equals(ip[i]))www.vidyarthiplus.com
{
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
www.vidyarthiplus.com
String str=in.readLine();www.vidyarthiplus.com
sendbyte=str.getBytes();
DatagramPacket sender=new
DatagramPacket(sendbyte,sendbyte.length,addr,1309);
client.send(sender);
www.vidyarthiplus.com
String ip[]={"165www.165.vidyarthiplus.80.80","165.com.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=new
DatagramPacket(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
Result :
Thus the program for implementing to display simulating ARP /RARP protocols.
www.vidyarthiplus.com
www.vidyarthiplus.com
import java.util.Calendar;
class pingclient
{
public static void main(String args[])throws Exception
{
String str;
int c=0;
long t1,t2;
Socket s=new Socket("127.0.0.1",5555);
www.vidyarthiplus.com
}
}
//pingserver.java
import java.io.*;
import java.net.*;
import java.util.*;
import java.text.*;
class pingserver
{
public static void main(String args[])throws Exception
{
ServerSocket ss=new
ServerSocket(5555); Socket s=ss.accept();
int c=0;
while(c<4)
{
DataInputStream dis=new DataInputStream(s.getInputStream());
PrintStream out=new PrintStream(s.getOutputStream());
String str=dis.readLine();
out.println("Reply from"+InetAddress.getLocalHost()+";Length"+str.length());
c++;
}
s.close();
}
}
Out put :
Result:
Thus the program was implementing to simulating ping and traceroute commands
www.vidyarthiplus.com
www.vidyarthiplus.com
5. Create a socket for HTTP for web page upload and download.
Aim:
To write a java program for socket for HTTP for web page upload and download .
Algorithm
1.Start the program.
2.Get the frame size from the user
3.To create the frame based on the user request.
4.To send frames to server from the client side.
5.If your frames reach the server it will send ACK signal to client otherwise it will
send NACK signal to client.
6.Stop 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();
ImageIO.write(img, "jpg", baos);
baos.flush();
byte[] bytes =
baos.toByteArray(); baos.close();
www.vidyarthiplus.com
System.out.println("Sending imagewwwto.vidyarthiplusserver.");.com
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();
}
}
import java.net.*;
import java.io.*;
import java.awt.image.*;
import javax.imageio.*;
import javax.swing.*;
class Server {
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);
l.setIcon(icon);
f.add(l);
f.pack();
f.setVisible(true);
www.vidyarthiplus.com
}
}
Output
When you run the client code, following output screen would appear on client side.
RESULT
Thus the program was implementing to socket for HTTP for web page upload and
download.
www.vidyarthiplus.com
Aim:
To write a java program to implement RPC (remote procedure call
Algorithm :
1.Start the program.
2.Get the frame size from the user
3.To create the frame based on the user request.
4.To send frames to server from the client side.
5.If your frames reach the server it will send ACK signal to client otherwise it will
send NACK signal to client.
6.Stop the program
Program:
RPC PROGRAM
Client
import java.io.*;
import java.net.*;
import java.util.*;
class Clientrpc
{
public static void main(String args[])
{
try
{
BufferedReader in=new BufferedReader(new
InputStreamReader(System.in)); Socket clsct=new Socket("127.0.0.1",139);
DataInputStream din=new DataInputStream(clsct.getInputStream());
DataOutputStream dout=new DataOutputStream(clsct.getOutputStream());
System.out.println("Enter
String"); String str=in.readLine();
dout.writeBytes(str+'\n');
clsct.close();
}
catch (Exception e)
{
System.out.println(e);
}
}
}
Server
import java.io.*;
import java.net.*;
www.vidyarthiplus.com
import java.util.*;
www.vidyarthiplus.com
class Serverrpc
{
public static void main(String args[])
{
try
{
ServerSocket obj=new
ServerSocket(139); while(true)
{
Socket obj1=obj.accept();
DataInputStream din=new DataInputStream(obj1.getInputStream());
DataOutputStream dout=new
DataOutputStream(obj1.getOutputStream()); String
str=din.readLine();
Process p=Runtime.getRuntime().exec(str);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
OUTPUT
Server
Y:\networks\remote>java
Serverrpc Client
Y:\networks\remote>java
Clientrpc Enter String
calc
Result :
Thus the program was implementing to implement RPC (remote procedure call
www.vidyarthiplus.com
EX-NO 7. Implementationwww.vidyarthiplus.comofSubnetting
Aim:
Write a program to implement subnetting and find the subnet masks.
Algorithm :
1.Start the program.
2.Get the frame size from the user
3.To create the frame based on the user request.
4.To send frames to server from the client side.
5.If your frames reach the server it will send ACK signal to client otherwise it will
send NACK signal to client.
6.Stop the program
Program
import java.util.Scanner;
class Subnet
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print(Enter the ip address: );
String ip = sc.nextLine(); String
split_ip[] = ip.split(\\.);
//SPlit the string after every .
String split_bip[] = new String[4];
//split binary ip
String bip = ;
for(int i=0;i<4;i++){
split_bip[i] = appendZeros(Integer.toBinaryString(Integer.parseInt(split_ip[i])));
// 18 => 18 => 10010 =>
00010010 bip += split_bip[i];
}
System.out.println(IP in binary is +bip);
System.out.print(Enter the number of addresses:
); int n = sc.nextInt();
www.vidyarthiplus.com
//Calculation of mask
www.vidyarthiplus.com
int bits = (int)Math.ceil(Math.log(n)/Math.log(2)); /*eg if address = 120, log 120/log 2 gives
log to the base 2 => 6.9068, ceil gives us upper integer */
System.out.println(Number of bits required for address =
+bits); int mask = 32-bits;
System.out.println(The subnet mask is = +mask);
//Calculation of first address and last
address int fbip[] = new int[32];
for(int i=0; i<32;i++) fbip[i] = (int)bip.charAt(i)-48; //convert cahracter 0,1 to integer
0,1 for(int i=31;i>31-bits;i)//Get first address by ANDing last n bits with 0
fbip[i] &= 0;
String fip[] =
{,,,}; for(int
i=0;i<32;i++)
fip[i/8] = new String(fip[i/8]+fbip[i]);
System.out.print(First address is = );
for(int i=0;i<4;i++)
{ System.out.print(Integer.parseInt(fip[i],2
)); if(i!=3) System.out.print(.);
}
System.out.println();
int lbip[] = new int[32];
for(int i=0; i<32;i++) lbip[i] = (int)bip.charAt(i)-48; //convert cahracter 0,1 to integer 0,1
for(int i=31;i>31-bits;i)//Get last address by ORing last n bits with 1
lbip[i] |= 1;
String lip[] =
{,,,}; for(int
i=0;i<32;i++)
lip[i/8] = new String(lip[i/8]+lbip[i]);
System.out.print(Last address is = );
for(int i=0;i<4;i++)
{ System.out.print(Integer.parseInt(lip[i],2));
if(i!=3) System.out.print(.);
}
System.out.println();
}
static String appendZeros(String s){
String temp = new String(00000000);
return temp.substring(s.length())+ s;
}
}
www.vidyarthiplus.com
www.vidyarthiplus.com
Output
Enter the ip address: 100.110.150.10
IP in binary is 01100100011011101001011000001010
Enter the number of addresses: 7
Number of bits required for address = 3
The subnet mask is = 29
First address is = 100.110.150.8
Last address is = 100.110.150.15
Result :
Thus the Program was displayed implement subnetting and find the subnet masks.
www.vidyarthiplus.com
www.vidyarthiplus.com
5.If your frames reach the server it will send ACK signal to client otherwise it will
send NACK signal to client.
6.Stop the program
Program : /echo
client.java
import java.io.*;
import java.net.*;
import java.util.*;
public class echoclient
{
public static void main(String args[])throws Exception
{
Socket c=null;
DataInputStream usr_inp=null;
DataInputStream din=new DataInputStream(System.in);
DataOutputStream dout=null;
try
{
c=new Socket("127.0.0.1",5678);
usr_inp=new DataInputStream(c.getInputStream());
dout=new DataOutputStream(c.getOutputStream());
}
catch(IOException e)
{
}
www.vidyarthiplus.com
{
String unip;
while((unip=din.readLine())!=null)
{
dout.writeBytes(""+unip);
dout.writeBytes("\n"); System.out.println("\n
the echoed message");
System.out.println(usr_inp.readLine());
System.out.println("\n enter your message");
}
System.exit(0);
}
din.close();
usr_inp.close();
c.close();
}
}
//echoserver.java
import java.io.*; import
java.net.*; public class
echoserver
{
public static void main(String args[])throws Exception
{
ServerSocket m=null;
Socket c=null;
DataInputStream usr_inp=null;
DataInputStream din=new DataInputStream(System.in);
DataOutputStream dout=null;
try
{
m=new ServerSocket(5678);
c=m.accept();
usr_inp=new DataInputStream(c.getInputStream());
dout=new DataOutputStream(c.getOutputStream());
}
catch(IOException e)
{}
if(c!=null || usr_inp!=null)
www.vidyarthiplus.com
www.vidyarthiplus.com
String unip;
while(true)
{
System.out.println("\nMessage from Client...");
String m1=(usr_inp.readLine());
System.out.println(m1);
dout.writeBytes(""+m1);
dout.writeBytes("\n");
}
}
dout.close();
usr_inp.close();
c.close();
}
}
Output :
b. Chat
/talkclient.java
import java.io.*;
import java.net.*;
public class talkclient
{
public static void main(String args[])throws Exception
{
Socket c=null;
DataInputStream usr_inp=null;
DataInputStream din=new DataInputStream(System.in);
DataOutputStream dout=null;
try
www.vidyarthiplus.com
www.vidyarthiplus.com
c=new Socket("127.0.0.1",1234);
usr_inp=new DataInputStream(c.getInputStream());
dout=new DataOutputStream(c.getOutputStream());
}
catch(IOException e)
{}
if(c!=null || usr_inp!=null || dout!=null)
{
String unip;
System.out.println("\nEnter the message for
server:"); while((unip=din.readLine())!=null)
{
dout.writeBytes(""+unip);
dout.writeBytes("\n");
System.out.println("reply");
System.out.println(usr_inp.readLine());
System.out.println("\n enter your message:");
}
System.exit(0);
}
din.close();
usr_inp.close();
c.close();
}
}
//talkserver.java
import java.io.*;
import java.net.*;
public class talkserver
{
public static void main(String args[])throws Exception
{
ServerSocket m=null;
Socket c=null;
DataInputStream usr_inp=null;
DataInputStream din=new DataInputStream(System.in);
DataOutputStream dout=null;
try
{
www.vidyarthiplus.com
m=new ServerSocket(1234);
c=m.accept();
www.vidyarthiplus.com
usr_inp=new DataInputStream(c.getInputStream());
dout=new DataOutputStream(c.getOutputStream());
}
catch(IOException e)
{}
if(c!=null||usr_inp!=null)
{
String unip;
while(true)
{
System.out.println("\nmessage from
client:"); String m1=usr_inp.readLine();
System.out.println(m1);
System.out.println("enter your message:");
unip=din.readLine();
dout.writeBytes(""+unip);
dout.writeBytes("\n");
}
}
dout.close();
usr_inp.close();
c.close();
}
}
OUTPUT:
www.vidyarthiplus.com
www.vidyarthiplus.com
C. File Transfer
Program
File Client
import java.io.*;
import java.net.*;
import java.util.*;
class Clientfile
{
public static void main(String args[])
{
Try
{
String str=in.readLine();
dout.writeBytes(str+'\n');
System.out.println("Enter the new file name:");
String str2=in.readLine();
String str1,ss;
FileWriter f=new FileWriter(str2);
char buffer[];
while(true)
{ str1=din.readLine();
if(str1.equals("-1")) break;
System.out.println(str1);
buffer=new char[str1.length()];
str1.getChars(0,str1.length(),buffer,0);
f.write(buffer);
}
f.close();
clsct.close();
}
catch (Exception e)
{
System.out.println(e);
www.vidyarthiplus.com
}
}
}
www.vidyarthiplus.com
Server
import java.io.*;
import java.net.*;
import java.util.*;
class Serverfile
{ public static void main(String args[])
{
Try
{
ServerSocket obj=new ServerSocket(139);
while(true)
{
Socket obj1=obj.accept();
DataInputStream din=new DataInputStream(obj1.getInputStream());
DataOutputStream dout=new DataOutputStream(obj1.getOutputStream());
String str=din.readLine();
FileReader f=new FileReader(str);
BufferedReader b=new BufferedReader(f);
String s;
while((s=b.readLine())!=null)
{ System.out.println(s);
dout.writeBytes(s+'\n');
}
f.close();
dout.writeBytes("-1\n");
}
}
catch(Exception e)
{
System.out.println(e);}
}
}
www.vidyarthiplus.com
www.vidyarthiplus.com
Output
File content
Computer networks
jhfcgsauf
jbsdava
jbvuesagv
client
Enter the file name:
sample.txt
server
Computer networks
jhfcgsauf
jbsdava
jbvuesagv
client
Enter the new file name:
net.txt
Computer networks
jhfcgsauf
jbsdava
jbvuesagv
Destination file
Computer networks
jhfcgsauf
jbsdava
jbvuesagv
www.vidyarthiplus.com
www.vidyarthiplus.com
EX-NO 9. Applications using TCP and UDP Sockets like DNS, SNMP and File
Transfer
a.DNS
Aim
Program
/ UDP DNS Server
Udpdnsserver
www.vidyarthiplus.com
InetAddress ipaddress;
if (args.length == 0)
ipaddress =
InetAddress.getLocalHost(); else
ipaddress = InetAddress.getByName(args[0]);
byte[] senddata = new byte[1024];
www.vidyarthiplus.com
$ 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
www.vidyarthiplus.com
www.vidyarthiplus.com
b. SNMP
Aim
To write a java program for SNMP application program
Algorithm
1.Start the program.
2.Get the frame size from the user
3.To create the frame based on the user request.
4.To send frames to server from the client side.
5.If your frames reach the server it will send ACK signal to client otherwise it will
send NACK signal to client.
6.Stop the program
Program
import java.io.IOException;
import org.snmp4j.CommunityTarget;
import org.snmp4j.PDU;
import org.snmp4j.Snmp;
import org.snmp4j.Target;
import org.snmp4j.TransportMapping;
import org.snmp4j.event.ResponseEvent;
import org.snmp4j.mp.SnmpConstants;
import org.snmp4j.smi.Address;
import org.snmp4j.smi.GenericAddress;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.VariableBinding;
import org.snmp4j.transport.DefaultUdpTransportMapping;
public class SNMPManager {
Snmp snmp = null;
String address = null;
*
Constructor
*@param
add
*/
www.vidyarthiplus.com
*
*
*
*
*
Method which takes a single OID and returns the response from the agent as a String.
@param oid
*
*
@return
@throws IOException
*/
public String getAsString(OID oid) throws IOException {
www.vidyarthiplus.com
}
/**
* This method is capable of handling multiple OIDs
*
*
*
@param oids
@return
@throws IOException
*/
public ResponseEvent get(OID oids[]) throws IOException {
PDU pdu = new PDU();
for (OID oid : oids) {
pdu.add(new VariableBinding(oid));
}
pdu.setType(PDU.GET);
ResponseEvent event = snmp.send(pdu, getTarget(), null);
if(event != null) {
return event;
}
throw new RuntimeException("GET timed out");
}
/**
*
*
*
www.vidyarthiplus.com
OUT PUT
www.vidyarthiplus.com
String str=in.readLine();
dout.writeBytes(str+'\n');
System.out.println("Enter the new file name:");
String str2=in.readLine();
String str1,ss;
FileWriter f=new FileWriter(str2);
char buffer[];
while(true)
{ str1=din.readLine();
if(str1.equals("-1")) break;
System.out.println(str1);
buffer=new char[str1.length()];
str1.getChars(0,str1.length(),buffer,0);
f.write(buffer);
www.vidyarthiplus.com
} www.vidyarthiplus.com f.close();
clsct.close();
}
catch (Exception e)
{
System.out.println(e);
}
}
}
Server
import java.io.*;
import java.net.*;
import java.util.*;
class Serverfile
{ public static void main(String args[])
{
Try
{
ServerSocket
ServerSocket(139); while(true)
{
Socket obj1=obj.accept();
obj=new
www.vidyarthiplus.com
www.vidyarthiplus.com
Output
File content
Computer networks
jhfcgsauf
jbsdava
jbvuesagv
client
Enter the file name:
sample.txt
server
Computer networks
jhfcgsauf
jbsdava
jbvuesagv
client
Enter the new file name:
net.txt
Computer networks
jhfcgsauf
jbsdava
jbvuesagv
Destination file
Computer networks
jhfcgsauf
jbsdava
jbvuesagv
Result
Thus the program was displayed application using file transfer
www.vidyarthiplus.com
Ns overview
Ns Status
Periodical release (ns-2.26, Feb 2003)
Platform support
FreeBSD, Linux, Solaris, Windows and Mac
Ns unctionalities
Routing, Transportation, Traffic sources,Queuing
disciplines, QoS
Wireless
Ad hoc routing, mobile IP, sensor-MAC
Tracing, visualization and various utilitie
NS(Network Simulators)
Most of the commercial simulators are GUI driven, while some network simulators are
CLI driven. The network model / configuration describes the state of the network (nodes,routers,
switches, links) and the events (data transmissions, packet error etc.). An important output of
simulations are the trace files. Trace files log every packet, every event that occurred in the
simulation and are used for analysis. Network simulators can also provide other tools to facilitate
visual analysis of trends and potential trouble spots.
Most network simulators use discrete event simulation, in which a list of pending
"events" is stored, and those events are processed in order, with some events triggering future
eventssuch as the event of the arrival of a packet at one node triggering the event of the arrival
of that packet at a downstream node.
Simulation of networks is a very complex task. For example, if congestion is high, then
estimation of the average occupancy is challenging because of high variance. To estimate the
likelihood of a buffer overflow in a network, the time required for an accurate answer can be
extremely large. Specialized techniques such as "control variates" and "importance sampling"
have been developed to speed simulation.
www.vidyarthiplus.com
Packet loss
occurs when one or morepacketsof data travelling across a computer networkfail to reachtheir
destination. Packet loss is distinguished as one of the three main error types encountered in
digital communications; the other two being bit errorand spurious packets caused due to noise.
Packets can be lost in a network because they may be dropped when a queue in the network node
overflows. The amount of packet loss during the steady state is another important property of a
congestion control scheme. The larger the value of packet loss, the more difficult it is for
transportlayer protocols to maintain high bandwidths, the sensitivity to loss of individual packets,
as well as to frequency and patterns of loss among longer packet sequences is strongly dependent
on the application itself.
www.vidyarthiplus.com
Throughput
www.vidyarthiplus.com
This is the main performance measure characteristic, and most widely used.
Incommunicationnetworks, such asEthernetorpacket radio, throughputor
network
throughputis the average rate of successfulmessage delivery over a communication channel. The
throughput is usually measured inbitsper second (bit/s orbps), andsometimes indata packetsper
second or data packets pertime slotThis measure how soon the receiver is able to get a certain
amount of data send by the sender. It is determined as the ratio of the total data received to the
end to end delay. Throughput is an important factor which directly impacts the network
performance
Delay
Delay is the time elapsed while a packet travels from one point e.g., source premise or network
ingress to destination premise or network degrees. The larger the valueof delay, the more difficult
it is for transport layer protocols to maintain highbandwidths. We will calculate end to end delay
Queue Length
A queuing system in networks can be described as packets arriving for service, waiting for
service if it is not immediate, and if having waited for service, leaving thesystem after being
served. Thus queue length is very important characteristic to determine that how well the active
queue management of the congestion control
algorithm has been working.
RESULT
Thus the study of Network simulator (NS2)was studied
www.vidyarthiplus.com
www.vidyarthiplus.com
ii. Flooding
www.vidyarthiplus.com
Flooding s a simple routing algorithm in which every incoming packet is sent through every
outgoing link except the one it arrived on.Flooding is used in bridging and in systems such as
Usenet and peer-to-peer file sharing and as part of some routing protocols, including OSPF,
DVMRP, and those used in ad-hoc wireless networks.There are generally two types of flooding
available, Uncontrolled Flooding and Controlled Flooding.Uncontrolled Flooding is the fatal law
of flooding. All nodes have neighbours and route packets indefinitely. More than two neighbours
creates a broadcast storm.
Controlled Flooding has its own two algorithms to make it reliable, SNCF (Sequence Number
Controlled Flooding) and RPF (Reverse Path Flooding). In SNCF, the node attaches its own
address and sequence number to the packet, since every node has a memory of addresses and
sequence numbers. If it receives a packet in memory, it drops it immediately while in RPF, the
node will only send the packet forward. If it is received from the next node, it sends it back to the
sender.
Algorithm
There are several variants of flooding algorithm. Most work roughly as follows:
1. Each node acts as both a transmitter and a receiver.
2. Each node tries to forward every message to every one of its neighbours except the
source node.
This results in every message eventually being delivered to all reachable parts of the network.
Algorithms may need to be more complex than this, since, in some case, precautions have to be
taken to avoid wasted duplicate deliveries and infinite loops, and to allow messages to eventually
expire from the system. A variant of flooding called selective flooding partially addresses these
issues by only sending packets to routers in the same direction. In selective flooding the routers
don't send every incoming packet on every line but only on those lines which are going
approximately in the right direction.
Advantages
Since flooding naturally utilizes every path through the network, it will also use the
shortest path.
www.vidyarthiplus.com
Disadvantages
www.vidyarthiplus.com
Flooding can be costly in terms of wasted bandwidth. While a message may only have
one destination it has to be sent to every host. In the case of a ping flood or a denial of
service attack, it can be harmful to the reliability of a computer network.
Messages can become duplicated in the network further increasing the load on the
networks bandwidth as well as requiring an increase in processing complexity to
disregard duplicate messages.
Duplicate packets may circulate forever, unless certain precautions are taken:
Use a hop count or a time to live count and include it with each packet. This value should
take into account the number of nodes that a packet may have to pass through on the way
to its destination.
Have each node keep track of every packet seen and only forward each packet once
Enforce a network topology without loops
Thus The Perform a case study about the different routing algorithms to select the
network path with itsoptimum and economical during data transfer. Was complicated .
www.vidyarthiplus.com