2024年5月5日发(作者:)
使用徐雷鸣书第七章的测试tcl代码得到的trace文件,
1、 RTR路由层收到之后添加了一个20字节的IP头,所以包长度从512变为532
2、 第6、7行,节点0又收到自己发出的包,所以,丢弃。中使用ch->num_forwards()
== 0来判断经过了几次转发,但是没有看到这个数递增啊?
使用shell批量化处理,设置场景、流量、运行ns、awk处理实验数据
#!/bin/bash
##############################################
# Shell grammar:
# test expr is logic expression
# lt means lower than
##############################################
i=1
while (test $i -lt 2)
do
scn/setdest -v 1 -n 50 -p 0 -M 5 -t 100 -x 1000 -y 1000 > scn/scene-50n-0p-5s-100t-1000-1000
ns scn/ -type cbr -nn 50 -seed $i -mc 30 -rate 1.0 > scn/cbr-50n-30c-1p
ns
awk -f
let i=i+1
done
tcl代码为徐雷鸣书中代码
#Agent/UDP set packetSize_ 6000
# ======================================================================
# Define options
# ======================================================================
set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_11
set val(ifq) Queue/DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(x) 1200 ;# X dimension of the topography
set val(y) 1200 ;# Y dimension of the topography
set val(ifqlen) 50 ;# max packet in ifq
set val(seed) 0.0
set val(rp) MFlood
set val(nn) 50 ;# how many nodes are simulated
set val(cp) "scn/cbr-50n-30c-1p"
set val(sc) "scn/scene-50n-0p-5s-100t-1000-1000"
set val(stop) 100
# ======================================================================
# Main Program
# ======================================================================
#ns-random 0
# Initialize Global Variables
set ns_ [new Simulator]
set tracefd [open w]
$ns_ trace-all $tracefd
# set up topography
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
set namtrace [open w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
#
# Create God
#
set god_ [create-god $val(nn)]
# Create the specified number of mobilenodes [$val(nn)] and "attach" them
# to the channel.
# configure node
set channel [new Channel/WirelessChannel]
发布评论