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

    1.hql与sql的区别 sql 面向数据库表查询 hql 面向对象查询 hql : from 后面跟的 类名+类对象 where 后 用 对象的属性做条件 sql: from 后面跟的是表名    ...

  2. 从0開始学习 GitHub 系列之「07.GitHub 常见的几种操作」

    之前写了一个 GitHub 系列,反响非常不错,突然发现居然还落下点东西没写,前段时间 GitHub 也改版了,借此机会补充下. 我们都说开源社区最大的魅力是人人多能够參与进去,发挥众人的力量,让一个 ...

  3. [RxJS] Split an RxJS observable conditionally with windowToggle

    There are variants of the window operator that allow you to split RxJS observables in different ways ...

  4. Mysql 安装(Using Generic Binaries)

    本次 Mysql 为Community 5.6.21 版本号.安装方式为通用Linux安装方式.即大多数Linux平台都能够採用该方式进行安装. 一.安装步骤 1.安装环境 1)Centos 7.0. ...

  5. css3-2 CSS3选择器和文本字体样式

    css3-2   CSS3选择器和文本字体样式 一.总结 一句话总结:是要记下来的,记下来可以省很多事. 1.css的基本选择器中的:first-letter和:first-line是什么意思? :f ...

  6. android获取和展示音乐的频谱

    做了个音乐播放器 就一直想做个加一个音乐频谱的展示界面 觉的这是一个好玩的东西,可以将耳边动听的声音形象化,仿佛眼前可以看到声音一样. 但是我在文档的开发者指南里没有讲任何有关音乐频谱的东西,最后还是 ...

  7. vi/vim基本使用命令

    vi/vim基本使用命令 一.总结 一句话总结:1.记住三种模式:命令行模式.插入模式.底行模式:2.记住两个按键功能:i和esc 二.vi/vim基本使用命令 vi/vim 基本使用方法本文介绍了v ...

  8. [SVG] Add an SVG as a Background Image

    Learn how to set an SVG as the background image of an element. Background images can be resized by c ...

  9. Expression Blend 的点滴(2)--利用可视化状态创建神奇翻转动画

    原文:Expression Blend 的点滴(2)--利用可视化状态创建神奇翻转动画 首先,来看下实现后的效果: 关于VisulaState VisualState 指定控件处于特定状态时的外观.例 ...

  10. Expression Blend 的点滴(1)--ListBox华丽大变身

    原文:Expression Blend 的点滴(1)--ListBox华丽大变身 最近,在园子里有不少朋友写了关于Blend的优秀并且实用的文章,在此,我先代表silverlight的爱好者感谢他们的 ...