Hey,

I am working on Ubuntu and with NS2.31. 
I am trying to emulate a wireless mesh network in NS2. I have written a UDP
client socket program to generate UDP traffic. Presently, to start with I am
trying to run my UDP socket code and my NS2 code on the same machine. If
this works, I will be running the UDP socket code on another machine and try
to accept traffic from there.

But right now, I am unable to see the emulation results. I do not get any
errors, but my terminal is blank, so is my trace file. Following is the code
that I have used:

set ns [new Simulator]
$ns use-scheduler RealTime


set file1 [open output_gentra.tr w]
$ns trace-all $file1
set file2 [open output_gentra.nam w]
$ns namtrace-all $file2
puts "Starting..........."
proc finish {} {
        global ns 
        global file1
        global file2 
        $ns flush-trace
        close $file1
        close $file2
        $ns close channel
        #exec nam output.nam &
        exit 0
}

set node0 [$ns node]
set node1 [$ns node]
set node2 [$ns node]


set ipnetIN [new Network/IP/UDP]
$ipnetIN open readonly
$ipnetIN bind 127.0.0.1 1234
set aIn [new Agent/Tap]
$aIn network $ipnetIN

set ipnetOUT [new Network/IP/UDP]
$ipnetOUT open writeonly
$ipnetOUT connect 127.0.0.1 1235
set aOut [new Agent/Tap]
$aOut network $ipnetOUT


$ns duplex-link $node0 $node1 30kb 5ms DropTail
$ns duplex-link $node1 $node2 0.1kb 5ms DropTail
$ns queue-limit $node1 $node2 10

$ns attach-agent $node0 $aIn
$ns attach-agent $node2 $aOut
$ns connect $aIn $aOut

puts "Starting..........."
$ns run 


and my UDP client socket program is as follows:

import java.net.*;
import java.lang.*;
import java.io.*;

public class ClientUDP
{
static Thread t;

public static class SimpleClient implements Runnable{


   DatagramSocket  socket;
    DatagramPacket  packet;
    InetAddress     address;
    //byte[]          message = new byte[256];
    int             port = 1234;
String s = "hdhasgdhasgd";
byte[] b = s.getBytes();

public SimpleClient(){

try{
    socket = new DatagramSocket();
    address = InetAddress.getByName("Sam");
    packet = new DatagramPacket(b, b.length,
                                address, port);
}catch(Exception e){}


}
    //
    // Send empty request
    //

   

public void run(){

try{
for(int i=0; i<10000; i++){

 socket.send(packet);
t.sleep(1000);
}
}catch(Exception e){}

}



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

try{
t = new Thread(new SimpleClient());
t.start();
}catch(Exception e){}

 

    //
    // Receive reply and print
    //
    /*packet = new DatagramPacket(message,
                                message.length);
    socket.receive(packet);
    String received = new String(packet.getData(), 0);
    System.out.println("Received: " + received);
    socket.close();*/
  }
}



Could somebody please tell me what is happening??

Sam
-- 
View this message in context: 
http://www.nabble.com/NS2-wireless-network-emulation-tp16715141p16715141.html
Sent from the ns-users mailing list archive at Nabble.com.

Reply via email to