chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · web viewthe...

65
ME -Networking Lab VINAYAKA MISSIONS UNIVERSITY VINAYAKA MISSIONS KIRUPANANDA VARIYAR ENGINEERING COLLEGE SALEM - 636308. Department of Computer Science & Engineering ____________________________ Laboratory Record University Reg.No _________________ Name ________S.PON SANGEETHA___________ Roll No.________________ Class ____________________ Batch ________________ CERTIFIED THAT THIS IS THE BONAFIDE RECORD OF WORK DONE BY Mr. / Ms._______________________________ Staff In-Charge Head of the Department Salem: 636308 Date : Submitted to the Vinayaka Missions University Practical Examination held on ____________ 2013

Upload: dinhnga

Post on 06-Mar-2018

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

VINAYAKA MISSIONS UNIVERSITY

VINAYAKA MISSIONS KIRUPANANDA

VARIYAR ENGINEERING COLLEGE

SALEM - 636308.

Department of Computer Science & Engineering

____________________________ Laboratory Record

University Reg.No _________________

Name ________S.PON SANGEETHA___________ Roll No.________________

Class ____________________ Batch ________________

CERTIFIED THAT THIS IS THE BONAFIDE RECORD OF WORK DONE BY

Mr. / Ms._______________________________

Staff In-Charge Head of the Department

Salem: 636308

Date :

Submitted to the Vinayaka Missions University

Practical Examination held on ____________ 2013

Internal Examiner External Examiner

Page 2: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

CONTENTS

S.NO DATE PROGRAMPAGE

NO SIGNATURE

SOCKET PROGRAMMING

01. A TCP SOCKETS

01. B UDP SOCKETS

01. C APPLICATIONS USING SOCKETS

02. SIMULATION OF SLIDING WINDOW PROTOCOL

03. SIMULATION OF ROUTING PROTOCOL

.DEVELOPMENT OF APPLICATIONS

04. A DNS

04. B E-MAIL

04. C HTTP

04. D MULTI –USER CHAT

05.SIMULATION OF NETWORK MANAGEMENT PROTOCOLS

STUDY OF SIMULATOR PACKAGES

06. A OPNET

06. B NS2

Page 3: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

SOURCE CODE

//Socket Programming using TCP Sockets

Server.java

import java.io.*;

import java.net.*;

public class Server

{

public static void main (String args[]) throws Exception

{

ServerSocket sersock=new ServerSocket (3000);

System.out.println ("Server ready for chatting");

Socket sock= sersock.accept ();

BufferedReader KeyRead= new BufferedReader (new InputStreamReader (System.in));

OutputStream ofstream=sock.getOutputStream ();

PrintWriter pwrite=new PrintWriter (ofstream, true);

InputStream istream=sock.getInputStream ();

BufferedReader receivedread=new BufferedReader (new InputStreamReader (istream));

String receivemessage, sendmessage;

while (true)

{

if ((receivemessage=receivedread.readLine ())! =null)

{

System.out.println (receivemessage);

}

sendmessage=KeyRead.readLine();

pwrite.println (sendmessage);

System.out.flush ();

}

}

}

Page 4: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

Client.java

import java.io.*;

import java.net.*;

public class Client

{

public static void main (String args[]) throws Exception

{

Socket sock=new Socket ("127.0.0.1", 3000);

BufferedReader KeyRead= new BufferedReader (new InputStreamReader (System.in));

OutputStream ofstream=sock.getOutputStream ();

PrintWriter pwrite=new PrintWriter (ofstream, true);

InputStream istream=sock.getInputStream ();

BufferedReader receivedread=new BufferedReader (new InputStreamReader (istream));

System.out.println ("client ready for chatting");

String receivemessage, sendmessage;

while (true)

{

sendmessage=KeyRead.readLine ();

pwrite.println (sendmessage);

System.out.flush ();

if ((receivemessage=receivedread.readLine ())! =null)

{

System.out.println (receivemessage);

}

}

}

}

Page 5: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

OUTPUT

SERVER

CLIENT

Page 6: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

SOURCE CODE

// Socket Programming using UDP Sockets

UDPServer.java

import java.io.*;

import java.net.*;

class UDPServer

{

public static void main(String args[]) throws Exception

{

DatagramSocket serverSocket = new DatagramSocket(9876);

byte[] receiveData = new byte[1024];

byte[] sendData = new byte[1024];

while(true)

{

DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);

serverSocket.receive(receivePacket);

String sentence = new String( receivePacket.getData());

System.out.println("RECEIVED: " + sentence);

InetAddress IPAddress = receivePacket.getAddress();

int port = receivePacket.getPort();

String capitalizedSentence = sentence.toUpperCase();

sendData = capitalizedSentence.getBytes();

DatagramPacket sendPacket =new DatagramPacket(sendData, sendData.length, IPAddress,

port);

serverSocket.send(sendPacket);

}

}

}

Page 7: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

UDPClient.java

import java.io.*;

import java.net.*;

class UDPClient

{

public static void main(String args[])throws Exception

{

BufferedReader informuser= new BufferedReader(new InputStreamReader(System.in));

DatagramSocket clientsocket= new DatagramSocket();

InetAddress IpAddress=InetAddress.getByName("localhost");

byte[] senddata= new byte[1024];

byte[] recedata= new byte[1024];

String sen=informuser.readLine();

senddata=sen.getBytes();

DatagramPacket sendpacket= new

DatagramPacket(senddata,senddata.length,IpAddress,9876);

clientsocket.send(sendpacket);

DatagramPacket receivepacket = new DatagramPacket(recedata, recedata.length);

clientsocket.receive(receivepacket);

String uppersen = new String(receivepacket.getData());

System.out.println("FROM SERVER:\n" + uppersen);

clientsocket.close();

}

}

