转载 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





(一). NS常用基本网站   1. Maillist个人觉得是寻求问题答案最好的地方。   http://mailman.isi.edu/pipermail/ns-users/   2. 柯老...
  • sxsj333
  • sxsj333
  • 2014年04月03日 14:43
  • 8055


出处:http://blog.chinaunix.net/uid-2559095-id-2140173.html http://www.isi.edu/nsnam/ns/ http:/...
  • wuhenyouyuyouyu
  • wuhenyouyuyouyu
  • 2016年03月08日 09:32
  • 2032


出处:http://blog.csdn.net/leixiaohua1020/article/details/12233331 NS2(Network Simulator 2) 是一...
  • wuhenyouyuyouyu
  • wuhenyouyuyouyu
  • 2016年03月07日 14:24
  • 1539

Windows 7 64位系统下安装Cy+NS2经验(成功安装)

Windows 7 64位系统下安装Cy+NS2经验(成功安装) 最近在研究NS2,不想装Linux,太烦了,所以准备在windows下用cygwin安装。 前提条件: 1.系统采用win7...
  • Gavinma666
  • Gavinma666
  • 2017年01月16日 10:48
  • 1174


ns2模拟仿真的一般过程及要点   在这里简单介绍ns2模拟仿真中的一般过程及要点 1)添加ns2的新组件,TclCL机制的实现及新组件的C++实现 最为关键的一步,该步将研究...
  • u010533400
  • u010533400
  • 2016年11月23日 15:21
  • 823


soap(简单对象访问协议),它是在http基础之上传递xml格式数据的协议。soap协议分为两个版本,soap1.1和soap1.2。 在学习webservice时我们有一个必备工具叫做tcpmon...
  • u012702547
  • u012702547
  • 2015年05月04日 16:39
  • 6497

柯志亨老师-- NS2 教學手冊

感谢柯志亨老师! NS2 教學手冊 ( NS2 Learning Guide) [快速連結區] My works  中文影音教學區  Q&A for my works  My ...
  • hzw05103020
  • hzw05103020
  • 2016年04月24日 15:29
  • 4147


  • u010245483
  • u010245483
  • 2014年11月30日 12:14
  • 2163


1、首先修改ns-2.34目录中的Makefile文件,开启调试模式,便于gdb调试 将 CC = gcc CPP = g++ 改为 CC = gcc -g CPP = g++ -g 2、打开Ecli...
  • bill_chuang
  • bill_chuang
  • 2014年01月15日 17:18
  • 2225

Ns2 Tcl语法总结

NS学习语法知识点; 1,变量代替 set  a  100;在使用变量之前,不需要事先声明,因为解释器会在首次使用变量的时候创建它,使用变量时要在变量前加$符号。 2,命令替代 set len [...
  • everysmile
  • everysmile
  • 2013年07月16日 23:30
  • 1719