Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BIT STUFFING
- import java.util.*;
- public class BitStuff {
- static Scanner sc = new Scanner (System.in);
- static int i,j;
- public static void main(String[] args) {
- System.out.print("Enter no. of bits in data word ");
- int n = sc.nextInt();
- System.out.println("Enter data word");
- int a[] = new int[n];
- for (i=0; i<n; i++)
- a[i] = sc.nextInt();
- int c=0; //counter
- int b[] = new int[10*n];
- System.out.println("Processing");
- for (i=0,j=0; i<a.length; i++,j++) {
- b[j] = a[i];
- if (a[i] == 1)
- c++;
- else c=0;
- if (c == 5)
- //something to be done
- b[++j] = 0;
- }
- System.out.println("Bit Stuffed Data is");
- System.out.print("01111110| "); //SOF
- for (i=0; i<j; i++)
- System.out.print(b[i]+" ");
- System.out.print("|01111110"); //EOF
- }
- }
- CHECKSUM
- import java.util.*;
- import java.lang.Math;
- public class CheckSum {
- static
- Scanner sc= new Scanner(System.in);
- public static void main(String[] args) {
- Random rnd = new Random();
- int dw[],bi[],di[],a[],b[]; //array
- int i,k=0,l=0,temp; //variable
- int ebn; //error bit
- int c1=0,c2=20,c3=21; //counter
- int sum,sum1,d1,d2,d3,d4,d5,d6,d8; //storing decimal values
- double nd8=0; //store decimal value
- dw = new int[25];
- bi = new int[25];
- di = new int[25];
- a = new int[25];
- b = new int[25];
- System.out.println("Sender Side:");
- //accepting data
- System.out.print("Enter 20 Bit (DW) Data: ");
- for(i=0; i<20; i++)
- dw[i] = sc.nextInt();
- //displaying data
- System.out.print("Your 20 Bit Data Is : ");
- for(i=0;i<=19;i++)
- System.out.print(+dw[i]+" ");
- System.out.println();
- System.out.println("Applying Checksum Method...");
- //binary to decimal conversion of 20 bit data
- d1=(dw[0]*8)+(dw[1]*4)+(dw[2]*2)+(dw[3]*1);
- d2=(dw[4]*8)+(dw[5]*4)+(dw[6]*2)+(dw[7]*1);
- d3=(dw[8]*8)+(dw[9]*4)+(dw[10]*2)+(dw[11]*1);
- d4=(dw[12]*8)+(dw[13]*4)+(dw[14]*2)+(dw[15]*1);
- d5=(dw[16]*8)+(dw[17]*4)+(dw[18]*2)+(dw[19]*1);
- sum=d1+d2+d3+d4+d5;
- // decimal to binary conversion of 20 bit sum
- while(sum> 0) {
- bi[k++]=sum%2;
- sum=sum/2;
- }
- //spliting array bits
- for(i=3;i>=0;i--)
- a[i]=bi[i];
- for(i=k-1;i>=4;i--) {
- b[i]=bi[i];
- c1=c1+1;
- }
- //converting splitted array from data to decimal
- d4=(a[3]*8)+(a[2]*4)+(a[1]*2)+(a[0]*1);
- c1=c1-1;
- for(i=k-1;i>=4 &&c1>=0;i--) {
- nd8=nd8+(b[i]*Math.pow(2,c1));
- c1=c1-1;
- }
- d8=(int)nd8;
- //rounding off
- sum1=d4+d8;
- temp=sum1;
- //convert rounded data from decimal to binary
- while(sum1> 0) {
- di[l++]=sum1%2;
- sum1=sum1/2;
- }
- if(temp>7)
- {
- for(i=l-1;i>=0;i--) {
- dw[c2]=di[i];
- c2=c2+1;
- }
- }
- if(temp<=7) {
- dw[20]=0;
- for(i=l-1;i>=0;i--) {
- dw[c3]=di[i];
- c3=c3+1;
- }
- }
- //1s complement
- if(dw[20]==1)
- dw[20]=0;
- else dw[20]=1;
- if(dw[21]==1)
- dw[21]=0;
- else dw[21]=1;
- if(dw[22]==1)
- dw[22]=0;
- else dw[22]=1;
- if(dw[23]==1)
- dw[23]=0;
- else dw[23]=1;
- System.out.println("Data transmitted Receiver");
- //introducing error
- ebn = (rnd.nextInt(250))/5;
- if(ebn<=25)
- if(dw[ebn]==1)
- dw[ebn]=0;
- else dw[ebn]=1;
- //receiver side
- System.out.println();
- System.out.println("Receiver Side");
- System.out.println("Data Received Is : ");
- for(i=0;i<=23;i++)
- System.out.print(dw[i]+" ");
- //converting 25 bit data from binary to decimal conversion
- d1 = (dw[0]*8)+(dw[1]*4)+(dw[2]*2)+(dw[3]*1);
- d2 = (dw[4]*8)+(dw[5]*4)+(dw[6]*2)+(dw[7]*1);
- d3 = (dw[8]*8)+(dw[9]*4)+(dw[10]*2)+(dw[11]*1);
- d4 = (dw[12]*8)+(dw[13]*4)+(dw[14]*2)+(dw[15]*1);
- d5 = (dw[16]*8)+(dw[17]*4)+(dw[18]*2)+(dw[19]*1);
- d6 = (dw[20]*8)+(dw[21]*4)+(dw[22]*2)+(dw[23]*1);
- sum = d1+d2+d3+d4+d5+d6;
- //converting 25 bit sum from decimal to binary conversion
- k=0; //resetting bits
- l=0; //resetting bits
- while(sum> 0) {
- bi[k++] = sum%2;
- sum = sum/2;
- }
- //spliting array bits
- for(i=3;i>=0;i--)
- a[i]=bi[i];
- c1=0;//resetting counter
- nd8=0;
- sum1=0;
- for(i=k-1;i>=4;i--) {
- b[i]=bi[i];
- c1=c1+1;
- }
- //converting splitted array from data to decimal
- d4=(a[3]*8)+(a[2]*4)+(a[1]*2)+(a[0]*1);
- c1=c1-1;
- for (i=k-1; i>=4 && c1>=0; i--) {
- nd8 = nd8+(b[i]*Math.pow(2,c1));
- c1 = c1-1;
- }
- d8 = (int)nd8;
- sum1 = d4+d8;
- while (sum1> 0) {
- di[l++] = sum1%2;
- sum1 = sum1/2;
- }
- //checking error
- System.out.println();
- System.out.println("Verifying Using Checksum Method...");
- System.out.println("Checking For Error: ");
- if (di[3]==1 &&di[2]==1 &&di[1]==1 &&di[0]==1)
- System.out.println("NO ERROR");
- else System.out.println("ERROR");
- }
- }
- CLIENT
- import java.io.*;
- import java.net.*;
- public class Client {
- public static void main(String[] args) {
- // declaration section:
- // smtpClient: our client socket
- // os: output stream
- // is: input stream
- Socket smtpSocket = null;
- DataOutputStream os = null;
- DataInputStream is = null;
- // Initialization section:
- // Try to open a socket on port 25
- // Try to open input and output streams
- try {
- smtpSocket = new Socket("hostname", 25);
- os = new DataOutputStream(smtpSocket.getOutputStream());
- is = new DataInputStream(smtpSocket.getInputStream());
- } catch (UnknownHostException e) {
- System.err.println("Don't know about host: hostname");
- } catch (IOException e) {
- System.err.println("Couldn't get I/O for the connection to: hostname");
- }
- // If everything has been initialized then we want to write some data
- // to the socket we have opened a connection to on port 25
- if (smtpSocket != null && os != null && is != null) {
- try {
- // The capital string before each colon has a special meaning to SMTP
- // you may want to read the SMTP specification, RFC1822/3
- os.writeBytes("HELO\n");
- os.writeBytes("MAIL From: k3is@fundy.csd.unbsj.ca\n");
- os.writeBytes("RCPT To: k3is@fundy.csd.unbsj.ca\n");
- os.writeBytes("DATA\n");
- os.writeBytes("From: k3is@fundy.csd.unbsj.ca\n");
- os.writeBytes("Subject: testing\n");
- os.writeBytes("Hi there\n"); // message body
- os.writeBytes("\n.\n");
- os.writeBytes("QUIT");
- // keep on reading from/to the socket till we receive the "Ok" from SMTP,
- // once we received that then we want to break.
- String responseLine;
- while ((responseLine = is.readLine()) != null) {
- System.out.println("Server: " + responseLine);
- if (responseLine.indexOf("Ok") != -1) {
- break;
- }
- }
- // clean up:
- // close the output stream
- // close the input stream
- // close the socket
- os.close();
- is.close();
- smtpSocket.close();
- } catch (UnknownHostException e) {
- System.err.println("Trying to connect to unknown host: " + e);
- } catch (IOException e) {
- System.err.println("IOException: " + e);
- }
- }
- }
- }
- CRC
- import java.util.*;
- class Crc {
- static Scanner sc = new Scanner(System.in);
- public static void main(String args[]) {
- int m,g[],n,d[],z[],r[],msb,i,j,k;
- System.out.print("Enter no. of bits in data word : ");
- n=sc.nextInt();
- System.out.print("Enter no. of bits in generator function : ");
- m=sc.nextInt();
- d=new int[n+m];
- g=new int[m];
- System.out.print("Enter data word : ");
- for(i=0;i<n;i++)
- d[i]=sc.nextInt();
- System.out.print("Enter bits in the generator function: ");
- for(j=0;j<m;j++)
- g[j]=sc.nextInt();
- for(i=0;i<m-1;i++)
- d[n+i]=0;
- r=new int[m+n];
- for(i=0;i<m;i++)
- r[i]=d[i];
- z=new int[m];
- for(i=0;i<m;i++)
- z[i]=0;
- for(i=0;i<n;i++)
- {
- k=0;
- msb = r[i];
- for (j=i;j<m+i;j++)
- {
- if (msb==0)
- r[j] = xor(r[j],z[k]);
- else r[j]=xor(r[j],g[k]);
- k++;
- }
- r[m+i] = d[m+i];
- }
- System.out.print("\nThe bits in the remainder are : ");
- for(i=n;i<n+m-1;i++)
- {
- d[i] = r[i];
- System.out.print(d[i]+"");
- }
- System.out.print("\nThe Crc code is : ");
- for(i=0;i<n+m-1;i++)
- System.out.print(d[i]);
- }
- public static int xor(int x,int y)
- {
- if (x==y)
- return(0);
- else return(1);
- }
- }
- DIJKSTRAS
- import java.util.*;
- public class DijkstraAlgorithm {
- private int distances[];
- private Set<Integer> settled;
- private Set<Integer> unsettled;
- private int number_of_nodes;
- private int adjacencyMatrix[][];
- public DijkstraAlgorithm(int number_of_nodes) {
- this.number_of_nodes = number_of_nodes;
- distances = new int[number_of_nodes + 1];
- settled = new HashSet<Integer>();
- unsettled = new HashSet<Integer>();
- adjacencyMatrix = new int[number_of_nodes + 1][number_of_nodes + 1];
- }
- public void DijkstraAlgorithm(int adjacency_matrix[][], int source) {
- int evaluationNode;
- for (int i = 1; i <= number_of_nodes; i++)
- for (int j = 1; j <= number_of_nodes; j++)
- adjacencyMatrix[i][j] = adjacency_matrix[i][j];
- for (int i = 1; i <= number_of_nodes; i++)
- distances[i] = Integer.MAX_VALUE;
- unsettled.add(source);
- distances[source] = 0;
- while (!unsettled.isEmpty()) {
- evaluationNode = getNodeWithMinimumDistanceFromUnsettled();
- unsettled.remove(evaluationNode);
- settled.add(evaluationNode);
- evaluateNeighbours(evaluationNode);
- }
- }
- private int getNodeWithMinimumDistanceFromUnsettled() {
- int min ;
- int node = 0;
- Iterator<Integer> iterator = unsettled.iterator();
- node = iterator.next();
- min = distances[node];
- for (int i = 1; i <= distances.length; i++) {
- if (unsettled.contains(i)) {
- if (distances[i] <= min) {
- min = distances[i];
- node = i;
- }
- }
- }
- return node;
- }
- private void evaluateNeighbours(int evaluationNode)
- {
- int edgeDistance = -1;
- int newDistance = -1;
- for (int destinationNode = 1; destinationNode <= number_of_nodes; destinationNode++)
- {
- if (!settled.contains(destinationNode))
- {
- if (adjacencyMatrix[evaluationNode][destinationNode] != Integer.MAX_VALUE)
- {
- edgeDistance = adjacencyMatrix[evaluationNode][destinationNode];
- newDistance = distances[evaluationNode] + edgeDistance;
- if (newDistance < distances[destinationNode])
- distances[destinationNode] = newDistance;
- unsettled.add(destinationNode);
- }
- }
- }
- }
- public static void main(String... arg)
- {
- Scanner scan = new Scanner(System.in);
- int adjacency_matrix[][];
- int number_of_vertices;
- int source = 0;
- try
- {
- System.out.println("Enter the number of vertices");
- number_of_vertices = scan.nextInt();
- adjacency_matrix = new int[number_of_vertices + 1][number_of_vertices + 1];
- System.out.println("Enter the Weighted Matrix for the graph");
- for (int i = 1; i <= number_of_vertices; i++)
- {
- for (int j = 1; j <= number_of_vertices; j++)
- {
- adjacency_matrix[i][j] = scan.nextInt();
- if (i == j)
- {
- adjacency_matrix[i][j] = 0;
- continue;
- }
- if (adjacency_matrix[i][j] == 0)
- adjacency_matrix[i][j] = Integer.MAX_VALUE;
- }
- }
- System.out.println("Enter the source ");
- source = scan.nextInt();
- DijkstraAlgorithm dijkstrasAlgorithm = new DijkstraAlgorithm(number_of_vertices);
- dijkstrasAlgorithm.DijkstraAlgorithm(adjacency_matrix, source);
- System.out.println("The Shorted Path to all nodes are ");
- for (int i = 1; i <= dijkstrasAlgorithm.distances.length - 1; i++)
- {
- System.out.println(source + " to " + i + " is "+ dijkstrasAlgorithm.distances[i]);
- }
- }
- catch (InputMismatchException inputMismatch)
- {
- System.out.println("Wrong Input Format");
- }
- scan.close();
- }
- }
- SOCKET Client
- import java.net.*;
- import java.io.*;
- public class GreetingClient
- {
- public static void main(String [] args)
- {
- String serverName = args[0];
- int port = Integer.parseInt(args[1]);
- try
- {
- System.out.println("Connecting to " + serverName +
- " on port " + port);
- Socket client = new Socket(serverName, port);
- System.out.println("Just connected to "
- + client.getRemoteSocketAddress());
- OutputStream outToServer = client.getOutputStream();
- DataOutputStream out = new DataOutputStream(outToServer);
- out.writeUTF("Hello from "
- + client.getLocalSocketAddress());
- InputStream inFromServer = client.getInputStream();
- DataInputStream in =
- new DataInputStream(inFromServer);
- System.out.println("Server says " + in.readUTF());
- client.close();
- }catch(IOException e)
- {
- e.printStackTrace();
- }
- }
- }
- SOCKET Server
- import java.net.*;
- import java.io.*;
- public class GreetingServer extends Thread
- {
- private ServerSocket serverSocket;
- public GreetingServer(int port) throws IOException
- {
- serverSocket = new ServerSocket(port);
- serverSocket.setSoTimeout(10000);
- }
- public void run()
- {
- while(true)
- {
- try
- {
- System.out.println("Waiting for client on port " +
- serverSocket.getLocalPort() + "...");
- Socket server = serverSocket.accept();
- System.out.println("Just connected to "
- + server.getRemoteSocketAddress());
- DataInputStream in =
- new DataInputStream(server.getInputStream());
- System.out.println(in.readUTF());
- DataOutputStream out =
- new DataOutputStream(server.getOutputStream());
- out.writeUTF("Thank you for connecting to "
- + server.getLocalSocketAddress() + "\nGoodbye!");
- server.close();
- }catch(SocketTimeoutException s)
- {
- System.out.println("Socket timed out!");
- break;
- }catch(IOException e)
- {
- e.printStackTrace();
- break;
- }
- }
- }
- public static void main(String [] args)
- {
- int port = Integer.parseInt(args[0]);
- try
- {
- Thread t = new GreetingServer(port);
- t.start();
- }catch(IOException e)
- {
- e.printStackTrace();
- }
- }
- }
- HAMMING
- import java.util.*;
- public class Hamming
- {
- static Scanner sc = new Scanner(System.in);
- static int set_parity_bit(int a[])
- {
- int count=0;
- int i;
- int l=a.length;
- for( i=0;i<l;i++)
- if(a[i]==1)
- count++;
- if((count%2)==0)
- return 0;
- else
- return 1;
- }
- public static void main(String args[])
- {
- System.out.println("This is hamming code error detection and correction using EVEN parity");
- System.out.println();
- System.out.println("Enter 4 data bits.D4 D3 D2 D1");
- int n=4;
- int i;
- int d[] = new int[4];
- for(i=n-1;i>=0;i--)
- {
- System.out.println("Enter the value of D"+(i+1));
- d[i]=sc.nextInt();
- }
- int k=0;
- while(Math.pow(2,k)<(n+k+1))
- k++;
- System.out.println();
- System.out.println(k+" parity bits are required for the transmission of data bits.");
- //int p[]=new int[k];
- int h[]=new int[n+k+1];
- for(i=0;i<7;i++)
- h[i]=-1;
- int count=0;
- int c=2;
- while(count<4)
- {
- c++;
- if(c==4)
- continue;
- h[c]=d[count];
- count++;
- }
- int p1[]={h[1],h[3],h[5],h[7]};
- int p2[]={h[2],h[3],h[6],h[7]};
- int p3[]={h[4],h[5],h[6],h[7]};
- int parity[]=new int[3];
- parity[0]=set_parity_bit(p1);
- parity[1]=set_parity_bit(p2);
- parity[2]=set_parity_bit(p3);
- h[1]=parity[0];
- h[2]=parity[1];
- h[4]=parity[2];
- System.out.println("\nSENDER:");
- System.out.print("\nThe data bits entered are: ");
- for(i=3;i>=0;i--)
- System.out.print(d[i]+" ");
- System.out.println("\nThe Parity bits are: ");
- for( i=2;i>=0;i--)
- System.out.println("Value of P"+(i+1)+" is "+parity[i]+" ");
- System.out.print("\nThe Hamming code is as follows :-\nD4 D3 D2 P3 D1 P2 P1 :");
- for( i=(n+k);i>0;i--)
- System.out.print(h[i]+" ");
- System.out.println();
- System.out.println("\nEnter the hamming code with error at any position of your choice.\nNOTE: ENTER A SPACE AFTER EVERY BIT POSITION.\nError should be present only at one bit position");
- for(i=7;i>0;i--)
- h[i] = sc.nextInt();
- int p4[] = {h[1],h[3],h[5],h[7]};
- int p5[] = {h[2],h[3],h[6],h[7]};
- int p6[] = {h[4],h[5],h[6],h[7]};
- parity[0] = set_parity_bit(p4);
- parity[1] = set_parity_bit(p5);
- parity[2] = set_parity_bit(p6);
- int position=(int)(parity[2]*Math.pow(2,2)+parity[1]*Math.pow(2,1)+parity[0]*Math.pow(2,0));
- System.out.println("\nRECEIVER:");
- System.out.println("Error is detected at position "+position+" at the receiving end.");
- System.out.println("Correcting the error.... ");
- if(h[position]==1)
- h[position]=0;
- else h[position]=1;
- System.out.print("The correct code is ");
- for(i=7;i>0;i--)
- System.out.print(h[i]+" ");
- }
- }
- UDPCLIENT
- import java.io.*;
- import java.net.*;
- class UDPClient
- {
- public static void main(String args[]) throws Exception
- {
- BufferedReader inFromUser =
- new BufferedReader(new InputStreamReader(System.in));
- DatagramSocket clientSocket = new DatagramSocket();
- InetAddress IPAddress = InetAddress.getByName("localhost");
- byte[] sendData = new byte[1024];
- byte[] receiveData = new byte[1024];
- String sentence = inFromUser.readLine();
- sendData = sentence.getBytes();
- DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 1234);
- clientSocket.send(sendPacket);
- DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
- clientSocket.receive(receivePacket);
- String modifiedSentence = new String(receivePacket.getData());
- System.out.println("FROM SERVER:" + modifiedSentence);
- clientSocket.close();
- }
- UDP SERVER
- import java.io.*;
- import java.net.*;
- class UDPServer
- {
- public static void main(String args[]) throws Exception
- {
- DatagramSocket serverSocket = new DatagramSocket();
- 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);
- }
- }
- } }
- NS2
- set ns [new Simulator]
- #Define different colors for data flows (for NAM)
- $ns color 1 blue
- $ns color 2 Red
- #Open the NAM trace file
- set nf [open out.nam w]
- $ns namtrace-all $nf
- #Define a 'finish' procedure
- proc finish {} {
- global ns nf
- $ns flush-trace
- #Close the NAM trace file
- close $nf
- #Execute NAM on the trace file
- exec nam out.nam &
- exit 0
- }
- #Create four nodes
- set n0 [$ns node]
- set n1 [$ns node]
- set n2 [$ns node]
- set n3 [$ns node]
- set n4 [$ns node]
- set n5 [$ns node]
- set n6 [$ns node]
- #Create links between the nodes
- $ns duplex-link $n0 $n1 50Mb 10ms DropTail
- $ns duplex-link $n0 $n2 100Mb 10ms DropTail
- $ns duplex-link $n1 $n5 50Mb 10ms DropTail
- $ns duplex-link $n1 $n3 50Mb 10ms DropTail
- $ns duplex-link $n2 $n3 100Mb 10ms DropTail
- $ns duplex-link $n5 $n4 50Mb 10ms DropTail
- $ns duplex-link $n3 $n4 100Mb 10ms DropTail
- $ns duplex-link $n4 $n6 50Mb 10ms DropTail
- #Set Queue Size of link (n2-n3) to 10
- $ns queue-limit $n1 $n5 2
- $ns queue-limit $n1 $n3 2
- $ns queue-limit $n3 $n4 2
- $ns queue-limit $n4 $n6 2
- #Give node position (for NAM)
- $ns duplex-link-op $n0 $n1 orient right-up
- $ns duplex-link-op $n0 $n2 orient right-down
- $ns duplex-link-op $n1 $n5 orient right
- $ns duplex-link-op $n1 $n3 orient right-down
- $ns duplex-link-op $n2 $n3 orient right
- $ns duplex-link-op $n5 $n4 orient right-down
- $ns duplex-link-op $n3 $n4 orient right-up
- $ns duplex-link-op $n1 $n5 orient right
- $ns duplex-link-op $n4 $n6 orient right
- #Monitor the queue for link (n2-n3). (for NA)
- $ns duplex-link-op $n1 $n5 queuePos 1
- $ns duplex-link-op $n3 $n4 queuePos 1
- $ns duplex-link-op $n4 $n6 queuePos 1
- #Setup a TCP connection
- set tcp [new Agent/TCP]
- $tcp set class_ 2
- $ns attach-agent $n0 $tcp
- set sink [new Agent/TCPSink]
- $ns attach-agent $n6 $sink
- $ns connect $tcp $sink
- $tcp set fid_ 1
- #Setup a FTP over TCP connection
- set ftp [new Application/FTP]
- $ftp attach-agent $tcp
- $ftp set type_ FTP
- #Setup a UDP connection
- set udp [new Agent/UDP]
- $ns attach-agent $n0 $udp
- set null [new Agent/Null]
- $ns attach-agent $n6 $null
- $ns connect $udp $null
- $udp set fid_ 2
- #Setup a CBR over UDP connection
- set cbr [new Application/Traffic/CBR]
- $cbr attach-agent $udp
- $cbr set type_ CBR
- $cbr set packet_size_ 10000
- $cbr set rate_ 1mb
- $cbr set random_ false
- #Schedule events for the CBR and FTP agents
- $ns at 0.1 "$ftp start"
- $ns at 1.0 "$cbr start"
- $ns at 3.5 "$cbr stop"
- $ns at 4.0 "$ftp stop"
- #Call the finish procedure after 5 seconds of simulation time
- $ns at 4.7 "finish"
- #Print CBR packet size and interval
- puts "CBR packet size = [$cbr set packet_size_]"
- puts "CBR interval = [$cbr set interval_]"
- #Run the simulation
- $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement