NS2网络模拟(7)-homework03.tcl
1: #NS2_有线部分\homework03.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:
32: #Create two nodes
33: set NODE_ShenZhen [$ns node]
34: $NODE_ShenZhen color red
35: $NODE_ShenZhen shape circle
36: $NODE_ShenZhen label "ShenZhen"
37: $NODE_ShenZhen label-color red
38: $NODE_ShenZhen label-at up
39:
40: set NODE_ShangHai [$ns node]
41: $NODE_ShangHai color blue
42: $NODE_ShangHai shape circle
43: $NODE_ShangHai label "ShangHai"
44: $NODE_ShangHai label-color blue
45: $NODE_ShangHai label-at down
46:
47:
48: #Create a duplex link between the nodes
49: $ns duplex-link $NODE_ShenZhen $NODE_ShangHai 1Mb 100ms DropTail
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: ##TCP Traffic from NODE_ShangHai to NODE_ShenZhen
56: #Create a TCP agent and attach it to node NODE_ShangHai
57: set Agent_Sender_TCP [new Agent/TCP]
58: $Agent_Sender_TCP set class_ 2
59: $Agent_Sender_TCP set fid_ 1
60: $Agent_Sender_TCP set window_ 20
61: $ns attach-agent $NODE_ShangHai $Agent_Sender_TCP
62: # Create a FTP source and attach it to Agent_Sender_TCP
63: set APP_FTP [new Application/FTP]
64: $APP_FTP attach-agent $Agent_Sender_TCP
65: $APP_FTP set type_ FTP
66: #Create a TCPSink agent and attach it to node NODE_ShenZhen
67: set Agent_Receiver_TCPSink [new Agent/TCPSink]
68: $ns attach-agent $NODE_ShenZhen $Agent_Receiver_TCPSink
69: $ns connect $Agent_Sender_TCP $Agent_Receiver_TCPSink
70:
71: ##UDP Traffic from NODE_ShenZhen to NODE_ShangHai
72: #Create a UDP agent and attach it to node NODE_ShenZhen
73: set Agent_Sender_UDP [new Agent/UDP]
74: $Agent_Sender_UDP set agent_addr_ 1000
75: $Agent_Sender_UDP set agent_port_ 100
76: $Agent_Sender_UDP set fid_ 2
77: $ns attach-agent $NODE_ShenZhen $Agent_Sender_UDP
78: ## Create a Exponential traffic source and attach it to Agent_Sender_UDP
79: #set APP_EXP [new Application/Traffic/Exponential]
80: #$APP_EXP set packetSize_ 400
81: #$APP_EXP set burst_time_ 400ms
82: #$APP_EXP set idle_time_ 100ms
83: #$APP_EXP set rate_ 150kb
84: #$APP_EXP attach-agent $Agent_Sender_UDP
85: #set APP_PARETO [new Application/Traffic/Pareto]
86: #$APP_PARETO set packetSize_ 400
87: #$APP_PARETO set burst_time_ 400ms
88: #$APP_PARETO set idle_time_ 100ms
89: #$APP_PARETO set rate_ 200kb
90: #$APP_PARETO set shape_ 1.2
91: #$APP_PARETO attach-agent $Agent_Sender_UDP
92: set APP_CBR [new Application/Traffic/CBR]
93: $APP_CBR set packetSize_ 1000
94: $APP_CBR set burst_time_ 500ms
95: $APP_CBR set idle_time_ 100ms
96: $APP_CBR set rate_ 1050kb
97: $APP_CBR set random_ On
98: $APP_CBR attach-agent $Agent_Sender_UDP
99: #Create a Null agent (a traffic sink) and attach it to node NODE_ShangHai
100: set Agent_Receiver_NULL [new Agent/Null]
101: $Agent_Receiver_NULL set dst_addr_ 2000
102: $Agent_Receiver_NULL set dst_port_ 200
103: $ns attach-agent $NODE_ShangHai $Agent_Receiver_NULL
104:
105: #Connect the traffic source with the traffic sink
106: $ns connect $Agent_Sender_UDP $Agent_Receiver_NULL
107:
108: #Schedule events for the CBR agent
109: $ns at 0.2 "$APP_FTP start"
110: $ns at 0.5 "$APP_CBR start"
111: $ns at 7.5 "$APP_CBR stop"
112: $ns at 9.7 "$APP_FTP stop"
113:
114:
115: #Call the finish procedure after 5 seconds of simulation time
116: $ns at 10.0 "finish"
117:
118: #Run the simulation
119: $ns run
120:
NS2网络模拟(7)-homework03.tcl的更多相关文章
- NS2网络模拟(6)-homework02.tcl
1: #NS2_有线部分\homework02.tcl 2: 3: #Create a simulator object 4: set ns [new Simulator] 5: 6: #Define ...
- NS2网络模拟(5)-homework01.tcl
1: #NS2_有线部分\homework01.tcl 2: 3: #创建两个结点,深圳到北京的TCP连接,图形将数据显示出来,计算吞吐率,画图分析 4: #tcp上层用ftp 5: #udp上层用c ...
- NS2网络模拟(4)-吞吐率图
1: #NS2_有线部分\ForGnuplot.plot 2: 3: #gnuplot> 4: #set xtics 0, 1, 10 5: set grid 6: set xrange [0: ...
- NS2网络模拟(3)-吞吐率
1: #NS2_有线部分\Throughput.awk 2: 3: BEGIN { 4: #Initialize the variable 5: init = 0; 6: i = 0; 7: } 8: ...
- NS2网络模拟(2)-丢包率
1: #NS2_有线部分\LossRate.awk 2: 3: BEGIN { 4: #Initialize the variable 5: Lost = 0; #the Sum of Lost pa ...
- NS2网络模拟(1)-延迟
1: #NS2_有线部分\EndDelay.awk 2: 3: BEGIN { 4: #Initialize the variable 5: MaxID = 0; 6: i = 0; 7: } 8: ...
- ns2的第一个tcl脚本
set ns [new Simulator] set tracef [open example1.tr w]$ns trace-all $tracefset namtf [open example1. ...
- 【NS2】WiMAX_NS2说明文档(转载)
关于目前NS2中WiMAX模块的说明 (1)美国NIST(National Institute of Standards and Technology)版, 可以从NIST主页获得,2007.04 r ...
- 【NS2】ubuntu安装和同时使用不同版本的ns2(转载)
有时候我们可能会遇到要同时安装两个ns版本的问题,比如我研究wimax/802.16,因为协议太复杂,用的是长庚大学和nist的wimax补丁.长庚大学的wimax补丁是在ns2.29下开发的,nis ...
随机推荐
- IQueryFielter接口
IQueryFilter基于属性查询过滤数据.需要定义一个where子句.可以指定要返回值的字段列表.如果没有指定列,将返回所有值.当需要根据属性值和属性的关系过滤数据时,使用该接口. 成员 AddF ...
- Qt 使用qDebug() 打印Qlist 容器数据(将QDebug()定义成某个类的友元函数)
当QList<T>容器中的数据用qDebug() 打印时 ,假如 T 是内置类型(int float ...)与 打印一个字符串使用完全一样,假如T 是一个CustomerClass 那 ...
- spring getbean 方法分析(很实用!)
十年阿里,就只剩下这套Java开发体系了 >>> 在最近的项目中,有个地方我们不得不实用getBean的方法,自己从Spring context中获取bean进行数据库操作. 方 ...
- Lucene学习总结之五:Lucene段合并(merge)过程分析 2014-06-25 14:20 537人阅读 评论(0) 收藏
一.段合并过程总论 IndexWriter中与段合并有关的成员变量有: HashSet<SegmentInfo> mergingSegments = new HashSet<Segm ...
- Android 为开发者准备的最佳 Android 函数库(2016 年版)
本文是翻译自 CloudRAIL 的官方博客(https://cloudrail.com/best-android-libraries-for-developers/),本文中分享的 Android ...
- php thinkphp uploadify
模板文件: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w ...
- oracle员工表和部门表基本操作
emp 员工表(empno 员工号/ename 员工姓名/job 工作/mgr 上级编号/hiredate 受雇日期/sal 薪金/comm 佣金/deptno 部门编号) dept 部门表(dept ...
- Stacks of Flapjacks
Stacks of Flapjacks Background Stacks and Queues are often considered the bread and butter of data s ...
- linux上电自启动应用程序具体解释
每当我学习一个新的东西得时候都是会 遇到一些错误.可是我会很努力的去解决它,今天这个自启动应用程序花了我两个小时的时间才攻克了.所以说遇到问题的时候要去思考.分析.以下我就来谈谈linux上电自启动应 ...
- PHP移动互联网开发笔记(4)——自定义函数及数组
一.自定义函数 自定义函数就是我们自己定义的函数,在PHP中自定义函数格式如下: function funname(arg1, arg2, arg3......){ //TODO return val ...