转载 2006年06月05日 17:10:00

1. All of the simulator functions can be found in the file

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


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];
 $throughput = $sum / $granularity;
 print STDOUT "$x[1] $throughtput/n";
 $clock = $clock + $granularity;
 $sum = 0;

    print STDOUT "$x[1] $throughput/n";

close DATA;

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

"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






  • 2013-12-30 15:20
  • 484KB
  • 下载


  • 2012-11-09 12:44
  • 21KB
  • 下载

NS-3学习笔记 2

今天从《ns-3 tutorial》第4章开始。4. 基本概念在看或写ns-3程序前,需要理解掌握一些概念和抽象问题。 It’s be recommended taking the time to ...

NS2 学习笔记

  • 2013-10-13 16:35
  • 2.97MB
  • 下载


  • 2015-02-03 15:52
  • 2.97MB
  • 下载

NS2 学习笔记—— AODV协议

在NS2中,AODV路由协议主要包括以下几个组件: 1、协议实体 2、路由表 3、定时器 (1)广播定时器 (2)周期Hello报文广播定时器 (3)用于邻居管理的定时器 (4)用于路由...
  • leo115
  • leo115
  • 2012-07-30 08:50
  • 5280


  • 2011-11-14 20:35
  • 2.97MB
  • 下载

NS2学习笔记 简介

  • 2010-04-14 08:19
  • 2.97MB
  • 下载


NS2无线模拟课程学习笔记12007-10-27 12:52http://www.crhc.uiuc.edu/wireless/assignments/simulations/是http://www....


  • 2014-12-28 21:59
  • 522KB
  • 下载