Page 8: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

OUTPUT

SERVER

CLIENT

Page 9: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

SOURCE CODE

//Applications using SOCKET

Serverapp.java

import java.io.*;

import java.net.*;

public class Serverapp

{

public static void main (String args []) throws Exception

{

String rmess, rmess1;

ServerSocket sersock=new ServerSocket (3000);

Socket sock=sersock.accept ();

OutputStream ostream=sock.getOutputStream ();

PrintWriter pwrite=new PrintWriter (ostream, true);

InputStream istream=sock.getInputStream ();

BufferedReader receivedread=new BufferedReader (new InputStreamReader (istream));

rmess =receivedread.readLine ();

rmess1=receivedread.readLine ();

System.out.println ("The two strings are: "+rmess+"\n"+rmess1);

System.out.println ("After concatenating: "+rmess+rmess1);

}

}

Page 10: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

Clientapp.java

import java.io.*;

import java.net.*;

public class Clientapp

{

public static void main (String args[]) throws Exception

{

String rmess1, rmess2;

Socket sock=new Socket ("127.0.0.1", 3000);

BufferedReader keyread=new BufferedReader (new InputStreamReader (System.in));

OutputStream ostream=sock.getOutputStream ();

PrintWriter pwrite=new PrintWriter (ostream, true);

System.out.println ("Enter the string1:");

rmess1=keyread.readLine ();

System.out.println ("Enter the string2:");

rmess2=keyread.readLine ();

pwrite.println (rmess1);

pwrite.println (rmess2);

System.out.flush ();

}

}

Page 11: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

OUTPUT

SERVER

CLIENT

Page 12: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

SOURCE CODE

// Simulation of Sliding Window Protocol

Server.java:

import java.io.*;

import java.net.*;

public class Server

{

public static void main (String args []) throws Exception

{

int [] rm=new int [100];

int lost, n, i, rlost;

ServerSocket sersock=new ServerSocket (3000);

Socket sock=sersock.accept ();

BufferedReader keyread=new BufferedReader (new InputStreamReader (System.in));

OutputStream ofstream=sock.getOutputStream ();

PrintWriter pwrite=new PrintWriter (ofstream, true);

InputStream istream=sock.getInputStream ();

BufferedReader receivedread=new BufferedReader (new InputStreamReader (istream));

n=Integer.parseInt (receivedread.readLine ());

System.out.println ("the frames are:");

for (i=1; i<=n; i++)

{

rm [i] =Integer.parseInt (receivedread.readLine ());

System.out.println (rm [i]);

}

System.out.println ("\n Enter the frame to be retransmitted :");

lost=Integer.parseInt (keyread.readLine ());

pwrite.println (lost);

rlost=Integer.parseInt (receivedread.readLine ());

System.out.println ("\n The lost frame "+rlost+"is successfully transmitted");

}

}

Page 13: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

Client.java

import java.io.*;

import java.net.*;

public class Client

{

public static void main (String args []) throws Exception

{

int [] f=new int [100];

int receivemessage, n, lf;

Socket sock=new Socket ("127.0.0.1", 3000);

BufferedReader keyread=new BufferedReader (new InputStreamReader(System.in));

OutputStream ostream=sock.getOutputStream ();

PrintWriter pwrite=new PrintWriter (ostream, true);

InputStream istream=sock.getInputStream ();

BufferedReader receivedread=new BufferedReader (new InputStreamReader (istream));

System.out.println ("enter the number of frames are:");

n=Integer.parseInt (keyread.readLine ());

pwrite.println (n);

for (int i=1; i<=n; i++)

{

System.out.println ("enter the frames are:"+i+":");

f[i]=Integer.parseInt (keyread.readLine ());

pwrite.println (f[i]);

}

System.out.println ("\n the frames are:\n");

for (int i=1; i<=n; i++)

System.out.println (f[i]);

receivemessage =Integer.parseInt (receivedread.readLine ());

lf=f [receivemessage];

pwrite.println (lf);

}

}

Page 14: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

OUTPUT

SERVER

CLIENT

Page 15: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

SOURCE CODE

// Simulation of Routing Protocols

#include<stdio.h>

struct node

{

unsigned dist[20];

unsigned from[20];

} rt[10];

int main()

{

int dmat [20] [20];

int n, i, j, k, count=0;

printf ("\nEnter the number of nodes: ");

scanf ("%d", &n);

printf ("\nEnter the cost matrix: \n");

for (i=0; i<n; i++)

for (j=0; j<n; j++)

{

scanf ("%d", &dmat [i] [j]);

dmat[i] [i]=0;

rt[i].dist[j]=dmat[i][j];

rt[i].from[j]=j;

}

do

{

count=0;

for (i=0; i<n; i++)

for (j=0; j<n; j++)

for(k=0; k<n; k++)

if(rt[i].dist[j]>dmat[i][k]+rt[k].dist[j])

{

Page 16: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

rt [i].dist [j]=rt [i].dist [k]+rt [k].dist [j];

rt [i].from[j]=k;

count++;

}

}while (count! =0);

for(i=0; i<n; i++)

{

Printf ("\n\n State value for router %d is \n",i+1);

For (j=0; j<n; j++)

{ printf ("\t\n node %d via %d Distance%d", j+1,rt[i].from[j]+1,rt[i].dist [j]); }

}

Printf ("\n\n");

}

