[ns] What's wrong with that code?

2007-01-22 Thread giantpassos

Hi everybody, 

Could someone show me the errors in this source code. 

Regards, 

Diego Passos. 

#  
# Define Node Configuration paramaters 
# 
set val(chan)   Channel/WirelessChannel;# channel type 
set val(prop)   Propagation/TwoRayGround   ;# radio-propagation 
model 
set val(netif)  Phy/WirelessPhy;# network interface type 

set val(mac)Mac/802_11;# MAC type 
set val(ifq)Queue/DropTail/PriQueue   ;# interface queue type 

set val(ll) LL ;# link layer type 
set val(ant)Antenna/OmniAntenna;# antenna model 
set val(ifqlen) 50 ;# max packet in ifq 
set val(nn) 11  ;# number of mobilenodes 
set val(rp) DSDV   ;# routing protocol 
set val(x)  1000;# X dimension of the 
topography 
set val(y)  1000   ;# Y dimension of the 
topography 

Mac/802_11 set RTSThreshold_  3000 
Mac/802_11 set basicRate_ 1Mb 
Mac/802_11 set dataRate_ 2Mb 

# *** Initialize Simulator *** 
set ns  [new Simulator] 

# *** Initialize Trace file *** 
set tracefd [open out.tr w] 

$ns trace-all $tracefd 

# *** Initialize Network Animator *** 
set namtrace [open out.nam w] 
$ns namtrace-all-wireless $namtrace $val(x) $val(y) 

# *** set up topography object *** 
set topo   [new Topography] 
$topo load_flatgrid $val(x) $val(y) 

# Create  General Operations Director (GOD) object. It is used to store 
global information about the state of the environment, network, or nodes 
that an 
# omniscent observer would have, but that should not be made known to any 
participant in the simulation. 

create-god $val(nn) 

# configure nodes 
$ns node-config -adhocRouting $val(rp) \ 
 -llType $val(ll) \ 
 -macType $val(mac) \ 
 -ifqType $val(ifq) \ 
 -ifqLen $val(ifqlen) \ 
 -antType $val(ant) \ 
 -propType $val(prop) \ 
 -phyType $val(netif) \ 
 -channelType $val(chan) \ 
 -topoInstance $topo \ 
 -agentTrace ON \ 
 -routerTrace ON \ 
 -macTrace OFF \ 
 -movementTrace OFF 


for {set i 0} {$i  $val(nn) } {incr i} { 

set node_($i) [$ns node] 
$node_($i) random-motion 0;# disable random motion 
} 

$node_(0) set X_ 500.0 
$node_(0) set Y_ 500.0 
$node_(0) set Z_ 0.0 
$ns initial_node_pos $node_(0) 20 

for {set i 1} {$i  $val(nn)} {incr i} { 

$node_($i) set X_ [expr (400+30*$i)] 
$node_($i) set Y_ 400 
$node_($i) set Z_ 0.0 
$ns initial_node_pos $node_($i) 20 

set agent($i) [new Agent/UDP] ;# Create TCP Agent 
$agent($i) set prio_ [expr ($i)]   ;# Set Its priority 
to 0 
$ns attach-agent $node_(0) $agent($i) ;# Attach Agent to source 
node 

set sink($i) [new Agent/LossMonitor]   ;# Create Loss Monitor Sink in 
orde 
to be able to trace the number obytes received 
$ns attach-agent $node_($i) $sink($i)  ;# Attach Agent to sink node 

$ns connect $agent($i) $sink($i);# Connect the nodes 
 
set app($i) [new Application/Traffic/CBR]  ;# Create Constant Bit Rate 
application 
$app($i) set packetSize_ 512   ;# Set Packet Size to 512 
bytes 
$app($i) set rate_ 512Kb;# Set CBR rate to 200 
Kbits/sec 
$app($i) attach-agent $agent($i) ;# Attach Application to agent 


} 

# Function To record Statistcis (Bit Rate, Delay, Drop) 

for {set i 1} {$i  $val(nn)} {incr i} { 


set t($i) [open throughput$i.tr w] 
set d($i) [open delay$i.tr w] 
set l($i) [open loss$i.tr w] 

} 

for {set i 1} {$i  $val(nn)} {incr i} { 

set holdtime($i) 0 
set holdseq($i) 0 
set holdrate($i) 0 

} 

proc record {} { 

set val(nn) 11 

for {set i 1} {$i  $val(nn)} {incr i} { 

global holdtime($i) 
global holdseq($i) 
global holdrate($i) 
 
global t($i) 
global d($i) 
global l($i) 
 
global sink($i) 

} 

set ns [Simulator instance] 

set time 0.9 ;#Set Sampling Time to 0.9 Sec 

for {set i 1} {$i  $val(nn)} {incr i} { 

set bw($i) [$sink($i) set bytes_] 
set nl($i) [$sink($i) set nlost_] 
set lt($i) [$sink($i) set lastPktTime_] 
  

Re: [ns] What's wrong with this code?

2006-08-24 Thread Filippos Kolovos

-
It has several errors, which you can spot in the code that I send you, which
should work.
I also have included a simple trace output for you, so that you will be able
to see the packets that were actually
sent between the 2 agents.

As I understand from the code, you are trying to connect both-way 2 agents
(FullTCP) and send packets between them.
The error message that you are getting is caused by the start and later
the send methods that you are using in your code since:

  1.) You are executing the start and/or the send methods naked,
meaning that you do not specify a specific time point
   (i.e. $ns at 0.1 $client_app start, or $ns at 1.2 $client_app send
100).

  2.) You are not running the simulator from within your script at all

This error message means that there is no target defined for the application
that is trying to send the packet, or in other words,
the simulator has not yet actually created the target addresses of the
nodes, since you did not run it. You have to issue AT THE END of your
script, the command $ns run, to actually start the simulator and just before
that command a finish command (a procedure) that will actually stop the
simulator at a specific point in (the simulated) time.

In the code below which works, I also include some potentialy helpful
comments.
Just copy+paste the code to a tcl file and run it. Then examine the
traces.tr file to see the packets that your applications have sent
to each other.

#**

# finish proc executed at the end

proc finish {} {
global tf

close $tf
exit 0
}

set ns [new Simulator]

set client [$ns node]
set server [$ns node]

set tf [open traces.tr w]
$ns trace-all $tf

$ns duplex-link $client $server 10Mb 10ms DropTail
$ns duplex-link-op $client $server queuePos 0.5

set client_tcp [new Agent/TCP/FullTcp]
set server_tcp [new Agent/TCP/FullTcp]

#Why do you keep that list?
lappend agents_(source) $client_tcp $server_tcp

#You have to put both of them in listening state in order to have a
bi-directional send-packet flow
#meaning for both applications to send to each other application packets
beyond the acknowledgements

$server_tcp listen
$client_tcp listen

$ns attach-agent $client $client_tcp
$ns attach-agent $server $server_tcp

#You have to connect them only once - The opposite direction is redundant
$ns connect $client_tcp $server_tcp

#You do not need to connect to the opposite direction - erase that line
#$ns connect $server_tcp $client_tcp

#You can also try the Application/FTP subclass if you like.

set client_app [new Application]
$client_app attach-agent $client_tcp

set server_app [new Application]
$server_app attach-agent $server_tcp

#You do not need these as well since you are just sending a single packet -
Nevertheless, with the class Application
#the start method does not do anything. You can go and use the send method
directly. You can use the FTP subclass
#to use the start method, but not concurrently with the send methods below -
either one or the other.

#$ns at 0.0 $client_app start
#$ns at 0.1 $server_app start

#Just send the packet at the specified time
$ns at 1.0 $client_app send 100
$ns at 1.5 $server_app send 300

#Schedule the finish time
$ns at 3.0 finish

#Run (begin) the simulator

$ns run

Hope that I have helped

Regards,

-Fk

