登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

我行我素

 
 
 

日志

 
 

Script of Enhanced Adaptive FEC for video over WLANs  

2007-09-13 22:41:15|  分类: 郁闷自己 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

Source from the website of Professor Ke:
http://140.116.72.80/~jhlin5/ns2/EAFEC/fec_simulation.htm

This Enhanced Adaptive FEC Mechanism is described in detail in the following two papers:

[1] Cheng-Han Lin, Chih-Heng Ke, Ce-Kuen Shieh, Naveen Chilamkurti, “An Enhanced Adaptive FEC Mechanism for Video Delivery over Wireless Networks”, International Conference on Networking and Services (ICNS'06), July 16-18, 2006, Silicon Valley, USA, IEEE Computer Society Press
[2] Chih-Heng Ke, Naveen Chilamkurti, Gaurav Dudeja, Ce-Kuen Shieh, “A New Adaptive FEC Algorithm for Wireless LAN Networks”,  The IASTED International Conference on Networks and Communication Systems, March 29-31, 2006, Chiang Mai, Thailand

 

If interested, go and get them in IEEE and ACTA Press.

 

 

I rewrite the script provided by Professor Ke, for my propose is to evaluate the video quality of 802.11g wireless lan. But after successful simulation, I find that there is much more for me to rewrite, especially the source codes of the extension to NS2. There is no time left, so finally I give up. Hope that after finishing my last paper, I will have time to go on this. The following is my TCL script, 18 wireless nodes and 19 wired nodes which can be changed easily.

 

=========================================================



proc getopt {argc argv} {
 global opt
        lappend optlist nn
        for {set i 0} {$i < $argc} {incr i} {
  set opt($i) [lindex $argv $i]
 }
}

getopt $argc $argv

set ns [new Simulator]
set packetSize    1028
set name v18
set num_wired_nodes  19
set num_mobile_nodes 18
set num_fec 17
set num_bs_nodes     1 ;# number of base stations
set num_nodes [expr $num_wired_nodes + $num_mobile_nodes + $num_bs_nodes]
set bs_id $num_wired_nodes

# Parameter for wireless nodes
set opt(chan)           Channel/WirelessChannel    ;# channel type
set opt(prop)           Propagation/TwoRayGround   ;# radio-propagation model
set opt(netif)          Phy/WirelessPhy            ;# network interface type
set opt(mac)            Mac/802_11                 ;# MAC type
set opt(ifq)            Queue/DropTail/myPriQueue    ;# interface queue type
set opt(ifq1)  Queue/DropTail/PriQueue
set opt(ifqlen)         50
set opt(ll)             LL                         ;# link layer type
set opt(ant)            Antenna/OmniAntenna        ;# antenna model
set opt(adhocRouting)   DSDV                     ;# routing protocol
set opt(x)  500  ;# X dimension of the topography
set opt(y)  500  ;# Y dimension of the topography

Mac/802_11 set dataRate_ 54Mb
Mac/802_11 set basicRate_ 6Mb

#set up for hierarchical routing
#(needed for routing over a basestation)
$ns node-config -addressType hierarchical
AddrParams set domain_num_ 2          ;# domain number
lappend cluster_num 1 1               ;# cluster number for each domain
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel $num_wired_nodes [expr $num_mobile_nodes + $num_bs_nodes] ;# number of nodes for each cluster            
AddrParams set nodes_num_ $eilastlevel

set ntr [open $name.tr w]
$ns trace-all $ntr

set chan [new $opt(chan)]
Phy/WirelessPhy set Rb_ 54*1e6
Phy/WirelessPhy set freq_ 2.4e+9


set topo [new Topography]
$topo load_flatgrid $opt(x) $opt(y)

# Create God
create-god [expr $num_mobile_nodes + $num_bs_nodes]

# creating wired nodes
for {set i 0} {$i < $num_wired_nodes} {incr i} {
 set W($i) [$ns node 0.0.$i]
    puts "wired node $i created"
}

# creating base station
$ns node-config -adhocRouting $opt(adhocRouting) \
                 -llType $opt(ll) \
                 -macType $opt(mac) \
                 -ifqType $opt(ifq) \
                 -ifqLen $opt(ifqlen) \
                 -antType $opt(ant) \
                 -propType $opt(prop)    \
                 -phyType $opt(netif) \
                 -channel $chan      \
                 -topoInstance $topo \
                 -wiredRouting ON \
                 -agentTrace OFF \
                 -routerTrace OFF \
                 -macTrace OFF    \
                 -movementTrace OFF

set BS(0) [$ns node 1.0.0]
$BS(0) random-motion 0
set bs_ifq [$BS(0) set ifq_(0)]
set bs_mac [$BS(0) set mac_(0)]
set bs_phy [$BS(0) set netif_(0)]
puts "Base-Station node $bs_id created"
#provide some co-ord (fixed) to base station node
$BS(0) set X_ 250.0
$BS(0) set Y_ 250.0
$BS(0) set Z_ 0.0

#$bs_ifq queuetype?
set queuechan [open $name.qlen.tr w]
$bs_ifq trace curq_
$bs_ifq attach $queuechan

$bs_ifq set threshold1 10
$bs_ifq set threshold2 40
$bs_ifq set maxfecpkts 4
$bs_ifq set staticfecpkts 0
$bs_ifq set qweight 0.1
$bs_ifq set fecpktsize 500
$bs_ifq set from_mac 1
$bs_ifq set threshold3  5
$bs_ifq set threshold4 15
$bs_ifq set sweight 0.1

 

set  rng  [new RNG]
$rng seed $opt(0)
set  rand1  [new RandomVariable/Uniform]
$rand1  use-rng $rng
$rand1  set  min_ -50.0
$rand1  set  max_ 50.0

# creating mobile nodes
$ns node-config -wiredRouting OFF
$ns node-config -ifqType $opt(ifq1)
for {set i 0} {$i < $num_mobile_nodes} {incr i} {
    set wl_node_($i) [$ns node 1.0.[expr $i + 1]] 
    $wl_node_($i) random-motion 0  ;# disable random motion
    puts "wireless node $i created ..."
    $wl_node_($i) base-station [AddrParams addr2id [$BS(0) node-addr]]
    set x [expr 250+[$rand1 value]]
    set y [expr 250+[$rand1 value]]
    $wl_node_($i) set X_ $x
    $wl_node_($i) set Y_ $y
    $wl_node_($i) set Z_ 0.0
    puts "X_:$x Y_:$y"
}

 

#$wl_phy set-error-level $pGG $pBB $pG $pB $loss_model
#loss model->(0:random uniform; 1:GE)
set wl_phy [$wl_node_($num_fec) set netif_(0)]
$wl_phy set-error-level $opt(1) $opt(2) $opt(3) $opt(4) $opt(5)


# linking of wired nodes to root node
for {set i 1} {$i < $num_wired_nodes} {incr i} {
    $ns duplex-link $W($i) $W(0) 100Mb 2ms DropTail
}


# linking of root to base-station node
$ns duplex-link $W(0) $BS(0) 100Mb 2ms DropTail
set q1 [[$ns link $W(0) $BS(0)] queue]
#$q1 set limit_ 100

for {set i 0} {$i < $num_mobile_nodes} {incr i} {

 set udp0($i) [new Agent/myUDP]
 $ns attach-agent $wl_node_($i) $udp0($i)
 $udp0($i) set packetSize_ $packetSize
 $udp0($i) set_filename $name.wlw.$i.sd
 set null0($i) [new Agent/myUdpSink3]
 $ns attach-agent $W([expr $i+1])  $null0($i)
 $ns connect $udp0($i) $null0($i)
 $null0($i) set_trace_filename $name.wlw.$i.rd
 
 set udp00($i) [new Agent/myUDP]
 $ns attach-agent $W([expr $i+1]) $udp00($i)
 $udp00($i) set packetSize_ $packetSize
 $udp00($i) set_filename $name.wwl.$i.sd
 set null00($i) [new Agent/myUdpSink2]
 $ns attach-agent $wl_node_($i) $null00($i)
 $ns connect $udp00($i) $null00($i)
 $null00($i) set_trace_filename $name.wwl.$i.rd
}


set original_file_name sourcevideo.txt
set trace_file_name $name.dat
set original_file_id [open $original_file_name r]
set trace_file_id [open $trace_file_name w]

set frame_count 0
set last_time 0
set pre_time 0

while {[eof $original_file_id] == 0} {

    gets $original_file_id current_line
    scan $current_line "%d%f%d%d" seq nexttime length type
    set time [expr ($nexttime-$pre_time)*1000000.0]

    puts $trace_file_id "$time $length $type"
    set pre_time $nexttime
    incr frame_count
}

close $original_file_id
close $trace_file_id
set end_sim_time $nexttime
puts "$end_sim_time"

for {set i 0} {$i < $num_mobile_nodes} {incr i} {

 set trace_file [new Tracefile]
 $trace_file filename $name.dat
 set video0($i) [new Application/Traffic/myTrace3]
 $video0($i) attach-agent $udp0($i)
 $video0($i) attach-tracefile $trace_file

 set trace_file [new Tracefile]
 $trace_file filename $name.dat
 set video00($i) [new Application/Traffic/myTrace3]
 $video00($i) attach-agent $udp00($i)
 $video00($i) attach-tracefile $trace_file


 $ns at 2.01 "$video0($i) start"
 $ns at 2.01 "$video00($i) start"
 $ns at 40.0 "$video0($i) stop"
 $ns at 40.0 "$video00($i) stop"

}

 

proc stop {} {
    global ns ntr bs_ifq
    $ns flush-trace
    close $ntr
    set fecno [$bs_ifq fecno?]
    puts "total fec no:$fecno"
}

 


$ns at [expr $end_sim_time + 5.1] "stop"
$ns at [expr $end_sim_time + 5.2] "puts \"NS EXITING...\" ; $ns halt"

$ns run

 

=================================================

 

  评论这张
 
阅读(317)| 评论(2)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018