Page 17: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

OUTPUT

MEstudent@MELab:~$ cc Router.c

MEstudent@MELab:~$ ./a.out

Enter the number of nodes: 4

Enter the cost matrix:

0 1 2 4

1 0 2 3

3 2 0 5

8 3 3 0

State value for Router 1 is

Node 1 via 1 Distance 0Node 2 via 2 Distance 1Node 3 via 3 Distance 2Node 4 via 4 Distance 4

State value for Router 2 is

Node 1 via 1 Distance 1Node 2 via 2 Distance 0Node 3 via 3 Distance 2Node 4 via 4 Distance 3

State value for Router 3 is

Node 1 via 1 Distance 3Node 2 via 2 Distance 2Node 3 via 3 Distance 0Node 4 via 4 Distance 5

State value for Router 4 is

Node 1 via 1 Distance 4Node 2 via 2 Distance 3Node 3 via 3 Distance 3Node 4 via 4 Distance 0

Page 18: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

SOURCE CODE

//Domain Name Service- DNS

DNSServer.java

import java.io.*;

import java.net.*;

import java.util.*;

class DNSServer

{ public static void main (String args[]) throws Exception

{

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.google.com","www.gmail.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]))

Page 19: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

{

sendbyte=ip[i].getBytes ();

DatagramPacket sender=new DatagramPacket (sendbyte, sendbyte.length, addr, port);

server.send (sender);

break;

}

}

break;

} }

}

DNSClient.java

import java.io.*;

import java.net.*;

import java.util.*;

class DNSClient

{ public static void main (String args[]) throws Exception

{

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 domain name:");

String str=in.readLine ();

sendbyte=str.getBytes ();

DatagramPacket sender=new DatagramPacket (sendbyte, sendbyte.length, addr, 1309);

client.send (sender);

DatagramPacket receiver=new DatagramPacket (receivebyte, sendbyte.length);

client.receive (receiver);

String s=new String (receiver.getData ());

System.out.println ("IP ADDRESS or DOMAIN NAME "+s.trim ());

Page 20: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

}

}

Page 21: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

OUTPUT

SERVER

CLIENT

Page 22: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

SOURCE CODE

//MULTIUSER CHAT

ChatServer.java

import java.io.*;

import java.net.*;

public class ChatServer

{

public static void main (String args[]) throws Exception

{

int i;

String smess, rmess, b="bye";

ServerSocket sersock=new ServerSocket (3000);

System.out.println ("Server ready to chat :");

do

{

System.out.println ("Client no :");

DataInputStream din=new DataInputStream (System.in);

i=Integer.parseInt(din.readLine());

if (i==0)

System.out.println("client" +i+"is connected :");

Socket sock=sersock.accept();

do

{

BufferedReader kread=new BufferedReader (new InputStreamReader (System.in));

OutputStream os=sock.getOutputStream();

PrintWriter pw=new PrintWriter (os, true);

InputStream ist=sock.getInputStream();

BufferedReader br=new BufferedReader(new InputStreamReader(ist));

rmess=br.readLine();

System.out.println(rmess);

smess=kread.readLine();

pw.println(smess);

Page 23: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

System.out.flush();

}while((rmess.compareToIgnoreCase(b))!=0);

}while(i!=0);

}

}

ChatClient1.java

import java.io.*;

import java.net.*;

public class ChatClient1

{

public static void main(String args[]) throws Exception

{

Socket sock=new Socket("127.0.0.1", 3000);

BufferedReader keyread=new BufferedReader(new InputStreamReader(System.in));

OutputStream ostream=sock.getOutputStream();

PrintWriter pwrite=new PrintWriter(ostream, true);

InputStream istream=sock.getInputStream();

BufferedReader receivedread=new BufferedReader(new InputStreamReader(istream));

System.out.println("client is ready for chat");

String rmess, smess, b="bye";

do

{

smess=keyread.readLine();

pwrite.println(smess);

System.out.flush();

rmess=receivedread.readLine();

System.out.println(rmess);

}while(smess.compareToIgnoreCase(b)!=0);

}

}

Page 24: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

ChatClient2.java

import java.io.*;

import java.net.*;

public class ChatClient2

{

public static void main(String args[]) throws Exception

{

Socket sock=new Socket("127.0.0.1", 3000);

BufferedReader keyread=new BufferedReader(new InputStreamReader(System.in));

OutputStream ostream=sock.getOutputStream();

PrintWriter pwrite=new PrintWriter(ostream, true);

InputStream istream=sock.getInputStream();

BufferedReader receivedread=new BufferedReader(new InputStreamReader(istream));

System.out.println("client is ready for chat");

String rmess, smess, b="bye";

do

{

smess=keyread.readLine();

pwrite.println(smess);

System.out.flush();

rmess=receivedread.readLine();

System.out.println(rmess);

}while(smess.compareToIgnoreCase(b)!=0);

}

}

Page 25: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

OUTPUT

SERVER

CLIENT-1

Page 26: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

CLIENT-2

Page 27: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

SOURCE CODE

//E-MAIL

#include <stdlib.h>

#include <string.h>

#define cknull(x) if((x)==NULL) {perror(""); exit(EXIT_FAILURE);}

#define cknltz(x) if((x)<0) {perror(""); exit(EXIT_FAILURE);}

#define LIST_LEN 4

void email_it(char *filename);

main()

{

char fname[15];

printf("enter the filename\n");

scanf("%s",fname);

email_it(fname);

}

void email_it(char *filename)

