1: #NS2_有线部分\homework02.tcl
  2:
  3: #Create a simulator object
  4: set ns [new Simulator]
  5:
  6: #Define different colors for data flows
  7: $ns color 1 Blue
  8: $ns color 2 Red
  9:
 10: #Open the nam trace file
 11: set nf [open szsh.nam w]
 12: $ns namtrace-all $nf
 13:
 14: #Open the trace record file
 15: set nd [open szsh.tr w]
 16: $ns trace-all $nd
 17:
 18: #Define a 'finish' procedure
 19: proc finish {} {
 20:     global ns nf nd
 21:     $ns flush-trace
 22:     #Close the trace file
 23:     close $nf
 24:     #Close the record file
 25:     close $nd
 26:     #Execute nam on the trace file
 27:     exec nam szsh.nam &
 28:     exit 0
 29: }
 30:
 31: #Create two nodes
 32: set NODE_ShenZhen [$ns node]
 33: $NODE_ShenZhen color red
 34: $NODE_ShenZhen shape circle
 35: $NODE_ShenZhen label "ShenZhen"
 36: $NODE_ShenZhen label-color red
 37: $NODE_ShenZhen label-at up
 38:
 39: set NODE_ShangHai [$ns node]
 40: $NODE_ShangHai color blue
 41: $NODE_ShangHai shape circle
 42: $NODE_ShangHai label "ShangHai"
 43: $NODE_ShangHai label-color blue
 44: $NODE_ShangHai label-at down
 45:
 46:
 47: #Create a duplex link between the nodes
 48: $ns duplex-link $NODE_ShenZhen $NODE_ShangHai 1Mb 100ms DropTail
 49:
 50: #Monitor the queue for the link between node 2 and node 3
 51: $ns duplex-link-op $NODE_ShenZhen $NODE_ShangHai queuePos 0.5
 52: $ns duplex-link-op $NODE_ShenZhen $NODE_ShangHai color green
 53: $ns duplex-link-op $NODE_ShenZhen $NODE_ShangHai orient right
 54:
 55: #Create a UDP agent and attach it to node NODE_ShenZhen
 56: set Agent_Sender [new Agent/UDP]
 57: $Agent_Sender set agent_addr_   1000
 58: $Agent_Sender set agent_port_   100
 59: $ns attach-agent $NODE_ShenZhen $Agent_Sender
 60:
 61: ## Create a Exponential traffic source and attach it to Agent_Sender
 62: #set APP_EXP [new Application/Traffic/Exponential]
 63: #$APP_EXP set packetSize_    400
 64: #$APP_EXP set burst_time_    400ms
 65: #$APP_EXP set idle_time_     100ms
 66: #$APP_EXP set rate_          150kb
 67: #$APP_EXP attach-agent $Agent_Sender
 68:
 69: set APP_PARETO [new Application/Traffic/Pareto]
 70: $APP_PARETO set packetSize_     400
 71: $APP_PARETO set burst_time_     400ms
 72: $APP_PARETO set idle_time_      100ms
 73: $APP_PARETO set rate_           100kb
 74: $APP_PARETO set shape_          1.2
 75: $APP_PARETO attach-agent $Agent_Sender
 76:
 77: #Create a Null agent (a traffic sink) and attach it to node NODE_ShangHai
 78: set Agent_Receiver [new Agent/Null]
 79: $Agent_Receiver set dst_addr_   2000
 80: $Agent_Receiver set dst_port_   200
 81: $ns attach-agent $NODE_ShangHai $Agent_Receiver
 82:
 83: #Connect the traffic source with the traffic sink
 84: $ns connect $Agent_Sender $Agent_Receiver
 85:
 86: #Schedule events for the CBR agent
 87: $ns at 0.2 "$APP_PARETO start"
 88: $ns at 0.8 "$APP_PARETO stop"
 89:
 90: #Call the finish procedure after 5 seconds of simulation time
 91: $ns at 1.0 "finish"
 92:
 93: #Run the simulation
 94: $ns run
 95: 

NS2网络模拟(6)-homework02.tcl的更多相关文章

  1. NS2网络模拟(7)-homework03.tcl

    1: #NS2_有线部分\homework03.tcl 2: 3: #Create a simulator object 4: set ns [new Simulator] 5: 6: #Define ...

  2. NS2网络模拟(5)-homework01.tcl

    1: #NS2_有线部分\homework01.tcl 2: 3: #创建两个结点,深圳到北京的TCP连接,图形将数据显示出来,计算吞吐率,画图分析 4: #tcp上层用ftp 5: #udp上层用c ...

  3. NS2网络模拟(4)-吞吐率图

    1: #NS2_有线部分\ForGnuplot.plot 2: 3: #gnuplot> 4: #set xtics 0, 1, 10 5: set grid 6: set xrange [0: ...

  4. NS2网络模拟(3)-吞吐率

    1: #NS2_有线部分\Throughput.awk 2: 3: BEGIN { 4: #Initialize the variable 5: init = 0; 6: i = 0; 7: } 8: ...

  5. NS2网络模拟(2)-丢包率

    1: #NS2_有线部分\LossRate.awk 2: 3: BEGIN { 4: #Initialize the variable 5: Lost = 0; #the Sum of Lost pa ...

  6. NS2网络模拟(1)-延迟

    1: #NS2_有线部分\EndDelay.awk 2: 3: BEGIN { 4: #Initialize the variable 5: MaxID = 0; 6: i = 0; 7: } 8: ...

  7. ns2的第一个tcl脚本

    set ns [new Simulator] set tracef [open example1.tr w]$ns trace-all $tracefset namtf [open example1. ...

  8. 【NS2】WiMAX_NS2说明文档(转载)

    关于目前NS2中WiMAX模块的说明 (1)美国NIST(National Institute of Standards and Technology)版, 可以从NIST主页获得,2007.04 r ...

  9. 【NS2】ubuntu安装和同时使用不同版本的ns2(转载)

    有时候我们可能会遇到要同时安装两个ns版本的问题,比如我研究wimax/802.16,因为协议太复杂,用的是长庚大学和nist的wimax补丁.长庚大学的wimax补丁是在ns2.29下开发的,nis ...

随机推荐

  1. 【48.47%】【POJ 2524】Ubiquitous Religions

    Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 32364 Accepted: 15685 Description There a ...

  2. jquery画图插件jPainter

    jquery画图插件jPainter 一.总结 一句话总结:四年前的项目,四年无更新,不好用. 二.基于HTML5 Canvas和jQuery 的画图工具的实现 简介 HTML5 提供了强大的Canv ...

  3. 嵌入式平台下的ldd

    x86平台有ldd可以很方便的查看对库的依赖关系,但在嵌入式linux环境中没有这个命令,替而代之是 CC=$(CROSS_COMPILE)gcc LDD=$(CROSS_COMPILE)readel ...

  4. Windows Phone 8.1 应用间共享

    (1)LaunchUriAsync 将简单数据包含在 Uri 中,然后发送到目标应用: await Launcher.LaunchUriAsync(new Uri("target:messa ...

  5. CSS自己主动换行、强制不换行、强制断行、超出显示省略号

    P标签是默认是自己主动换行的,因此设置好宽度之后,可以较好的实现效果,可是近期的项目中发现,使用ajax载入数据之后.p标签内的内容没有换行,导致布局错乱,于是尝试着使用换行样式,尽管攻克了问题.可是 ...

  6. SetProcessWorkingSetSize() 方法使内存降低了很多(把内存放到交换区,其实会降低性能)——打开后长时间不使用软件,会有很长时间的加载过程,原来是这个!

    在项目中对程序性能优化时,发现用SetProcessWorkingSetSize() 方法使内存降低了很多,于是查阅了相关的资料如下: 我的程序为什么能够将占用的内存移至虚拟内存呢? 其实,你也可以, ...

  7. Linux删除非空目录

    Linux下如何删除非空目录   这个问题很basic,不过还是困扰了我一段时间.(这里主要讨论的是命令行模式下)我本来觉得应该使用命令 rmdir但是发现它无法删除非空的目录.后来发现了原来应该使用 ...

  8. [Angular] Export directive functionalities by using 'exportAs'

    Directive ables to change component behaives and lookings. Directive can also export some APIs which ...

  9. BZOJ 2096 Pilots - 单调队列STL(deque)

    传送门 分析: 单调队列:维护两个递增.递减的队列,每次都加入新元素并更新,如果最大值(递减队首)-最小值(递增队首) > k,那么将最左段更新为前面两者中较前的那一个,并弹掉.用deque可以 ...

  10. [Angular] Some performance tips

    The talk from here. 1. The lifecycle in Angular component: constructor vs ngOnInit: Constructor: onl ...