关闭

NS2学习笔记

1818人阅读 评论(1) 收藏 举报

1. All of the simulator functions can be found in the file
ns2/ns-2.27/tcl/lib/ns-lib.tcl

2. We have serveral flows, we may wish to distinguish them so that we can

identity them with different colors in the visualisation part. This is done

by the command $tcp set fid_ 1 that assigns to the TCP connection a flow

identification of "1".

3. Instead of defining the rate, in the command $cbr set rate_ 0.01Mb, one

can define the time interval between transmission of packets using the

command $cbr set interval_ 0.005.

4. The scheduler is started when running ns, i.e. through the command $ns

run.

5. The ns manual page 328 talks about queuePos. It reads as "The queeuPos or

position of queue is defined as the angle of the queue line with horizontal",

it gives example $ns duplex-link-op queuePos 0.5 .
The queuePos is only needed for visualisation. It is not used during the

simulations, it is used by NAM to show the queue. For example you can also

try other values to see the difference in NAM. The value 0.5 is the angle in

pi radians with the horizontal line. In other words, 0.5 is (pi/2) or 90

degrees from the horizontal line. 1.0 would be pi radians or 180 degrees and

so on.

6. When we use tracing, ns inserts four objects in the link: EnqT, DeqT,

RecvT and DrpT. EnqT registers information concerning a packet that arrives

and is queued at the input queue of the link. If the packet overflows then

information concerning the dropped packet are handled by DrpT. DeqTregisters

information at the instant the packet is dequed. Finally, RecvT gives us

information about packets that have been received at the output of the link.

7. Tracing a subset of events
The first way to do so is by replacing the command $ns trace-all <filename>

by the command $ns trace-queue. For example, we can type $ns trace-queue $n2

$n3 $file1.

8. To use the awk script to generate file named "out.ns", we should type in

unix: awk -f awkfile.awk out.ns. And "awk -v var=? -f awkfile.awk out.ns" if

there are some variables in the file awkfile.awk.

9. Using grep
If we wish to obtain a file containing all lines of tr1.tr that begin with

the letter r, we should type: grep "^r" tr1.tr > tr2.tr. If we wish to make a

file of all the lines that begin with "s" and have later "tcp 1020" we should

type: grep "^s" simple.tr | grep "tcp 1020" > tr3.tr.

10. Using perl
#type: perl throughtput.pl <trace file> <required node> <granlarity> > file
#Computing the throughput.
$infile = $ARGV[0];
$tonode = $ARGV[1];
$granularity = $ARGV[2];

#we compute how many bytes were transmitted during time interval specified
#by granularity parameter in seconds
$sum = 0;
$clock = 0;

open (DATA, "<$infile")
|| die "Can't open $infile $!";

while (<DATA>) {
@x = split(' ');
#column 1 is time
if ($x[1] - $clock <= $granularity)
{
#checking if the event corresponds to a reception
if ($x[0] eq 'r')
{
#checking if the destination corresponds to 1st argument
if ($x[3] eq $tonode)
{
#checking if the packet type is TCP
if ($x[4] eq 'tcp')
{
 $sum = $sum + $x[5];
}
}
}
}
else
{
 $throughput = $sum / $granularity;
 print STDOUT "$x[1] $throughtput/n";
 $clock = $clock + $granularity;
 $sum = 0;
}
}

   $throughput=$sum/$granularity;
    print STDOUT "$x[1] $throughput/n";
    $clock=$clock+$granularity;
    $sum=0;

close DATA;
exit(0);

11. Extracting information within a tcl script
It is possible to integrate unix commands such as "grep" and "awk" already

into the tcl scripts, so as to start the processing of data while writing the

file. For example another way to limit the tracing files (or in general, to

process them online while they are being written) is to use linux commands

related to file processing within the tcl command that opens the required

file. For example, set file1 [open "| grep /"tcp/" > out.tr" w], this will

result in filtering the lines written to the file "out.tr" and leaving only

those that contain the word "tcp".

12. The trace file of wireless network is different from wire network.

13. Retransmitting after three dupplicated ACKS is called "fast retransmit".
Dynamic congestion window: its size can vary according to the network state.

The basic idea is as follows: When the window is small, it can grow rapidly,

and when it reaches large values it can only grow slowly. When congestion is

detected, the window size decrease drastically. This dynamic mechanism allows

to resolve congestion rapidly and yet use efficiently the network's

bandwidth.
"slow start": an exponential growth of the window.
"congestion avoidance": when cwnd reaches W:"slow start threshold", the

window W increases by [1/W] which each ACK that returns. After transmitting W

packets, W increases by 1. If we transmit the W packets at t, then at time

t+RTT we transmit W+1, and at t+2RTT we transmit W+2, etc... We see that the

window growth is linear.

14. compare of serveral variants of TCP: Tahoe, Reno and New-Reno
"Tahoe": whenever a loss is detected then the window reduces to the value of

1 and a slow-start phase begins.
"Reno or New-Reno": the window drops to 1 only if the loss is detected

through a time-out. When a loss is detected through repeated ACKs then the

congestion window drops by half. Slow start is not initiated and we remain in

the "congestion avoidance" phase.

15. Note that we used the delayed Ack version of TCP by using the command:

set sink [new Agent/TCPSink/DelAck] instead of simply set sink [new

Agent/TCPSink].

 

 


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:375854次
    • 积分:5322
    • 等级:
    • 排名:第5063名
    • 原创:102篇
    • 转载:76篇
    • 译文:8篇
    • 评论:249条
    博客专栏
    最新评论