Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
02-25-2014, 02:55 AM
|
#1
|
Member
Registered: Apr 2013
Posts: 197
Rep:
|
error : ns: record can not find firstPkttime_ no such variable
Hello friends
I tried a example in ns-2.34
How to get the system throughput without parsing the trace file? (For UDP-based application)
Code:
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagationmodel
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) 1000 ;# max packet in ifq
set val(nn) 5 ;# number of mobilenodes
set val(rp) DSDV ;# routing protocol
Mac/802_11 set RTSThreshold_ 3000 ;# bytes
Mac/802_11 set ShortRetryLimit_ 7 ;# retransmittions
Mac/802_11 set LongRetryLimit_ 4 ;# retransmissions
Mac/802_11 set PreambleLength_ 144 ;# 144 bit
Mac/802_11 set PLCPHeaderLength_ 48 ;# 48 bits
Mac/802_11 set PLCPDataRate_ 1Mb ;# 1Mbps
Mac/802_11 set dataRate_ 1Mb
Mac/802_11 set basicRate_ 1Mb
Mac/802_11 set CWMin_ 31
Mac/802_11 set CWMax_ 1023
Mac/802_11 set SlotTime_ 0.000020 ;# 20us
Mac/802_11 set SIFS_ 0.000010 ;# 10us
set ns_ [new Simulator]
set tracefd [open simple.tr w]
$ns_ trace-all $tracefd
set nf [open out.nam w]
$ns_ namtrace-all-wireless $nf 300 300
set topo [new Topography]
$topo load_flatgrid 300 300
create-god $val(nn)
set chan_1_ [new $val(chan)]
$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) \
-channel $chan_1_ \
-topoInstance $topo \
-agentTrace ON \
-routerTrace OFF \
-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
}
set rng [new RNG]
$rng seed 1
set rand1 [new RandomVariable/Uniform]
for {set i 0} {$i < $val(nn) } {incr i} {
puts "wireless node $i created ..."
set x [expr 150+[$rand1 value]*4]
set y [expr 150+[$rand1 value]*1]
$node_($i) set X_ $x
$node_($i) set Y_ $y
$node_($i) set Z_ 0.0
puts "X_:$x Y_:$y"
}
for {set i 0} {$i < $val(nn) } {incr i} {
set udp_($i) [new Agent/UDP]
$ns_ attach-agent $node_($i) $udp_($i)
set null_($i) [new Agent/LossMonitor]
$ns_ attach-agent $node_($i) $null_($i)
}
for {set i 0} {$i < $val(nn) } {incr i} {
if {$i == ($val(nn)-1)} {
$ns_ connect $udp_($i) $null_(0)
} else {
set j [expr $i+1]
$ns_ connect $udp_($i) $null_($j)
}
set cbr_($i) [new Application/Traffic/CBR]
$cbr_($i) attach-agent $udp_($i)
$cbr_($i) set type_ CBR
$cbr_($i) set packet_size_ 1000
$cbr_($i) set rate_ 500kb
$cbr_($i) set random_ false
}
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at 1.0 "$cbr_($i) start"
$ns_ at 50.0 "$cbr_($i) stop"
}
# Tell nodes when the simulation ends
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at 100.0 "$node_($i) reset";
}
$ns_ at 100.0 "stop"
$ns_ at 100.01 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at 45.0 "record"
proc record {} {
global ns_ null_ val
set sum 0
for {set i 0} {$i < $val(nn) } {incr i} {
set th 0
set a [$null_($i) set bytes_]
set b [$null_($i) set lastPktTime_]
set c [$null_($i) set firstPktTime_]
set d [$null_($i) set npkts_]
if {$b>$c} {
set th [expr ($a-$d*20)*8/($b-$c)]
puts "flow $i has $th bps"
}
set sum [expr $sum+$th]
}
puts "total throughput:$sum bps"
}
proc stop {} {
global ns_ tracefd
$ns_ flush-trace
close $tracefd
}
puts "Starting Simulation..."
$ns_ run
I did these instructions before executing this program
Code:
1. Modify the tools/loss-monitor.h
class LossMonitor : public Agent {
public:
LossMonitor();
virtual int command(int argc, const char*const* argv);
virtual void recv(Packet* pkt, Handler*);
protected:
int nlost_;
int npkts_;
int expected_;
int bytes_;
int seqno_;
double last_packet_time_;
//add the following two lines
double first_packet_time_;
int first;
};
2. Modify the tools/loss-monitor.cc
LossMonitor::LossMonitor() : Agent(PT_NTYPE)
{
bytes_ = 0;
nlost_ = 0;
npkts_ = 0;
expected_ = -1;
last_packet_time_ = 0.;
first_packet_time_ = 0.;
first=0;
seqno_ = 0;
bind("nlost_", &nlost_);
bind("npkts_", &npkts_);
bind("bytes_", &bytes_);
bind("lastPktTime_", &last_packet_time_);
bind("firstPktTime_", &first_packet_time_);
bind("expected_", &expected_);
}
void LossMonitor::recv(Packet* pkt, Handler*)
{
hdr_rtp* p = hdr_rtp::access(pkt);
seqno_ = p->seqno();
bytes_ += hdr_cmn::access(pkt)->size();
++npkts_;
if(first==0){
first_packet_time_=Scheduler::instance().clock();
first=1;
}
/*
* Check for lost packets
*/
if (expected_ >= 0) {
int loss = seqno_ - expected_;
if (loss > 0) {
nlost_ += loss;
Tcl::instance().evalf("%s log-loss", name());
}
}
last_packet_time_ = Scheduler::instance().clock();
expected_ = seqno_ + 1;
Packet::free(pkt);
}
4. Recomplie NS2
cd ns-allinone-2.34/ns-2.34
make clean; make
but i am getting error
firstPktTime not found
please reply
If any one has a solution for this
Last edited by Aska123; 02-25-2014 at 01:53 PM.
|
|
|
02-25-2014, 07:23 AM
|
#3
|
Member
Registered: Apr 2013
Posts: 197
Original Poster
Rep:
|
Sorry Kundfi
I was not aware of code tags.
I have re-compiled ns-2.34
after making changes to tools/loss-monitor.h
and tools/loss-monitor.cc
and tcl/ns-default.tcl
changes made by me are as follows
Code:
1. Modify the tools/loss-monitor.h
class LossMonitor : public Agent {
public:
LossMonitor();
virtual int command(int argc, const char*const* argv);
virtual void recv(Packet* pkt, Handler*);
protected:
int nlost_;
int npkts_;
int expected_;
int bytes_;
int seqno_;
double last_packet_time_;
//add the following two lines
double first_packet_time_;
int first;
};
2. Modify the tools/loss-monitor.cc
LossMonitor::LossMonitor() : Agent(PT_NTYPE)
{
bytes_ = 0;
nlost_ = 0;
npkts_ = 0;
expected_ = -1;
last_packet_time_ = 0.;
first_packet_time_ = 0.;
first=0;
seqno_ = 0;
bind("nlost_", &nlost_);
bind("npkts_", &npkts_);
bind("bytes_", &bytes_);
bind("lastPktTime_", &last_packet_time_);
bind("firstPktTime_", &first_packet_time_);
bind("expected_", &expected_);
}
void LossMonitor::recv(Packet* pkt, Handler*)
{
hdr_rtp* p = hdr_rtp::access(pkt);
seqno_ = p->seqno();
bytes_ += hdr_cmn::access(pkt)->size();
++npkts_;
if(first==0){
first_packet_time_=Scheduler::instance().clock();
first=1;
}
/*
* Check for lost packets
*/
if (expected_ >= 0) {
int loss = seqno_ - expected_;
if (loss > 0) {
nlost_ += loss;
Tcl::instance().evalf("%s log-loss", name());
}
}
last_packet_time_ = Scheduler::instance().clock();
expected_ = seqno_ + 1;
Packet::free(pkt);
}
3. Modify ns-default.tcl file
add
Agent/LossMonitor set firstPktTime_ 0
I took this example from
http://hpds.ee.ncku.edu.tw/~smallko/..._throghput.htm
|
|
|
02-25-2014, 07:41 AM
|
#4
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519
|
Please edit post #1, to use code tags for the c++ code.
And please replace the "c++ text" with the real c++ code :
Looks like some indents are missing :
Code:
public:
LossMonitor();
virtual int command(int argc, const char*const* argv);
virtual void recv(Packet* pkt, Handler*);
protected:
int nlost_;
I.e. you will have to use the indents shown in
http://hpds.ee.ncku.edu.tw/~smallko/..._throghput.htm
** Which line numbers were edited ?
Also : Please attach the edited files as :
`loss-monitor.h.txt' , loss-monitor.cc.txt ,
i.e. suffix .txt is a must : No .txt, and you cannot attach the file.
Attachments : That's the 'Paper clip' button.
-
|
|
|
02-25-2014, 08:44 AM
|
#5
|
Member
Registered: Apr 2013
Posts: 197
Original Poster
Rep:
|
loss-monitor.h loss-monitor.cc and ns-default.tcl
ok
.cc file I saved as loss-monitor-cc.txt
It was showing invalid file for loss-monitor.cc.txt
|
|
|
02-25-2014, 08:50 AM
|
#6
|
Member
Registered: Apr 2013
Posts: 197
Original Poster
Rep:
|
ns-default.tcl and loss-monitor.cc
ns-default.tcl and loss-monitor.cc
|
|
|
02-25-2014, 10:02 AM
|
#7
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519
|
#5, #6 , #1 .
I don't see any "2.34" in http://hpds.ee.ncku.edu.tw/~smallko/..._throghput.htm
And : You will still have to edit post #1 : All c++ code into code tags, please.
-
Last edited by knudfl; 02-25-2014 at 11:12 AM.
|
|
|
02-25-2014, 11:25 AM
|
#8
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519
|
Testing with ns-2.28, your OK "test.tcl" from post #1 : No errors.
Code:
./ns-throughput 1test_UDP_trace.tcl
num_nodes is set 5
INITIALIZE THE LIST xListHead
wireless node 0 created ...
X_:150.00135830880001 Y_:150.55588069999999
wireless node 1 created ...
X_:150.05681863999999 Y_:150.08812266999999
wireless node 2 created ...
X_:151.76469359999999 Y_:150.79915550000001
wireless node 3 created ...
X_:151.25184719999999 Y_:150.81647609999999
wireless node 4 created ...
X_:150.9384072 Y_:150.6388651
Starting Simulation...
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 550.0
SORTING LISTS ...DONE!
flow 0 has 155383.0204194377 bps
flow 1 has 178659.06307888444 bps
flow 2 has 153833.50654319464 bps
flow 3 has 164968.86779817566 bps
flow 4 has 154617.6097945378 bps
total throughput:807462.06763423025 bps
NS EXITING...
The edited files, throughput-without-parsing-the-trace-file-ns228.tar.bz2 are attached.
-
Last edited by knudfl; 02-25-2014 at 11:31 AM.
|
|
|
02-25-2014, 12:58 PM
|
#9
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519
|
The test with ns-2.34 is equally OK. Same output as above from "test.tcl".
New files were created : throughput-without-parsing-the-trace-file-ns234.tar.bz2
https://drive.google.com/file/d/0B7S...it?usp=sharing
Using : 1)
cd ns-allinone-2.34/ && tar xvf throughput-without-parsing-the-trace-file-ns234.tar.bz2
2) ./install ( .. do a make clean in ns-2.34/ before ./install, if it's a remake.)
... ( My actual command was $ export CC=gcc41 CXX=g++41 && ./install ).
About your errors, ref. post #1 . ""firstPktTime_": no such variable " :
* There are some indents in your c++ files that are <space>'s instead of a <TAB>.
* And the comment in ns-default.tcl : "//<text>" , should instead be ";# added ..":
Like my line 1315 → Agent/LossMonitor set firstPktTime_ 0 ;# added ...
-
Last edited by knudfl; 02-25-2014 at 01:06 PM.
|
|
|
02-25-2014, 01:45 PM
|
#10
|
Member
Registered: Apr 2013
Posts: 197
Original Poster
Rep:
|
Hello knudfi
I followed your steps.
1. cd ns-allinone-2.34/ && tar xvf throughput-without-parsing-the-trace-file-ns234.tar.bz2
2. make clean in ns-2.34
3. when I did $ export CC=gcc41 CXX=g++41 && ./install in ns-allinone-2.34
I got errors
configure: error: in `/home/ro/ns-allinone-2.34/tcl8.4.18/unix':
configure: error: C compiler cannot create executables
See `config.log' for more details.
tcl8.4.18 configuration failed! Exiting ...
Tcl is not part of the ns project. Please see www.Scriptics.com
Then in ns-allinone-2.34
I did sudo su
./install
installed successfully but again I am facing same error
Code:
ns: record: can't read "firstPktTime_": no such variable
while executing
"subst $[subst $var]"
(procedure "_o99" line 5)
(Object next line 5)
invoked from within
"_o99 next firstPktTime_"
("eval" body line 1)
invoked from within
"eval $self next $args"
(procedure "_o99" line 18)
(Agent set line 18)
invoked from within
"$null_($i) set firstPktTime_"
(procedure "record" line 8)
invoked from within
"record"
Last edited by Aska123; 02-25-2014 at 02:26 PM.
|
|
|
02-25-2014, 02:14 PM
|
#11
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519
|
# 10 .
Quote:
configure: error: C compiler cannot create executables
|
Well, a tool has to be present , before you can use it.
Which OS ? Please show the output from : $ uname -m <Enter>
... And also specify the OS name and version.
|
|
|
02-25-2014, 02:34 PM
|
#12
|
Member
Registered: Apr 2013
Posts: 197
Original Poster
Rep:
|
Quote:
Originally Posted by knudfl
|
there is no ns-2.34 in this post . I was trying to run it on ns-2.34.
because I have ns-2.34 installed on my system.
|
|
|
02-25-2014, 02:36 PM
|
#13
|
Member
Registered: Apr 2013
Posts: 197
Original Poster
Rep:
|
My OS is ubuntu 10.0.4
command
$ uname -m <Enter>
gives
i686
Last edited by Aska123; 02-25-2014 at 02:41 PM.
|
|
|
02-25-2014, 02:51 PM
|
#14
|
Member
Registered: Apr 2013
Posts: 197
Original Poster
Rep:
|
Quote:
Originally Posted by knudfl
The edited files, throughput-without-parsing-the-trace-file-ns228.tar.bz2 are attached.
-
|
This file is showing nothing
|
|
|
02-25-2014, 03:09 PM
|
#15
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519
|
# 14 .
HOWTO unpack an attached file name.tar.bz2.txt :
Code:
$ mv throughput-without-parsing-the-trace-file-ns228.tar.bz2.txt throughput-without-parsing-the-trace-file-ns228.tar.bz2
$ tar xvf throughput-without-parsing-the-trace-file-ns228.tar.bz2
I.e. you will have to remove .txt , to unpack the package.
.
Last edited by knudfl; 02-25-2014 at 03:10 PM.
|
|
1 members found this post helpful.
|
All times are GMT -5. The time now is 11:16 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|