{

char tmp[256]={0x0};

char fpBuffer[400]={0x0};

char email_list[LIST_LEN][256]={{"[email protected]"},{0x0}};

int i=0;

for(i=0;*email_list[i]>0x0;i++)

{

cknull(strcpy(tmp, email_list[i]));

cknltz(sprintf (fpBuffer,"mail -s '%s %s' %s < %s","Please Review:", filename,

tmp, filename));

if(system (fpBuffer)==(-1))

{ perror("email failure");

exit(EXIT_FAILURE);

}

}

Page 28: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

}

OUTPUT

Enter the file name: sample.c

/home/1me1/dead.letter….saved message in /home/1me1/dead.letter…..

Page 29: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

SOURCE CODE

//Download a file using HTTP

<html>

<title>MCA</title>

<body background="file:///Z:/USER/PERISONAL/IMAGES/light%20work.jpg"/><center>

<br><br><br><br><br><br><br><br>

<blink><font color="#00ff00" size="10"><i>WELLCOME TO CCET </i></font></blink>

<p><font color="blue">YOUR APPLICATION SUBMITED SUCCESFULLY</FONT></P><a

href="http://10.0.0.7/">GOTO CCET</a>

<a href="file:///Z:/ADD%20ON%20COURSE/html/syll11.docx"> Download File</a>

</center>

</body>

</html>

Page 30: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

OUTPUT

Page 31: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

SOURCE CODE

//Simulation of Network Management Protocol

Manager.java

import java.io.*;

import java.net.*;

public class Manager

