📄 faq(trace分析,常见问题分析).txt
字号:
to your Tcl scrip
(2) If you are using older version, you need to do as below:
To change the value in mac_802-11.h (a macro), then make depend, make
In a similar way, you can change cw_, ShortRetryLimit_, LongRetryLimit_ etc.
-----------------------------------------------------------------------------------
Question 10:
What is size of voice or data packet size used to simulate in a wireless LAN?
Answer:
voip: 150bytes
FTP: vaiable packet size, 150-1500Bytes
HDTV or SDTV: 1500bytes
-----------------------------------------------------------------------------------
Question 11:
How to run a set of similar experiments together?
Answer:
Method 1: You can specify an input parameter to the simulation script. Then, based on the
value of your input, you can name your tracefiles differently. You could create,
for instance, the .sh script on the top of the NS simulator to launch consequently
all the simulations.
Method 2: Type your tcl scipts sequentially, do remember to set different trace files
$>ns code1.tcl
.....Starting Simulation
ns code2.tcl #just type in your commands here sequentially
ns code3.tcl
Method 3: Try doing this in TCL level using for loop. For example, look at parts
of the code below:
proc runsim { num_cbr i }
set CBRrate [expr $i*1000000]
...
...
set traffic [new Application/Traffic/CBR]
$traffic set rate_ $CBRrate
...
...
xxx
}
for {set i 1} {$i < 10} {incr i 1} {
runsim $i
}
You can see that your main code is in the runsim procedure, but the
main control is in the for loop below -- which increases the CBR rate
from 1Mbps to 10Mbps using 1Mbps increment. At the end of the runsim
procedure, you would see I put xxx there. It's where you can make a
calculation and output to your output file (append line by line after
each run); which means you have all the results in the same file ready
to be plotted.
Method 4:just write another script that passes a command line parameter
to your ns script that is the CBR rate
E.g
In your ns script put
if { $argc == 1 } {
set cbr [lindex $argv 0]
puts "CBR: $cbr"
}
<insert the rest of your script>
Then in the running script do something like
set max 20
for { set cbr 1 } { $cbr <= $max } { set cbr [expr $cbr + 1] } {
puts "Running test CBR=$cbr"
exec ns myscript.tcl $cbr
}
-----------------------------------------------------------------------
Question 12:
Rx Power or carrier sense Threshold setting?
Answer:
- enter indep-utils/propagation directory
- g++ -lm -o threshold threshold.cc
- ./threshold
this tool can help you calculate
------------------------------------------------------------------------
Question 13:
How to pass an argument from tcl to c++?
Answer:
method 1: bind the variables you want to share
method 2: For example:
Tcl& tcl = Tcl::instance();
tcl.eval("$cbr set packet_size_");
char* var_temp = tcl.result();
--------------------------------------------------------------------------
Question 14:
How to post analyze the trace file?
ANswer:
The below is a awk script to analyze several parameters (average e-2-e delay,
pdf, normalised routing load and dropped packets,..) for aodv old trace file
format.
BEGIN {
droppedAODVPackets=0;
sends=0;
recvs=0;
# highest packet id can be checked in the trace file for an approximate value
highest_packet_id =500000;
sum=0;
AODV_Adv=0;
}
{
action = $1;
time = $2;
node_1 = $3;
node_2 = $4;
src = $5;
# For stand alone ad hoc trace files:
# if ( packet_id > highest_packet_id ) highest_packet_id = packet_id;
# For wired- and cireless trace files.
if ($5 =="cbr") {
packet_id = $12;
} else {
packet_id = $6;
}
#============= CALCULATE DELAY =========================================
# getting start time is not a problem, provided you're not starting
# traffic at 0.0.
# could test for sending node_1_address or flow_id here.
if ( start_time[packet_id] == 0 ) start_time[packet_id] = time;
# only useful for small unicast where packet_id doesn't wrap.
# checking receive means avoiding recording drops
if ( action != "d" ) {
if ( action == "r" ) {
# could test for receiving node_2_address or flow_id here.
end_time[packet_id] = time;
}
} else {
end_time[packet_id] = -1;
}
#============= CALCULATE PACKET DELIVERY FRACTION============================
# $3 = source node id , here I have 4 source nodes and start my analysis after
490 seconds of simulation (when traffic started)
if (( $1 == "s") && ( $7 == "cbr" ) && ( $4
=="AGT" ) && ( ( $3== "_5_" ) || ( $3==
"_6_" ) || ($3=="_7_") || ($3=="_8_")
)&& ($2 > 490.00 ) ) {
sends++;}
# $4 = destination node in wired segment of network. if you simulate ad hoc only
scenario the change $4 to $3 and %5 to $7.
if ( ( $1 == "r") && ( $5 == "cbr" ) && (
$4 == "0" ) && ($2 > 490.00 ) ) {
recvs++;}
pdf = (recvs/sends)*100;
#==================== ADVERTISEMENTS ==================
if ( (($1=="f") || ($1=="s") ) && ($4 ==
"RTR") && ($7 =="AODV" ) && ($2 > 490.00
) ) {
AODV_Adv++;
}
#============= DROPPED AODV PACKETS ========================================
if ( ($1 == "D") && ($7=="cbr") && ($2 >
490.00 ) ){
droppedAODVBytes=droppedAODVBytes+$8 ;
droppedAODVPackets=droppedAODVPackets+1;
}
}
END {
for ( packet_id = 0; packet_id <= highest_packet_id; packet_id++ ) {
start = start_time[packet_id];
end = end_time[packet_id];
packet_duration = end - start;
if ( start < end ) sum= packet_duration+sum;
}
delay=sum/recvs;
printf(" Average e-e delay: \t %f \n", delay);
printf(" normalised routing load \t %f \n ", AODV_Adv/recvs);
printf("No. of packets sent = %d \n", sends);
printf(" No. of packets received = %d \n", recvs);
printf(" Pdf (100%) = %f \n \n", pdf);
printf("No. of dropped data (packets) = %d \n ",droppedAODVPackets);
printf("No. of dropped data (bytes) = %d \n \n ",droppedAODVBytes);
printf("No. of aodv advertisements = %f \n ",AODV_Adv);
}
------------------------------------------------------------------------------------
Question 15:
How to disable the routing when you wanna measure MAC layer performance?
Answer:
you can use DumbAgent as below:
$ns_ node-config \
-adhocRouting DumbAgent\
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF \
-channel [new $val(chan)]
---------------------------------------------------------------------------------------
Question 16:
How to use parameters in command line?
Answer:
For example, if you try to pass the number of nodes as a parameter to
your script such as my_script.tcl 10
- use the following in your tcl file
set num_nodes [lindex $argv 0]
- then use the num_nodes variable wherever you wanna
--------------------------------------------------------------------------------------
Question 17:
How to debug by printf?
Answer:
method 1: printf("DEBUG TEST TEST\n"); don't use \r
and you may put a fflush(NULL); statement after prinf, then the result will
get printed immediately.
method 2:
char out[100];
Tcl& tcl = Tcl::instance();
sprintf(out, "puts \"DEBUG TEST TEST\"");
tcl.eval(out);
-------------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -