NS2 简单无线网络模拟
2018-02-05 17:56
495 查看
# Simulator Instance Creation set ns [new Simulator] #Fixing the co-ordinate of simutaion area set val(x) 500 set val(y) 500 # Define options set val(chan) Channel/WirelessChannel ;# channel type set val(prop) Propagation/TwoRayGround ;# radio-propagation model set val(netif) Phy/WirelessPhy ;# network interface type set val(mac) Mac/802_11 ;# MAC type set val(ifq) Queue/DropTail/PriQueue ;# interface queue type set val(ll) LL ;# link layer type set val(ant) Antenna/OmniAntenna ;# antenna model set val(ifqlen) 50 ;# max packet in ifq set val(nn) 2 ;# number of mobilenodes set val(rp) AODV ;# routing protocol set val(x) 500 ;# X dimension of topography set val(y) 400 ;# Y dimension of topography set val(stop) 10.0 ;# time of simulation end # set up topography object set topo [new Topography] $topo load_flatgrid $val(x) $val(y) #Nam File Creation nam – network animator set namfile [open sample1.nam w] #Tracing all the events and cofiguration $ns namtrace-all-wireless $namfile $val(x) $val(y) #Trace File creation set tracefile [open sample1.tr w] #Tracing all the events and cofiguration $ns trace-all $tracefile # general operational descriptor- storing the hop details in the network create-god $val(nn) # configure the nodes $ns node-config -adhocRouting $val(rp) \ -llType $val(ll) \ -macType $val(mac) \ -ifqType $val(ifq) \ -ifqLen $val(ifqlen) \ -antType $val(ant) \ -propType $val(prop) \ -phyType $val(netif) \ -channelType $val(chan) \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF \ -movementTrace ON # Node Creation set node1 [$ns node] # Initial color of the node $node1 color black #Location fixing for a single node $node1 set X_ 200 $node1 set Y_ 100 $node1 set Z_ 0 set node2 [$ns node] $node2 color black $node2 set X_ 200 $node2 set Y_ 300 $node2 set Z_ 0 # Label and coloring $ns at 0.1 "$node1 color blue" $ns at 0.1 "$node1 label Node1" $ns at 0.1 "$node2 label Node2" #Size of the node $ns initial_node_pos $node1 30 $ns initial_node_pos $node2 30 # ending nam and the simulation $ns at $val(stop) "$ns nam-end-wireless $val(stop)" $ns at $val(stop) "stop" #Stopping the scheduler $ns at 10.01 "puts \"end simulation\" ; $ns halt" #$ns at 10.01 "$ns halt" proc stop {} { global namfile tracefile ns $ns flush-trace close $namfile close $tracefile #executing nam file exec nam sample1.nam & } #Starting scheduler $ns run
相关文章推荐
- NS2中无线网络模拟之三(AODV路由分析)
- NS2中无线网络模拟之三(AODV路由分析4)
- 无线简单网络模型模拟
- NS2中无线网络模拟之一
- NS2杂项(ns2相关的其他工具、NS2无线模拟相关的网站、计算机网络系列学术讲座、NS2 GDB调试、NS2跨层设计的思想、VANET路由--蚂蚁的一点启发、NS2一些有用的网站)
- ns2无线网络模拟出现的错误和调试-转自csdn响亮空间
- NS2中无线网络模拟之三(AODV路由分析2)
- NS2中无线网络模拟之三(AODV路由分析5)
- NS2中无线网络模拟之三(AODV路由分析3)
- 利用NS2进行无线网络模拟
- NS2中无线网络模拟之二
- 简单模拟网络蜘蛛爬出邮箱地址
- NS2网络模拟(3)-吞吐率
- java网络编程——socket简单模拟http服务器
- NS2网络模拟(3)-吞吐率
- 运行无线网络模拟出现的错误与解决方法
- NS2网络模拟(7)-homework03.tcl
- HTTP网络请求原理 (三) 简单模拟HTTP服务器
- NS2 进行无线模拟时 调用的类和函数
- NS2网络模拟(2)-丢包率