EX - NO:1 Write A Code Simulating ARP /RARP Protocols: Aim: Algorithm: Server
EX - NO:1 Write A Code Simulating ARP /RARP Protocols: Aim: Algorithm: Server
EX - NO:1 Write A Code Simulating ARP /RARP Protocols: Aim: Algorithm: Server
Aim:
To write a java program for simulating ARP/RARP protocols
ALGORITHM:
server
1. Create a server socket and bind it to port.
2. Listen for new connection and when a connection arrives, accept it.
Aim
Algorithm
5.If your frames reach the server it will send ACK signal to client
otherwise it will
Program :
/echo client.java
import java.io.*;
import java.net.*;
import java.util.*;
public class echoclient
Socket c=null;
DataInputStream usr_inp=null;
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.studentsfocus.com
String unip;
while((unip=din.readLine())!=null)
dout.writeBytes(""+unip);
dout.writeBytes("\n");
System.out.println(usr_inp.readLine());
System.exit(0);
din.close();
usr_inp.close();
c.close();
//echoserver.java
import java.io.*;
import java.net.*;
ServerSocket m=null;
Socket c=null;
DataInputStream usr_inp=null;
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.studentsfocus.com
String unip;
while(true)
String m1=(usr_inp.readLine());
System.out.println(m1);
dout.writeBytes(""+m1);
dout.writeBytes("\n");
dout.close();
usr_inp.close();
c.close();
}
b. Chat
/talkclient.java
import java.io.*;
import java.net.*;
Socket c=null;
DataInputStream usr_inp=null;
DataOutputStream dout=null;
try
www.studentsfocus.com
c=new Socket("127.0.0.1",1234);
usr_inp=new DataInputStream(c.getInputStream());
dout=new DataOutputStream(c.getOutputStream());
}
catch(IOException e)
{}
String unip;
while((unip=din.readLine())!=null)
dout.writeBytes(""+unip);
dout.writeBytes("\n");
System.out.println("reply");
System.out.println(usr_inp.readLine());
System.exit(0);
din.close();
usr_inp.close();
c.close();
//talkserver.java
import java.io.*;
import java.net.*;
ServerSocket m=null;
Socket c=null;
DataInputStream usr_inp=null;
DataOutputStream dout=null;
try
www.studentsfocus.com
m=new ServerSocket(1234);
c=m.accept();
usr_inp=new DataInputStream(c.getInputStream());
dout=new DataOutputStream(c.getOutputStream());
catch(IOException e)
{}
if(c!=null||usr_inp!=null)
String unip;
while(true)
String m1=usr_inp.readLine();
System.out.println(m1);
unip=din.readLine();
dout.writeBytes(""+unip);
dout.writeBytes("\n");
}
}
dout.close();
usr_inp.close();
c.close();
C. File Transfer
Program
File Client
import java.io.*;
import java.net.*;
import java.util.*;
class Clientfile
Try
DataOutputStream dout=new
DataOutputStream(clsct.getOutputStream());
String str=in.readLine();
dout.writeBytes(str+'\n');
String str2=in.readLine();
String str1,ss;
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);
Server
import java.io.*;
import java.net.*;
import java.util.*;
class Serverfile
Try
{
ServerSocket obj=new ServerSocket(139);
while(true)
Socket obj1=obj.accept();
DataOutputStream dout=new
DataOutputStream(obj1.getOutputStream());
String str=din.readLine();
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);}
Aim:
Ns overview
Ns overview
Ns Status
Periodical release (ns-2.26, Feb 2003)
Platform support
FreeBSD, Linux, Solaris, Windows and Mac
Ns unctionalities
disciplines, QoS
Wireless
NS(Network Simulators)
1. ns (open source)
There are a wide variety of network simulators, ranging from the very
simple to the very complex. Minimally, a network simulator must enable
a user to represent a network topology, specifying the nodes on the
network, the links between those nodes and the traffic between
thenodes. More complicated systems may allow the user to specify
everything about the protocols used to handle traffic in a network.
Graphical applications allow users to easily visualize the workings of
their simulated environment. Text-based applications may provide a
less intuitive interface, but may permit more advanced forms of
customization.
Packet loss
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.
Throughput
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
RESULT