{

public static void main(String args[])throws Exception

{

String rmess1, smess, rmess2;

int ch=0;

Socket sock=new Socket("127.0.0.1", 3000);

BufferedReader keyread=new BufferedReader(new InputStreamReader(System.in));

OutputStream ostream=sock.getOutputStream();

PrintWriter pwrite=new PrintWriter(ostream, true);

InputStream istream=sock.getInputStream();

BufferedReader receivedread=new BufferedReader(new InputStreamReader(istream));

System.out.println("Manager\n1.TCP CONNECTION\n2.SYSTEM DETAILS\nEnter your

choice:");

ch=Integer.parseInt(keyread.readLine());

if(ch==1)

{

System.out.println("Enter the object ID for client:");

smess=keyread.readLine();

pwrite.println(smess);

rmess1=receivedread.readLine();

System.out.println("The window size of "+smess+" for TCP connection is "+rmess1);

}

else if(ch==2)

{

System.out.println("Enter the object ID for System:");

smess=keyread.readLine();

Page 32: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

pwrite.println(smess);

System.out.flush(); rmess1=receivedread.readLine();

rmess2=receivedread.readLine();

System.out.println("The manufacturing date for "+smess+" is "+rmess1+"\n The time of

last utilization for "+smess+" is "+rmess2);

}

}

}

Agent1.java

import java.io.*;

import java.net.*;

public class Agent1

{

public static void main(String args[])throws Exception

{ String rmess, smess;

String oid[]={"client1","client2","client3","client4","client5"};

String wsize[]={"5","10","15","20","25"};

ServerSocket sersock=new ServerSocket(3000);

Socket sock=sersock.accept();

System.out.println("Agent1:\nAgen1 is ready!!");

OutputStream ostream=sock.getOutputStream();

PrintWriter pwrite=new PrintWriter(ostream, true);

InputStream istream=sock.getInputStream();

BufferedReader receivedread=new BufferedReader(new InputStreamReader(istream));

rmess=receivedread.readLine();

for(int i=0;i<5;i++)

{ if(rmess.equals(oid[i]))

{

pwrite.println(wsize[i]);

break;

}

}

Page 33: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

} }

Agent2.java

import java.io.*;

import java.net.*;

public class Agent2

{

public static void main(String args[])throws Exception

{

String rmess;

String oid[]={"system1","system2","system3","system4","system5"};

String mdate[]={"1-10-1995","10-03-2008","14-02-2000","29-09-1989","09-12-1987"};

String time[]={"9.a.m","10.a.m","11.a.m","10.p.m","12.p.m"};

ServerSocket sersock=new ServerSocket(3000);

Socket sock=sersock.accept();

System.out.println("Agent2:\n Agent2 is ready!");

OutputStream ostream=sock.getOutputStream();

PrintWriter pwrite=new PrintWriter(ostream, true);

InputStream istream=sock.getInputStream();

BufferedReader receivedread=new BufferedReader(new InputStreamReader(istream));

rmess=receivedread.readLine();

for(int i=0; i<5; i++)

{

if(rmess.equals(oid[i]))

{

pwrite.println(mdate[i]);

pwrite.println(time[i]);

break;

}

}

}

}

Page 34: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

OUTPUT

MANAGER - TCP CONNECTION

AGENT 1

Page 35: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

MANAGER – SYSTEM DETAILS

AGENT2

Page 36: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

STUDY OF OPNET

AIM:

To study about OPNET - Network Simulator.

INTRODUCTION

OPNET (Optimized Network Engineering Tools) is a commercial tool from MIL3 Inc. It is

being developed for almost 15 years.

USE

Network with several hundreds of nodes can be simulated, but it would take time for the

computation. OPNET is used by companies like Thomson-CSF or CNET which use it to model ATM

networks and validate various layers protocols, packet switched radio networks.

THE PACKAGE

The software comprises several tools and is divided in several parts, OPNET Modeler and

OPNET Planner, the Model Library, and the Analysis tool. Features included in this generic

simulator are an event-driven scheduled simulation kernel, integrated analysis tools for

interpreting and synthesizing output data, graphical specification of models and a hierarchical

object-based modeling.

OPNET Modeler is intended for modeling, simulating and analyzing the performance of

large communications networks, computer systems and applications. Common uses are assessing

and feasibility of new designs, optimizing already developed communication systems and

predicting performance.

The modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

level, Process models are structured as a finite state machine. State and transitions are specified

graphically using state-transition diagrams whereas conditions that specify what happen within

each state are programmed with a C-like language called Proto-C. Those processes and built-in

modules in OPNET (source and destination modules, traffic generators, queues, ...) are then

configured with menus and organized into data flow diagrams that represent nodes using the

graphical Node Editor. Using a graphical Network Editor, nodes and links are selected to build up

the topology of a communication network.

Page 37: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

The Analysis Tool provides a graphical environment to view and manipulate data collected

during simulation runs. Results can be analyzed for any network element.

OPNET Planner is an application that allows administrators to evaluate the performance of

communications networks and distributed systems, without programming or compiling. Planner

analyses behavior and performance by discrete-event simulations. Models are built using a

graphical interface. The user only chooses pre-defined models (from the physical layer to the

application) from the library and sets attributes. The user cannot define new models, he should

contact MIL3's modeling service.

The modeling libraries are included with OPNET Modeler and OPNET Planner and contains

protocols and analysis environments, among them ATM, TCP, IP, Frame Relay, FDDI, Ethernet, link

models such as point-to-point or bus, queueing service disciplines such as First-in-First-Out (FIFO),

Last-In-First-Out (LIFO), priority non-preemptive queueing, shortest first job, round-robin or

preempt and resume.

OPNET Modeler is the industry's leading environment for network modeling and

simulation, allowing you to design and study communication networks, devices, protocols, and

applications with unmatched flexibility and scalability. Modeler is used by the world's largest

network equipment manufacturers to accelerate the R&D of network devices and technologies such

as VoIP, TCP, OSPFv3, MPLS, IPv6, and more.

Networking technology has become too complex for traditional analytical methods or "rules

of thumb" to yield an accurate understanding of system behavior. OPNET is the state-of-art network

simulation tool for modeling, simulating and analyzing the performance of

i. Communication Networks, Distributed Systems

ii. Computer systems and Applications.

OPNET MODULES:

Modeler

Terrain Modeling Module (TMM)

High Level Architecture (HLA)

MODELER:

OPNET Modeler is intended for modeling, simulating and analysing the performance of

large communications networks, computer systems and applications. Common uses are assessing

Page 38: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

and feasibility of new designs, optimizing already developed communication systems and

predicting performance.

The modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

level, Process models are structured as a finite state machine. State and transitions are specified

graphically using state-transition diagrams whereas conditions that specify what happen within

each state are programmed with a C-like language called Proto-C. Those processes, and built-in

modules in OPNET (source and destination modules, traffic generators, queues, ...) are then

configured with menus and organized into data flow diagrams that represent nodes using the

graphical Node Editor. Using a graphical Network Editor, nodes and links are selected to build up

the topology of a communication network.

TERRAIN MODELING MODULE (TMM)

Building on the capabilities of OPNET's Wireless Module, the Terrain Modeling Module

provides the next level of accuracy and control for wireless network design and planning. This

module allows you to model environmental effects on wireless network communications anywhere.

Featuring an open-source Longley-Rice model, the Terrain Modeling Module is ready to

replicate any known atmospheric or topological conditions and their combined impact on signal

propagation. Create elevation maps, line-of-sight profiles, and signal-power comparisons of mobile

network models. Interfaces to read DTED and USGS DEM terrain data are provided. Open and

flexible, the Terrain Modeling Module is supported by the standard Radio Transceiver Pipeline,

which enables easy implementation of custom propagation models

HIGH LEVEL ARCHITECTURE (HLA)

The High-Level Architecture (HLA) Module supports building and running a federation of

many simulators, each modeling some aspect of a composite system. The OPNET HLA Module

enables OPNET simulations to model some portion (or the entirety) of the communications aspects

of the HLA federation models. The OPNET-HLA interface provides the various simulators

(federates) the necessary mechanisms to share a common object representation (for persistent

elements), to exchange messages (interactions), and to maintain appropriate time synchronization.

The module supports a large subset of the HLA interfaces, including:

Time management such that an OPNET simulation remains synchronized with overall HLA

time

Page 39: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

Generation and reception of RTI interactions using OPNET packet

Creation, destruction, or discovery of RTI objects during the simulation

Generation of RTI object attribute updates based on changes to OPNET attribute values

Automatic updates of OPNET attributes upon reception of RTI object attribute updates

A user-defined mapping specifying the relation between RTI and OPNET objects

Page 40: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

STUDY OF NS2

AIM:

To study about NS2 - Network Simulator.

INTRODUCTION:

NS is a discrete event simulator targeted at networking research. NS provides substantial

support for simulation of TCP, routing, and multicast protocols over wired and wireless (local and

satellite) networks. NS began as a variant of the REAL network simulator in 1989 and has evolved

substantially over the past few years. In 1995 ns development was supported by DARPA through

the VINT project at LBL, Xerox PARC, UCB, and USC/ISI. Currently ns development is support

through DARPA with SAMAN and through NSF with CONSER, both in collaboration with other

researchers including ACIRI. NS has always included substantial contributions from other

researchers, including wireless code from the UCB Daedelus and CMU Monarch projects and Sun

Microsystems.

The network simulator ns-2 is a widely accepted discrete event network simulator, actively

used for wired and wireless network simulations. It has a highly detailed model of the lower layers

(Physical and MAC) of wireless IEEE 802.11 networks. Ns-2 has also an emulation feature, i.e. the

ability to introduce the simulator into a live network and to simulate a desired network between

real applications in real-time. Within the scope of this project we developed some methods and

extensions to the ns-2 to combine wireless network simulation and network emulation.

OVERVIEW

NS is an event driven network simulator developed at UC Berkeley that simulates variety of

IP networks. It implements network protocols such as TCP and UDP, traffic source behavior such as

FTP, Telnet, Web, CBR and VBR, router queue management mechanism such as Drop Tail, RED and

CBQ, routing algorithms such as Dijkstra, and more. NS also implements multicasting and some of

the MAC layer protocols for LAN simulations. The NS project is now a part of the VINT project that

develops tools for simulation results display, analysis and converters that convert network

topologies generated by well-known generators to NS formats. Currently, NS (version 2) written in

C++ and OTcl (Tcl script language with Object-oriented extensions developed at MIT) is available.

This document talks briefly about the basic structure of NS, and explains in detail how to use NS

mostly by giving examples. Most of the figures that are used in describing the NS basic structure

Page 41: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

and network components are from the 5th VINT/NS Simulator Tutorial/Workshop slides and the

NS Manual (formerly called "NS Notes and Documentation"), modified little bit as needed.

Figure 1. Simplified User's View of NS

As shown in Figure 1, in a simplified user's view, NS is Object-oriented Tcl (OTcl) script

interpreter that has a simulation event scheduler and network component object libraries, and

network setup (plumbing) module libraries (actually, plumbing modules are implemented as

member functions of the base simulator object). In other words, to use NS, you program in OTcl

script language. To setup and run a simulation network, a user should write an OTcl script that

initiates an event scheduler, sets up the network topology using the network objects and the

plumbing functions in the library, and tells traffic sources when to start and stop transmitting

packets through the event scheduler. The term "plumbing" is used for a network setup, because

setting up a network is plumbing possible data paths among network objects by setting the

"neighbor" pointer of an object to the address of an appropriate object. When a user wants to make

a new network object, he or she can easily make an object either by writing a new object or by

making a compound object from the object library, and plumb the data path through the object.

This may sound like complicated job, but the plumbing OTcl modules actually make the job very

easy. The power of NS comes from this plumbing.

Another major component of NS beside network objects is the event scheduler. An event in

NS is a packet ID that is unique for a packet with scheduled time and the pointer to an object that

handles the event. In NS, an event scheduler keeps track of simulation time and fires all the events

in the event queue scheduled for the current time by invoking appropriate network components,

which usually are the ones who issued the events, and let them do the appropriate action associated

with packet pointed by the event. Network components communicate with one another passing

Page 42: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

packets; however this does not consume actual simulation time. All the network components that

need to spend some simulation time handling a packet (i.e. need a delay) use the event scheduler by

issuing an event for the packet and waiting for the event to be fired to itself before doing further

action handling the packet. For example, a network switch component that simulates a switch with

20 microseconds of switching delay issues an event for a packet to be switched to the scheduler as

an event 20 microsecond later. The scheduler after 20 microseconds dequeues the event and fires it

to the switch component, which then passes the packet to an appropriate output link component.

Another use of an event scheduler is timer.

NS is written not only in OTcl but in C++ also. For efficiency reason, NS separates the data

path implementation from control path implementations. In order to reduce packet and event

processing time (not simulation time), the event scheduler and the basic network component

objects in the data path are written and compiled using C++. These compiled objects are made

available to the OTcl interpreter through an OTcl linkage that creates a matching OTcl object for

each of the C++ objects and makes the control functions and the configurable variables specified by

the C++ object act as member functions and member variables of the corresponding OTcl object. In

this way, the controls of the C++ objects are given to OTcl. It is also possible to add member

functions and variables to a C++ linked OTcl object. The objects in C++ that do not need to be

controlled in a simulation or internally used by another object do not need to be linked to OTcl.

Likewise, an object (not in the data path) can be entirely implemented in OTcl. Figure 2 shows an

object hierarchy example in C++ and OTcl. One thing to note in the figure is that for C++ objects that

have an OTcl linkage forming a hierarchy, there is a matching OTcl object hierarchy very similar to

that of C++.

Figure 3 shows the general architecture of NS. In this figure a general user (not an NS

developer) can be thought of standing at the left bottom corner, designing and running simulations

in Tcl using the simulator objects in the OTcl library. The event schedulers and most of the network

components are implemented in C++ and available to OTcl through an OTcl linkage that is

implemented using tclcl. The whole thing together makes NS, which is a OO extended Tcl

interpreter with network simulator libraries.

Page 43: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

Figure 2. C++ and OTcl: The Duality Figure 3. Architectural View of NS

As shown in Figure 1, when a simulation is finished, NS produces one or more text-based

output files that contain detailed simulation data, if specified to do so in the input Tcl (or more

specifically, OTcl) script. The data can be used for simulation analysis (two simulation result

analysis examples are presented in later sections) or as an input to a graphical simulation display

tool called Network Animator (NAM) that is developed as a part of VINT project. NAM has a nice

graphical user interface similar to that of a CD player (play, fast forward, rewind, pause and so on),

and also has a display speed controller. Furthermore, it can graphically present information such as

throughput and number of packet drops at each link, although the graphical information cannot be

used for accurate simulation analysis.

Figure 4. A Simple Network Topology and Simulation Scenario

This network consists of 4 nodes (n0, n1, n2, n3) as shown in above figure. The duplex links

between n0 and n2, and n1 and n2 have 2 Mbps of bandwidth and 10 ms of delay. The duplex link

between n2 and n3 has 1.7 Mbps of bandwidth and 20 ms of delay. Each node uses a DropTail

Page 44: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

queue, of which the maximum size is 10. A "tcp" agent is attached to n0, and a connection is

established to a tcp "sink" agent attached to n3. As default, the maximum size of a packet that a

"tcp" agent can generate is 1KByte. A tcp "sink" agent generates and sends ACK packets to the

sender (tcp agent) and frees the received packets. A "udp" agent that is attached to n1 is connected

to a "null" agent attached to n3. A "null" agent just frees the packets received.

Example - A Simple NS Simulation Script

The following is the explanation of the script above. In general, an NS script starts with

making a Simulator object instance.

set ns [new Simulator]: generates an NS simulator object instance, and assigns it to variable

ns (italics is used for variables and values in this section).

o Initialize the packet format (ignore this for now)

o Create a scheduler (default is calendar scheduler)

o Select the default address format (ignore this for now)

The "Simulator" object has member functions that do the following:

Create compound objects such as nodes and links (described later)

Connect network component objects created (ex. attach-agent)

Set network component parameters (mostly for compound objects)

Create connections between agents (ex. make connection between a "tcp" and "sink")

Specify NAM display options

Most of member functions are for simulation setup and scheduling, however some of them are

for the NAM display. The "Simulator" object member function implementations are located in the

"ns-2/tcl/lib/ns-lib.tcl" file.

$ns color fid color: is to set color of the packets for a flow specified by the flow id (fid). This

member function of "Simulator" object is for the NAM display, and has no effect on the

actual simulation.

$ns namtrace-all file-descriptor: This member function tells the simulator to record

simulation traces in NAM input format. It also gives the file name that the trace will be

written to later by the command $ns flush-trace. Similarly, the member function trace-all is

for recording the simulation trace in a general format.

Page 45: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

proc finish {}: is called after this simulation is over by the command $ns at 5.0 "finish". In

this function, post-simulation processes are specified.

Set n0 [$ns node]: The member function node creates a node. A node in NS is compound

object made of address and port classifiers (described in a later section). Users can create a

node by separately creating an address and a port classifier objects and connecting them

together. However, this member function of Simulator object makes the job easier. To see

how a node is created, look at the files: "ns-2/tcl/libs/ns-lib.tcl" and "ns-2/tcl/libs/ns-

node.tcl".

$ns duplex-link node1 node2 bandwidth delay queue-type: creates two simplex links of

specified bandwidth and delay, and connects the two specified nodes. In NS, the output

queue of a node is implemented as a part of a link, therefore users should specify the queue-

type when creating links. In the above simulation script, DropTail queue is used. If the

reader wants to use a RED queue, simply replace the word DropTail with RED. The NS

implementation of a link is shown in a later section. Like a node, a link is a compound object,

and users can create its sub-objects and connect them and the nodes. Link source codes can

be found in "ns-2/tcl/libs/ns-lib.tcl" and "ns-2/tcl/libs/ns-link.tcl" files. One thing to note is

that you can insert error modules in a link component to simulate a lossy link (actually

users can make and insert any network objects). Refer to the NS documentation to find out

how to do this.

$ns queue-limit node1 node2 number: This line sets the queue limit of the two simplex links

that connect node1 and node2 to the number specified. At this point, the authors do not

know how many of these kinds of member functions of Simulator objects are available and

what they are. Please take a look at "ns-2/tcl/libs/ns-lib.tcl" and "ns-2/tcl/libs/ns-link.tcl",

or NS documentation for more information.

$ns duplex-link-op node1 node2 ...: The next couple of lines are used for the NAM display.

To see the effects of these lines, users can comment these lines out and try the simulation.

Now that the basic network setup is done, the next thing to do is to setup traffic agents such as

TCP and UDP, traffic sources such as FTP and CBR, and attach them to nodes and agents

respectively.

Set tcp [new Agent/TCP]: This line shows how to create a TCP agent. But in general, users

can create any agent or traffic sources in this way. Agents and traffic sources are in fact

basic objects (not compound objects), mostly implemented in C++ and linked to OTcl.

Page 46: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

Therefore, there are no specific Simulator object member functions that create these object

instances. To create agents or traffic sources, a user should know the class names these

objects (Agent/TCP, Agnet/TCPSink, Application/FTP and so on). This information can be

found in the NS documentation or partly in this documentation. But one shortcut is to look

at the "ns-2/tcl/libs/ns-default.tcl" file. This file contains the default configurable

parameter value settings for available network objects. Therefore, it works as a good

indicator of what kind of network objects is available in NS and what are the configurable

parameters.

$ns attach-agent node agent: The attach-agent member function attaches an agent object

created to a node object. Actually, what this function does is call the attach member function

of specified node, which attaches the given agent to itself. Therefore, a user can do the same

thing by, for example, $n0 attach $tcp.

$ns connect agent1 agent2: After two agents that will communicate with each other are

created, the next thing is to establish a logical network connection between them. This line

establishes a network connection by setting the destination address to each others' network

and port address pair.

Assuming that all the network configuration is done, the next thing to do is write a simulation

scenario (i.e. simulation scheduling). The Simulator object has many scheduling member functions.

However, the one that is mostly used is the following:

$ns at time "string": This member function of a Simulator object makes the scheduler

(scheduler_ is the variable that points the scheduler object created by [new Scheduler]

command at the beginning of the script) to schedule the execution of the specified string at

given simulation time. For example, $ns at 0.1 "$cbr start" will make the scheduler call a

start member function of the CBR traffic source object, which starts the CBR to transmit

data. In NS, usually a traffic source does not transmit actual data, but it notifies the

underlying agent that it has some amount of data to transmit, and the agent, just knowing

how much of the data to transfer, creates packets and sends them.

After all network configurations, scheduling and post-simulation procedure specifications are done,

the only thing left is to run the simulation. This is done by $ns run.

Page 47: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

NETWORK COMPONENTS

Figure 6. Class Hierarchy (Partial)

The root of the hierarchy is the TclObject class that is the superclass of all OTcl library

objects (scheduler, network components, timers and the other objects including NAM related ones).

As an ancestor class of TclObject, NsObject class is the superclass of all basic network component

objects that handle packets, which may compose compound network objects such as nodes and

links. The basic network components are further divided into two subclasses, Connector and

Classifier, based on the number of the possible output data paths. The basic network objects that

have only one output data path are under the Connector class, and switching objects that have

possible multiple output data paths are under the Classifier class.

NODE AND ROUTING

A node is a compound object composed of a node entry object and classifiers as shown in

Figure 7. There are two types of nodes in NS. A unicast node has an address classifier that does

unicast routing and a port classifier. A multicast node, in addition, has a classifier that classify

multicast packets from unicast packets and a multicast classifier that performs multicast routing.

Page 48: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

Figure 7. Node (Unicast and Multicast)

In NS, Unicast nodes are the default nodes. To create Multicast nodes the user must

explicitly notify in the input OTcl script, right after creating a scheduler object, that all the nodes

that will be created are multicast nodes. After specifying the node type, the user can also select a

specific routing protocol other than using a default one.

Unicast

- $ns rtproto type

- type: Static, Session, DV, cost, multi-path

Multicast

- $ns multicast (right after set $ns [new Scheduler])

- $ns mrtproto type

- type: CtrMcast, DM, ST, BST

LINK

A link is another major compound object in NS. When a user creates a link using a duplex-link

member function of a Simulator object, two simplex links in both directions are created as shown in

Figure 8.

Figure 8. Link

Page 49: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

One thing to note is that an output queue of a node is actually implemented as a part of

simplex link object. Packets dequeued from a queue are passed to the Delay object that simulates

the link delay, and packets dropped at a queue are sent to a Null Agent and are freed there. Finally,

the TTL object calculates Time To Live parameters for each packet received and updates the TTL

field of the packet.

Tracing

In NS, network activities are traced around simplex links. If the simulator is directed to

trace network activities (specified using $ns trace-all file or $ns namtrace-all file), the links created

after the command will have the following trace objects inserted as shown in Figure 9. Users can

also specifically create a trace object of type type between the given src and dst nodes using the

create-trace {type file src dst} command.

When each inserted trace object (i.e. EnqT, DeqT, DrpT and RecvT) receives a packet, it

writes to the specified trace file without consuming any simulation time, and passes the packet to

the next network object. The trace format will be examined in the General Analysis Example

section.

Figure 9. Inserting Trace Objects

Queue Monitor

Basically, tracing objects are designed to record packet arrival time at which they are

located. Although a user gets enough information from the trace, he or she might be interested in

what is going on inside a specific output queue. For example, a user interested in RED queue

behavior may want to measure the dynamics of average queue size and current queue size of a

specific RED queue (i.e. need for queue monitoring). Queue monitoring can be achieved using queue

monitor objects and snoop queue objects as shown in Figure 10.

Page 50: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

Figure 10. Monitoring Queue

When a packet arrives, a snoop queue object notifies the queue monitor object of this event.

The queue monitor using this information monitors the queue. A RED queue monitoring example is

shown in the RED Queue Monitor Example section. Note that snoop queue objects can be used in

parallel with tracing objects even though it is not shown in the above figure.

PACKET FLOW EXAMPLE

Figure 11. Packet Flow Example

Until now, the two most important network components (node and link) were examined.

Figure 11 shows internals of an example simulation network setup and packet flow. The networks

consist of two nodes (n0 and n1) of which the network addresses are 0 and 1 respectively. A TCP

agent attached to n0 using port 0 communicates with a TCP sink object attached to n1 port 0.

Finally, an FTP application (or traffic source) is attached to the TCP agent, asking to send some

amount of data.

Note that the above figure does not show the exact behavior of a FTP over TCP. It only

shows the detailed internals of simulation network setup and a packet flow.

Page 51: chettinadtech.ac.inchettinadtech.ac.in/storage/14-02-24/14-02-24-13-39-49-…  · Web viewThe modeling methodology of OPNET is organized in a hierarchical structure. At the lowest

ME -Networking Lab

PACKET

A NS packet is composed of a stack of headers, and an optional data space As briefly

mentioned in the "Simple Simulation Example" section, a packet header format is initialized when a

Simulator object is created, where a stack of all registered (or possibly useable) headers, such as the

common header that is commonly used by any objects as needed, IP header, TCP header, RTP

header (UDP uses RTP header) and trace header, is defined, and the offset of each header in the

stack is recorded.

Usually, a packet only has the header stack (and a data space pointer that is null). Although a

packet can carry actual data (from an application) by allocating a data space, very few application

and agent implementations support this. This is because it is meaningless to carry data around in a

non-real-time simulation. Another possible approach would be creating a new header for the

application and modifying the underlying agent to write data received from the application to the

new header. The second approach is shown as an example in a later section called "Add New

Application and Agent".

Figure 12. NS Packet Format