Packet Delivery Ratio (PDR)=[Packets Received] / [Packets Sent]
通过得知发送或者接收包的数量进行统计。本例用下面的脚本统计发送包数。
grep AGT cwsim.tr |grep ^s |grep cbr|wc -l
接收包数用如下脚步统计。
grep AGT cwsim.tr |grep ^r |grep cbr|wc -l
接收的包数应该等于或者少于发送数。
Throughput=512 x 8 x [Packets Received] / 25 bits/second 、
本例代码如下
# Copyright (c) 1997 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by the Computer Systems # Engineering Group at Lawrence Berkeley Laboratory. # 4. Neither the name of the University nor of the Laboratory may be used # to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. #
# Script to Study Impact of CW size #V.B., 2005
# ====================================================================== # 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) 25 ;#default number of mobilenodes set val(rp) AODV ;# routing protocol set val(sc)"./scenario";# scenario file set val(x) 150.0 ; set val(y) 150.0 ; set val(simtime) 25.0 ; #sim time set val(rlen) 5 ; # ====================================================================== # Main Program # ======================================================================
proc getopt {argc argv}{ global val lappend optlist rlen
for{set i 0}{$i < $argc}{incr i}{ set arg [lindex $argv $i] if{[string range $arg 0 0]!="-"}continue set name [string range $arg 1 end] set val($name)[lindex $argv [expr $i+1]] }
set val(nn)[expr $val(rlen)* $val(rlen)]
}
getopt $argc $argv # # Initialize Global Variables # set ns_ [new Simulator] set tracefd [open cwsim.tr w] $ns_ trace-all $tracefd
set namtrace [open cwsim.nam w];#for nam tracing $ns_ namtrace-all-wireless $namtrace $val(x) $val(y) $ns_ use-newtrace
# set up topography object set topo [new Topography]
From liuchng_xt:NS lab的网站地址 http://www.crhc.illinois.edu/wireless/assignments/simulations/转载自:http://blog.chinaunix.net/uid-232277-id-2485895.html介绍本实验目标是调查冲突窗口大小对IEEE802.11性能的影响。该标准要求