On 8/24/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 -- Forwarded message --
 From: 임인택 (Intaek Lim) [EMAIL PROTECTED]
 To: ns-users@ISI.EDU
 Date: Wed, 23 Aug 2006 11:39:44 +0900
 Subject: [ns] What's wrong with this code?
 Hello, I just wrote simple tcl script for ns but it did not work.

 -

 set ns [new Simulator]

 set client [$ns node]
 set server [$ns node]

 $ns duplex-link $client $server 10Mb 10ms DropTail
 $ns duplex-link-op $client $server queuePos 0.5

 set client_tcp [new Agent/TCP/FullTcp]
 set server_tcp [new Agent/TCP/FullTcp]
 lappend agents_(source) $client_tcp $server_tcp

 $server_tcp listen

 $ns attach-agent $client $client_tcp
 $ns attach-agent $server $server_tcp

 $ns connect $client_tcp $server_tcp
 $ns connect $server_tcp $client_tcp

 set client_app [new Application]
 $client_app attach-agent $client_tcp

 set server_app [new Application]
 $server_app attach-agent $server_tcp

 $client_app start
 $server_app start

 $client_app send 100

 _


 When I run this script, I get an error like below:


 --- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---
 _o12: no target for slot -1
 _o12 type: Classifier/Hash/Dest
 content dump:
 classifier _o12
 0 offset
 0 shift
 2147483647 mask
 1 slots
 slot 0: _o30 (Classifier/Port)
 -1 default
 -- Finished standard no-slot{} default handler --



 Please tell me what should I do.


 thanks.





-- 
Filippos N Kolovos

Software Systems Analyst  Engineer
M.Sc. (Eng.) in Data Communications

Automation  Networking Department
University of Macedonia Library
Egnatia 156, P.O.Box 1591
540 06 Thessaloniki, Greece

Re: [ns] What's wrong with this code?

2006-08-23 Thread Renata Vidal

who is agents_(source) ?

Why you have twice the same comand?
$ns connect $client_tcp $server_tcp
$ns connect $server_tcp $client_tcp



On 8/22/06, 임인택 (Intaek Lim) [EMAIL PROTECTED] wrote:

 Hello, I just wrote simple tcl script for ns but it did not work.

 -

 set ns [new Simulator]

 set client [$ns node]
 set server [$ns node]

 $ns duplex-link $client $server 10Mb 10ms DropTail
 $ns duplex-link-op $client $server queuePos 0.5

 set client_tcp [new Agent/TCP/FullTcp]
 set server_tcp [new Agent/TCP/FullTcp]
 lappend agents_(source) $client_tcp $server_tcp

 $server_tcp listen

 $ns attach-agent $client $client_tcp
 $ns attach-agent $server $server_tcp

 $ns connect $client_tcp $server_tcp
 $ns connect $server_tcp $client_tcp

 set client_app [new Application]
 $client_app attach-agent $client_tcp

 set server_app [new Application]
 $server_app attach-agent $server_tcp

 $client_app start
 $server_app start

 $client_app send 100

 _


 When I run this script, I get an error like below:


 --- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---
 _o12: no target for slot -1
 _o12 type: Classifier/Hash/Dest
 content dump:
 classifier _o12
 0 offset
 0 shift
 2147483647 mask
 1 slots
 slot 0: _o30 (Classifier/Port)
 -1 default
 -- Finished standard no-slot{} default handler --



 Please tell me what should I do.


 thanks.










-- 
Renata Vidal
Triste é o destino de quem tenta vencer as batalhas e ter sucesso nos
ataques sem cultivar o espírito da iniciativa (A Arte da Guerra – SUN
TSU – pg 102)



[ns] What's wrong with this code?

2006-08-22 Thread 임인택 (Intaek Lim)

Hello, I just wrote simple tcl script for ns but it did not work.

-

set ns [new Simulator]

set client [$ns node]
set server [$ns node]

$ns duplex-link $client $server 10Mb 10ms DropTail
$ns duplex-link-op $client $server queuePos 0.5

set client_tcp [new Agent/TCP/FullTcp]
set server_tcp [new Agent/TCP/FullTcp]
lappend agents_(source) $client_tcp $server_tcp

$server_tcp listen

$ns attach-agent $client $client_tcp
$ns attach-agent $server $server_tcp

$ns connect $client_tcp $server_tcp
$ns connect $server_tcp $client_tcp

set client_app [new Application]
$client_app attach-agent $client_tcp

set server_app [new Application]
$server_app attach-agent $server_tcp

$client_app start
$server_app start

$client_app send 100

_


When I run this script, I get an error like below:


--- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---
_o12: no target for slot -1
_o12 type: Classifier/Hash/Dest
content dump:
classifier _o12
0 offset
0 shift
2147483647 mask
1 slots
slot 0: _o30 (Classifier/Port)
-1 default
-- Finished standard no-slot{} default handler --



Please tell me what should I do.


thanks.