RECORD
RECORD
AIM:
To study the usage of commands like tcpdump, netstat, ifconfig, nslookup and traceroute.
DESCRIPTION:
LIST OF COMMANDS:
TCPDUMP:
Tcpdump is a common packet analyzer that runs under the command line. It allows the user to
display TCP/IP and other packets being transmitted or received over a network to which the
computer is attached.
Tcpdump is a command line utility that allows you to capture and analyze network traffic going
through your system. It is often used to help troubleshoot network issues, as well as a security tool.
sudo yum install -y tcpdump
Capturing packets with tcpdump
use the command tcpdump -D to see which interfaces are available for capture
sudo tcpdump -D
1.eth0
2.virbr0
3.eth1
4.any (Pseudo-device that captures on all interfaces)
5.lo [Loopback]
Capture all packets in any interface by running this command:
sudo tcpdump -i any
To limit the number of packets captured and stop tcpdump, use the -c option:
sudo tcpdump -i any -c 5NETSTAT:
Displays active TCP connections, ports on which the computer is listening, Ethernet statistics, the
IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for
the IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols).
Syntax
netstat [-a] [-e] [-n] [-o] [-p Protocol] [-r] [-s] [Interval]
Examples:
NETSTAT:
Netstat –s provides statistics about incoming and outgoing traffic.
Command Explanation
netstat -a Shows all sockets , both listening and non-listening, all protocols like tcp, udp
etc
netstat -at Shows only tcp connections (-au shows only udp connections)
netstat -ant Shows all TCP connections with no dns resolution (show ip numbers instead).
Also show pid and to which program each socket belongs, e add extra info like
sudo netstat -aep
the user. Run as root to see all pids.
netstat -r Shows kernel routing information. This is the same output as route -e
netstat -g Display multicast group membership information for IPv4 and IPv6
Display all services listening for tcp and udp, all free open ports on the local
netstat -lntu
machine
NETBIOSSTAT:
Nbtstat (NetBios over TCP/IP) enables you to check information about NetBios names.
It helps us view the NetBios name cache (nbtstat -c) which shows the NetBios names and the
corresponding IP address that has been resolved (nbtstat -r) by a particular host as well as the
names that have been registered by the local system (nbtstat –n).
Syntax
nbtstat [-a RemoteName] [-A IPAddress] [-c] [-n] [-r] [-R] [-RR] [-s] [-S] [Interval]
Examples:
Nbtstat
Nbtstat -c
Nbtstat -n
IFCONFIG:
$ ifconfig
ifconfig is a system administration utility in Unix-like operating systems for network
interface configuration.
The utility is a command-line interface tool and is also used in the system startup scripts of many
operating systems. It has features for configuring, controlling, and querying TCP/IP network
interface parameters
NSLOOKUP:
Nslookup (Name Server lookup) is a UNIX shell command to query Internet domain name
servers.
Examples:
ns lookup espn.com
TRACEROUTE:
In computing, traceroute and tracert are computer networkdiagnostic commands for displaying
the route (path) and measuring transit delays of packets across an Internet Protocol (IP) network.
The history of the route is recorded as the round-trip times of the packets received from each
successive host (remote node) in the route (path);
Tracert: Determines the path taken to a destination by sending Internet Control Message Protocol
(ICMP) Echo Request messages to the destination with incrementally increasing Time to Live
(TTL) field values.
Examples:
To trace the path to the host named www.google.co.in use following command
tracert www.google.co.in
tracert -d www.google.com
To trace the path to the host named www.google.com and use the loose source route 10.12.0.1-
10.29.3.1-10.1.44.1, type:
tracert -j 10.12.0.1 10.29.3.1 10.1.44.1 www.google.com
Syntax
tracert [-d] [-h MaximumHops] [-j HostList] [-w Timeout] [TargetName]
OUTPUT:
RESULT:
Thus the usage of commands like tcpdump, netstat, ifconfig, nslookup and traceroute were
studied and the commands were executed successfully.
EX NO:1 B SIMULATING PING AND TRACEROUTE COMMANDS
DATE:
AIM:
To Write the java program for simulating Ping and Trace route commands.
ALGORITHM:
1.Start the program.
2.Create a new socket.
3.Get the local Host number using the function.
4.Using readline function get the systems time, length of data send and its TTL.
5. Stop the program.
PROGRAM:
CLIENT:
import java.io.*;
import java.net.*;
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);
DataInputStream dis=new DataInputStream(s.getInputStream());
PrintStream out=new PrintStream(s.getOutputStream());
while(c<4)
{
t1=System.currentTimeMillis();
str="Welcome to network programming world"; out.println(str);
System.out.println(dis.readLine()); t2=System.currentTimeMillis();
System.out.println(";TTL="+(t2-t1)+"ms"); c++;
}
s.close();
}
}
SERVER:
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();
}
}
OUTPUT :
SERVER:
CLIENT:
RESULT:
Thus the program was implemented for simulating Ping and Trace route commands.
AIM:
To write a java program for creating socket for HTTP web page upload and download.
CONCEPT:
HTTP
1. The Hypertext Transfer Protocol (HTTP) is a protocol used mainly to access data on the
World Wide Web.
2. HTTP functions as a combination of FTP and SMTP.
3. SMTP messages are stored and forwarded, but HTTP messages are delivered immediately.
4. The commands from the client to the server are embedded in a request message. The
contents of the requested file or other information are embedded in a response message.
ALGORITHM:
Step1: Set a server port as 80.
Step2: Using HTTP services create a Socket for server by specifying the server port
Step3: Use HTTP socket for connecting the client to the URL.
Step4: Use BufferedReader to output stream to place the response from the server by the client.
Step5: Close the Connection as soon the request is been serviced. Use Malformed URL exception
If any errors in grabbing the server
PROGRAM:
CLIENT:
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);
SERVER:
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);
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:
RESULT:
Thus the program for creating sockets for HTTP web page upload and download was
implemented.
AIM:
ALGORITHM:
1. Start the program.
2. Include necessary package in java.
3. Create a socket from client to server.
4. The client establishes a connection to the server.
5. The client accepts the connection and sends data to server and the server to replay the echo
message to the client.
6. The client communicates the server to send the end of the message.
7. Stop the program.
PROGRAM:
ECHO SERVER:
import java.io.*;
import java.net.*;
public class EchoServer
{
public static void main(String args[]) throws Exception
{
try
{
int Port;
BufferedReader Buf =new BufferedReader(new
InputStreamReader(System.in));
System.out.print(" Enter the Port Address : " );
Port=Integer.parseInt(Buf.readLine());
ServerSocket sok =new ServerSocket(Port);
System.out.println(" Server is Ready To Receive a Message. ");
System.out.println(" Waiting ..... ");
Socket so=sok.accept();
if(so.isConnected()==true)
System.out.println(" Client Socket is Connected Succecfully. ");
InputStream in=so.getInputStream();
OutputStream ou=so.getOutputStream();
PrintWriter pr=new PrintWriter(ou);
BufferedReader buf=new BufferedReader(new
InputStreamReader(in));
String str=buf.readLine();
System.out.println(" Message Received From Client : " + str);
System.out.println(" This Message is Forwarded To Client. ");
pr.println(str);
pr.flush();
}
catch(Exception e)
{
System.out.println(" Error : " + e.getMessage());
}
}
}
ECHOCLIENT
import java.io.*;
import java.net.*;
public class EchoClient
{
public static void main(String args[]) throws Exception
{
try {
int Port;
BufferedReader Buf =new BufferedReader(new
InputStreamReader(System.in));
OUTPUT :
RESULT:
Thus the program to implement the concept of echo server and client using TCP was
executed and verified successfully.
AIM:
To Write a java program to implement client-server application for chat using TCP.
ALGORITHM:
CLIENT:
1. Start the program.
2. Include necessary package in java.
3. Create a socket from client to server.
4. The client establishes a connection to the server.
5. The client accepts the connection and to send the data from client to server and vice versa.
6. The client communicates the server to send the end of the message.
7. Stop the program.
ALGORITHM:
SERVER:
1. Start the program.
2. Include necessary package in java.
3. Create a socket from server to client.
4. The server establishes a connection to the client.
5. The server accepts the connection and to send the data from server to client and vice versa.
6. The server communicates the client to send the end of the message.
7. Stop the program.
PROGRAM:
TCPCHATCLIENT.JAVA
import java.io.*;
import java.net.*;
public class TcpChatClient
{
@SuppressWarnings("deprecation")
public static void main(String args[]) throws
Exception{ InetAddress in =
InetAddress.getLocalHost();
Socket s = new Socket(in,3000);
System.out.println("CLIENT READY");
DataInputStream dis = new DataInputStream(s.getInputStream());
PrintStream ps = new PrintStream(s.getOutputStream());
try {
while (true) {
String st = new DataInputStream(System.in).readLine();
ps.println("CLIENT MESSAGE:"+" "+st);
st = dis.readLine();
System.out.println(st);
}
} catch (Exception e) {
// TODO: handle exception
System.out.println("ERROR:"+" "+e);
}
}
}
TCPCHATSERVER.JAVA import
java.net.*;
import java.io.*;
public class TcpChatServer
{
ServerSocket m_ServerSocket;
Socket clientSocket;
public TcpChatServer()
{
try
{
}
{
}
m_ServerSocket = new ServerSocket(3000);
catch(IOException ioe)
{
System.out.println("Could not create server socket at 12111. Quitting.");
System.exit(-1);
}
System.out.println("SERVER READY:");
System.out.println("Listening for
clients....."); int id = 0;
while(true)
{
try
{
clientSocket = m_ServerSocket.accept();
ClientServiceThread cliThread = new ClientServiceThread(clientSocket, id+
+); cliThread.start();
}
catch(IOException ioe)
{
System.out.println("Exception encountered on accept. Ignoring. Stack Trace
:"); ioe.printStackTrace();
}
}
}
public static void main (String[] args)
{
new TcpChatServer();
}
class ClientServiceThread extends Thread
{
Socket
m_clientSocket; int
m_clientID = -1;
boolean m_bRunThread = true;
ClientServiceThread(Socket s, int
clientID)
{
m_clientSocket = s;
m_clientID =
clientID;
}
public void run(){
try {
DataInputStream dis = new
DataInputStream(clientSocket.getInputStream()); PrintStream
ps = new PrintStream(clientSocket.getOutputStream());
while (true) {
String st =
dis.readLine
();
System.out.
println();
st = new
DataInputStream(System.in).readLi
ne(); ps.println("SERVER
MESSAGE:"+" "+st); }
} catch (Exception e) {
// TODO: handle
exception
System.out.println("
ERROR:"+" "+e);
}
}
}
}
OUTPUT:
RESULT:
DATE:
AIM:
ALGORITHM:
1. Start the program.
2. Include necessary package in java.
3. Create a socket in client to server.
4. The client establishes a connection to the server.
5. The client accepts the connection and transfers the file to server.
6. The server communicates the client that the file is received.
7. Stop the program.
PROGRAM:
SERVER:
ft2server.java
import java.io.*;
import java.net.*;
import java.util.*;
public class ft2server{
public static void main(String args[])throws IOException{
ServerSocket ss=null;
try{
ss=new ServerSocket(8081);
}
catch(IOException e)
{ System.out.println("Could
n't listen"); System.exit(0);
}
Socket cs=null; try{
cs=ss.accept();
System.out.println("Connection established"+cs);
}
catch(Exception e){
System.out.println("Accept failed");
System.exit(1);}
PrintWriter put=new PrintWriter(cs.getOutputStream(),true);
BufferedReader st=new BufferedReader(new InputStreamReader(cs.getInputStream()));
String s=st.readLine();
System.out.println("The requested file is:"+s);
File f=new File(s);
if(f.exists()){
BufferedReader d=new BufferedReader(new FileReader(s));
String line;
while((line=d.readLine())!=null){
put.write(line);
put.flush();}
d.close();
System.out.println("File transfered");
cs.close();
ss.close();
}}}
CLIENT:
ft2client.java
import java.io.*;
import java.net.*;
import java.util.*;
public class ft2client{
public static void main(String args[]) throws IOException{
Socket s=null;
BufferedReader get=null;
PrintWriter put=null;
try{
s=new Socket("192.168.2.203",8081);
get=new BufferedReader(new InputStreamReader(s.getInputStream()));
put=new PrintWriter(s.getOutputStream(),true);
}
catch(Exception e){
System.out.println(e);}
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);
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();
}}
OUTPUT:
RESULT:
Thus the program to transfer a file from server to client using TCP was executed and
verified successfully.
EX NO: 4 DOMAIN NAME SYSTEM USING TCP& UDP
DATE:
AIM:
To write a java program to implement the concept of domain name system using TCP/UDP.
ALGORITHM:
1. Start the program.
2. Include the header files.
3. Declare the variables and assign the values.
4. In try selection, declare the runtime and process.
5. Input the domain name of domain name system.
6. Return the IP address of corresponding domain name to the requested client from domain name
server.
7. Stop the program.
PROGRAM:
CLIENT:
Clientdns12.java
import java.io.*;
import java.net.*;
import java.util.*;
class Clientdns12{
public static void main(String args[]){
try{
DatagramSocket client=new DatagramSocket();
InetAddress
addr=InetAddress.getByName("192.168.2.140");
byte[] sendbyte=new byte[1024];
byte[] receivebyte=new byte[1024];
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the DOMAIN NAME or IP adress:");
String str=in.readLine();
sendbyte=str.getBytes();
DatagramPacket sender=new
DatagramPacket(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("IP address or DOMAIN NAME: "+s.trim());
client.close();
}
catch(Exception e){
System.out.println(e);
}}}
SERVER:
Serverdns12.java
import java.io.*;
import java.net.*;
import java.util.*;
class Serverdns12{
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 name[]={"www.aptitudeguru.com","www.downloadcyclone.blogspot.com"};
for(int i=0;i<ip.length;i++){
if(s.equals(ip[i])){
sendbyte=name[i].getBytes();
DatagramPacket sender=new DatagramPacket(sendbyte,sendbyte.length,addr,port);
server.send(sender);
break;
}
else if(s.equals(name[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:
RESULT:
Thus the program to implement the concept of domain name system using TCP/UDP was
executed and verified successfully.
EX NO: 5 SIMULATION OF ARP/RARP PROTOCOL
DATE:
AIM:
Write a program to implement the concept of ARP/RARP protocol.
ALGORITHM:
1. Start the program.
2. Include necessary package in java.
3. Get MAC or physical address of system using ARP.
4. Display MAC or physical address of system using ARP.
5. Stop the program.
PROGRAM:
App.java
import java.io.*;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
public class App{
public static void main(String[] args){
InetAddress ip;
try{
ip = InetAddress.getLocalHost();
System.out.println("Current IP address : " + ip.getHostAddress());
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
byte[] mac = network.getHardwareAddress();
System.out.print("Current MAC address : ");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mac.length; i++){
sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
}
System.out.println(sb.toString());
}
catch (UnknownHostException e)
{
e.printStackTrace();
}
catch (SocketException e)
{
e.printStackTrace();
}}}
serverrarp.java
import java.io.*;
import java.net.*;
import java.util.*;
class Serverrarp
{
public static void main(String args[])
{
try{
ServerSocket obj=new ServerSocket(139);
Socket obj1=obj.accept();
while(true)
{
DataInputStream din=new DataInputStream(obj1.getInputStream());
DataOutputStream dout=new DataOutputStream(obj1.getOutputStream());
String str=din.readLine();
String ip[]={"165.165.80.80","165.165.79.1"};
String mac[]={"6A:08:AA:C2","8A:BC:E3:FA"};
for(int i=0;i<mac.length;i++)
{
if(str.equals(mac[i]))
{
dout.writeBytes(ip[i]+'\n'); break;
}
}
obj.close();
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Clientrarp.java
OUTPUT:
RESULT:
Thus the implementation of ARP and RARP protocol was verified and implemented
successfully.
DATE:
AIM:
To study about the network simulator version 2 package.
DESCRIPTION:
INTRODUCTION ABOUT NS 2:
NS (version 2) is an object-oriented, discrete event driven network simulator developed at UC
Berkely written in C++ and OTcl. It is used by networking research to simulate wired, wireless and
satellite networks.
NS started as a variant of the REAL network simulator in 1989 and has since been supported
by the VINT project and others. NS allows for the simulation of various protocols, applications,
routing, queue types etc. A graphical front end has been developed for use with Ns known as network
animator (nam). Alternatively trace files can be created for analysis, which can be displayed using
Xgraph, Microsoft Excel and many more.
NS is primarily useful for simulating local and wide area networks. Although NS is fairly easy
to use once you get to know the simulator, it is quite difficult for a first time user, because there are few
user-friendly manuals. Even though there is a lot of documentation written by the developers which has
in depth explanation of the simulator, it is written with the depth of a skilled NS user.
BACKGROUND OF NS 2:
Node types
Nodes in Ns are the hardware entities (hosts) within a simulation topology. Each simulation
requires an instance of the simulator class. Nodes are defined in a standalone class in Otcl. Two basic
node types exist unicast and multicast, which contain components that are TclObjects, which give them
the correct functionality for routing in a particular simulation.
The node can be configured to customize it for example to create a mobile node in a wireless
topology. Unicast is the default in Ns. Nodes contain a node entry object and classifiers but to get
started the two main classifiers defined for a node that are of concern here are an address classifier and
a port classifier which ensure incoming packets are sent to the correct agent or outgoing link. This gives
us our first two key words “Agent” and “Link” which allows us to look at a basic node. In the diagram
below there are two nodes, which have a link. The link can be either simplex or duplex.
Each node has an agent attached; this is the connection / protocol, which could be TCP. On top
of this agent sits an application, which puts traffic onto our network such as FTP. An agent is normally
software based.
Typical applications
Two common applications that are used in Ns, which most will have heard of are FTP and
Telnet. When we use these applications from a home or business Pc / workstation, we are in fact using
the client or traffic source part of the application. All forms of users from various locations use FTP
widely and this client software can be by different vendors. To transfer a file-using FTP we put traffic
on the network, but in order for us to complete this we need to connect to a FTP server (FTP daemon)
or the sink node.
Telnet works with the same type of principle in that it uses TCP as the agent with a client
application and traffic is placed on the on the network for example to gain a remote login to a server
(sink node). Other examples of typical applications are e-mail using SMTP all senders are using a client
(agent) which then transfers your e-mail by putting traffic on the network to connect via a e-mail server
(sink node).
This sink node may if required then become an agent to pass on the data to another sink node,
before the person you sent the e-mail to, client application requests the e-mail you sent from the sink
node. HTTP is another example using a web browser as a client, which puts traffic on the network to
connect to a web server (sink node). The more you think about it the more applications you could add
to the list.
Constant bit rate (CBR) data transfer
CBR reserves a constant amount of bandwidth during the connection set up even when idle. The
CBR service was conceived to support applications such as voice and video, which require jitter (small
time variations).
The source may send at a negotiated or lower rate at any time and for any duration. The
connection in Ns would normally be set up with a UDP agent and the traffic source would be CBR. In
the diagram below node0 and 1 are both using UDP and CBR, which are sending data via node2 to the
null agent sink node3. There is bandwidth congestion at node2 which means packets of data are being
dropped for example using a drop tail queue. This results in node3 not receiving all the data.
a header file. A linkage has to be set up within the C++ class to ensure the OTcl can use instances of the
C++ class. Dependent on what is being written, a header file may have to be registered in the packet.h
and ns-packet.tcl.
An overview object modeling using C++
The object-oriented paradigm covers three main areas encapsulation, Inheritance and
polymorphism. C++ extends C by allowing new data types to be defined in a word it encapsulates C. A
class is a logical method that organises data and functions to be contained in the same structure. A class
contains members, which can be allocated permissions that are either public private or protected.
The public part is accessible from anywhere the class can be seen. The private part can only be
used by member functions that makeup the same class or from a friend class. Protected is similar to
private but with the exception of derived classes can also access the class. Each object is an instance of
a class, which has its own data and functions. Constructors and deconstructors are used with classes.
Inheritance allows us to build new classes from existing classes and hence reuse code.
Inheritance again comes in three forms public, private and protected. Member functions from the base
class are made available depending on the form to all derived classes.lymorphism meaning many
forms allows a collection of different object types to be manipulated uniformly through a generic
interface.
Polymorphism comes in three types virtual functions, function name overloading and operator
overloading. The inheritance hierarchy of related objects can be manipulated in the same way using
virtual functions. Function name overloading is when a function is declared more than once in a
program.
When a set of functions that perform a similar operation, overloading is used to collect them
under the same name. The compiler will then determine which function to call. Operators are defined
similar to functions but can be members or non-members of a class. Operators can take two arguments
and are either unary or binary.
We can see how C++ through Tclcl can allow us to create similar hierarchies in both C++ and
OTcl using the linkage, which allows members functions to be shared.
The role of the Tk/Tcl and OTcl command language
Tcl is a command line tool Tk is a graphical interface for Tcl. Tcl is used because of the fast
iteration time it takes to modify a simulation model and re run the script file. Tcl/Tk uses a simple
interface so users do not have to learn any complex languages such as C++.
OTcl as already discussed is built upon or encapsulates features of Tcl and as OTcl is object
oriented it is interfaced with C++ through the use of Tclcl. OTcl is the front-end to the simulator as it is
interpreted rather than compiled, the benefits for Ns is development speed rather than it’s slower
execution speed. So we could say OTcl is used for control as it allows us to design our simulations by
sharing member functions. OTcl is used for triggered actions. It also manipulates the existing objects
in C++.
BASICS OF USING NS 2:
Download the software.
Install NS 2 in your home directory.
- Compile the latest version of NS 2.
- Validate NS 2.
Create your topology.
- Need to understand the real topology and the directory structure in NS 2.
- Modify the existing in C++/.tcl files.
- Create your own .tcl script for this.
Execute the script.
- Analyze your result.
- To run, $ ns filename.tcl and this will then run the script and show the animation in
nam.
- Initially, NS2 instantiates C++ classes based on the tcl scripts.
The complete commented script that when run will invoke the nam and Xgraph. Two screen
shots are shown below of the result.
[ Fig Xgraph.]
RESULT:
Thus the study about network simulator version 2 package has been completed successfully.