NS2上如何利用无线网络组播H.264/SVC视频
2013-07-05 09:13
99 查看
本文转载网址:http://140.116.164.80/~smallko/ns2/svc_multicast.htm
[To Read before running this example]
Please refer to How to do H.264 SVC simulations? first. If you use this work, please add the following into your reference.
C. H. Ke, " myEvalSVC: an Integrated Simulation Framework for Evaluation of H.264/SVC Transmission ", KSII Transactions on
Internet and Information Systems, vol. 6, no. 1, pp. 378-393, Jan. 2012 (SCI)
[Preparation]
1. To fix two bugs.
a. Go to /ns-allinone-2.29/ns-2.29/myvideo
b. Open myevalsvc.cc
c. Modify the code.
void myEvalSVC::timeout()
{
…………………..
if(x_ > 0){
for(i=0 ; i<x_; i++)
agent_->sendmsg(max_);
}
if(y_!=0)
agent_->sendmsg(y_);
……………………
}
d. Modify the prepare_receivedtrace1.awk
2. To install a multicast routing protocol for wireless networks. In this example, we use PUMA. (I port it into ns-2.29)
a. Modify the packet.h that is under /ns-allineone-2.29/ns-2.29/common
…………………………………..
// HDLC packet
PT_HDLC,
// added by smallko
PT_PUMA,
// insert new packet types here
PT_NTYPE // This MUST be the LAST one
…………………………………..
// XCP
name_[PT_XCP]="xcp";
//added by smallko
name_[PT_PUMA]="PUMA";
name_[PT_NTYPE]= "undefined";
…………………………………..
b. Modify the ns-lib.tcl that is under /ns-allinone-2.29/ns-2.29/tcl/lib
…………………………………..
AODV {
set ragent [$self create-aodv-agent $node]
}
PUMA {
set ragent [$self create-puma-agent $node]
}
TORA {
Simulator set IMEPFlag_ ON
set ragent [$self create-tora-agent $node]
}
…………………………………..
Simulator instproc create-aodv-agent { node } {
Create AODV routing agent
ragent [new Agent/AODV [$node node-addr]]
self at 0.0 "$ragent start" ;# start BEACON/HELLO Messages
ode set ragent_ $ragent
turn $ragent
}
Simulator instproc create-puma-agent { node } {
# Create PUMA routing agent
set ragent [new Agent/PUMA [$node node-addr]]
$self at 0.0 "$ragent start"
$node set ragent_ $ragent
return $ragent
}
…………………………………..
c. Modify the Makefile.in that is under /ns-allinone-2.29/ns-2.29
…………………………………..
xcp/xcpq.o xcp/xcp.o xcp/xcp-end-sys.o \
measure/mtcpsink.o measure/mudp.o measure/mudpsink.o \
myvideo/myevalvid.o myvideo/myevalvid_sink.o myvideo/my_udp.o myvideo/myfifo.o \
myvideo/myevalsvc.o myvideo/myevalsvc_sink.o \
noah/noah.o mac/forwarder.o \
puma/puma.o \
queue/dtrr-queue.o \
…………………………………..
d. Download svc_multicast.rar and decompress it.
e. You will find a puma folder and copy this folder to /ns-allinone-2.29/ns-2.29
f. Recompile.
$cd /ns-allinone-2.29/ns-2.29
$./configure; make clean; make depend; make
g. Test the puma protocol
$cd /ns-allineone-2.29/ns-2.29/puma
$ns puma.tcl
If there is no error, it means that you have successfully install puma.
[Simulation]
In this simple example, there are two nodes. One node sends the H.264/SVC video to the other node using multicast. Very simple.
When you decompress svc_multicast.rar, you will see ns_svc_multicast. Copy this folder to cygwin environment. (to C:\cygwin\home\smallko )
Click the cygwin icon on the desktop
$cd ns_svc_multicast
$ns test_svc_multicast.tcl
$awk –f prepare_receivedtrace1.awk rd_n1_f0 > ns2received
$./prepare_receivedtrace2.exe ns2send ns2received temporal_originaltrace-frameno.txt > received.txt
When you decompress svc_multicast.rar, you will see post_processing. Copy this folder to cygwin_new environment. (to C:\cygwin_new\home\smallko )
Please also copy the received.txt to the post_processing folder (C:\cygwin_new\home\smallko\ post_processing)
Click the cygwin_new icon on the desktop
$nalufilter temporal_originaltrace-frameno.txt received.txt 15000 30 > filteredtrace.txt
$BitStreamExtractorStatic.exe temporal.264 temporal-filter.264 –et filteredtrace.txt
$H264AVCDecoderLibTestStatic.exe temporal-filter.264 temporal-filter.yuv
$framefilter filteredtrace.txt 152064 300 temporal-filter.yuv temporal-conceal.yuv
$PSNRStatic.exe 352 288 foreman_cif temporal-conceal.yuv
From the simulation result, you can see that the PSNR is not good as you expect. This is because that multicast sender does not need any acknowledgement from the receiver. Consequently, when the collision occurs, sender does not know that the collision happens
and then to retransmit.
In this example, n0 sends to n1. n1 forwards the received packets. Therefore, the packets sent by n0 and n1 may get collided.
So interested readers can think how to improve the protocol to make the performance better.
[To Read before running this example]
Please refer to How to do H.264 SVC simulations? first. If you use this work, please add the following into your reference.
C. H. Ke, " myEvalSVC: an Integrated Simulation Framework for Evaluation of H.264/SVC Transmission ", KSII Transactions on
Internet and Information Systems, vol. 6, no. 1, pp. 378-393, Jan. 2012 (SCI)
[Preparation]
1. To fix two bugs.
a. Go to /ns-allinone-2.29/ns-2.29/myvideo
b. Open myevalsvc.cc
c. Modify the code.
void myEvalSVC::timeout()
{
…………………..
if(x_ > 0){
for(i=0 ; i<x_; i++)
agent_->sendmsg(max_);
}
if(y_!=0)
agent_->sendmsg(y_);
……………………
}
d. Modify the prepare_receivedtrace1.awk
BEGIN{ i=0; } { time=$1 frameno=$2 len=$3 lid=$4 tid=$5 qid=$6 if(frameno>i) i=frameno; FrameLen[frameno]+=len; if(time>FrameRcvTime[frameno]){ FrameRcvTime[frameno]=time; } FrameLid[frameno]=lid; FrameTid[frameno]=tid; FrameQid[frameno]=qid; } END{ for(j=0;j<=i;j++) if(FrameLen[j]!=0) printf("%f\t%d\t%d\t%d\t%d\t%d\n", FrameRcvTime[j], FrameLen[j], FrameLid[j],FrameTid[j], FrameQid[j], j); } |
a. Modify the packet.h that is under /ns-allineone-2.29/ns-2.29/common
…………………………………..
// HDLC packet
PT_HDLC,
// added by smallko
PT_PUMA,
// insert new packet types here
PT_NTYPE // This MUST be the LAST one
…………………………………..
// XCP
name_[PT_XCP]="xcp";
//added by smallko
name_[PT_PUMA]="PUMA";
name_[PT_NTYPE]= "undefined";
…………………………………..
b. Modify the ns-lib.tcl that is under /ns-allinone-2.29/ns-2.29/tcl/lib
…………………………………..
AODV {
set ragent [$self create-aodv-agent $node]
}
PUMA {
set ragent [$self create-puma-agent $node]
}
TORA {
Simulator set IMEPFlag_ ON
set ragent [$self create-tora-agent $node]
}
…………………………………..
Simulator instproc create-aodv-agent { node } {
Create AODV routing agent
ragent [new Agent/AODV [$node node-addr]]
self at 0.0 "$ragent start" ;# start BEACON/HELLO Messages
ode set ragent_ $ragent
turn $ragent
}
Simulator instproc create-puma-agent { node } {
# Create PUMA routing agent
set ragent [new Agent/PUMA [$node node-addr]]
$self at 0.0 "$ragent start"
$node set ragent_ $ragent
return $ragent
}
…………………………………..
c. Modify the Makefile.in that is under /ns-allinone-2.29/ns-2.29
…………………………………..
xcp/xcpq.o xcp/xcp.o xcp/xcp-end-sys.o \
measure/mtcpsink.o measure/mudp.o measure/mudpsink.o \
myvideo/myevalvid.o myvideo/myevalvid_sink.o myvideo/my_udp.o myvideo/myfifo.o \
myvideo/myevalsvc.o myvideo/myevalsvc_sink.o \
noah/noah.o mac/forwarder.o \
puma/puma.o \
queue/dtrr-queue.o \
…………………………………..
d. Download svc_multicast.rar and decompress it.
e. You will find a puma folder and copy this folder to /ns-allinone-2.29/ns-2.29
f. Recompile.
$cd /ns-allinone-2.29/ns-2.29
$./configure; make clean; make depend; make
g. Test the puma protocol
$cd /ns-allineone-2.29/ns-2.29/puma
$ns puma.tcl
If there is no error, it means that you have successfully install puma.
[Simulation]
In this simple example, there are two nodes. One node sends the H.264/SVC video to the other node using multicast. Very simple.
When you decompress svc_multicast.rar, you will see ns_svc_multicast. Copy this folder to cygwin environment. (to C:\cygwin\home\smallko )
#=================================== # Simulation parameters setup #=================================== 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) 5000 ;# max packet in ifq set val(nn) 2 ;# number of mobilenodes set val(rp) PUMA ;# routing protocol set val(x) 500 ;# X dimension of topography set val(y) 500 ;# Y dimension of topography set val(stop) 50.0 ;# time of simulation end #=================================== # Initialization #=================================== #Create a ns simulator set ns [new Simulator] #Setup topography object set topo [new Topography] $topo load_flatgrid $val(x) $val(y) set god_ [create-god $val(nn)] #Open the NS trace file set tracefile [open out.tr w] $ns trace-all $tracefile set tracenam [open out.nam w] $ns namtrace-all-wireless $tracenam $val(x) $val(y) set chan [new $val(chan)];#Create wireless channel #=================================== # Mobile node parameter setup #=================================== $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) \ -channel $chan \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace ON \ -movementTrace OFF #=================================== # Nodes Definition #=================================== #Create 2 nodes set n0 [$ns node] $n0 set X_ 100 $n0 set Y_ 100 $n0 set Z_ 0.0 $ns initial_node_pos $n0 20 set n1 [$ns node] $n1 set X_ 120 $n1 set Y_ 100 $n1 set Z_ 0.0 $ns initial_node_pos $n1 20 #=================================================== set max_fragmented_size 1500 set packetSize $max_fragmented_size set src_udp1 [new Agent/my_UDP] #set the multicast address and port number $src_udp1 set dst_addr_ 0xE000000 $src_udp1 set dst_port_ 100 $src_udp1 set_filename sd $src_udp1 set packetSize_ $packetSize $ns attach-agent $n0 $src_udp1 set dst1_f0 [new Agent/myEvalSVC_Sink] #Set the receiver port number $n1 attach $dst1_f0 100 $dst1_f0 set_filename rd_n1_f0 set original_file_name ns2send set trace_file_name video1.dat set original_file_id [open $original_file_name r] set trace_file_id [open $trace_file_name w] set pre_time 0 while {[eof $original_file_id] == 0} { gets $original_file_id current_line scan $current_line "%f%d%d%d%d%d" t_ size_ lid_ tid_ qid_ fno_ set time [expr int(($t_ - $pre_time)*1000000.0)] if { $tid_ == 0 } { set prio_p 1 } if { $tid_ == 1 } { set prio_p 1 } if { $tid_ == 2 } { set prio_p 1 } puts $trace_file_id "$time $size_ $lid_ $tid_ $qid_ $fno_ $prio_p$max_fragmented_size" set pre_time $t_ } close $original_file_id close $trace_file_id set trace_file [new Tracefile] $trace_file filename $trace_file_name set video1 [new Application/Traffic/myEvalSVC] $video1 attach-agent $src_udp1 $video1 attach-tracefile $trace_file Node instproc join { group } { $self instvar ragent_ set group [expr $group] $ragent_ join $group } Node instproc leave { group } { $self instvar ragent_ set group [expr $group] ; $ragent_ leave $group } #=================================== # Termination #=================================== #Define a 'finish' procedure proc finish {} { global ns tracefile tracenam $ns flush-trace close $tracefile close $tracenam exit 0 } for {set i 0} {$i < $val(nn) } { incr i } { $ns at $val(stop) "\$n$i reset" } $ns at 1.0 "$video1 start" $ns at $val(stop) "$video1 stop" $ns at 0.010000000000000 "$n1 join 0xE000000" $ns at $val(stop) "$n1 leave 0xE000000" $ns at $val(stop) "finish" $ns at $val(stop) "puts \"done\" ; $ns halt" $ns run |
$cd ns_svc_multicast
$ns test_svc_multicast.tcl
$awk –f prepare_receivedtrace1.awk rd_n1_f0 > ns2received
$./prepare_receivedtrace2.exe ns2send ns2received temporal_originaltrace-frameno.txt > received.txt
When you decompress svc_multicast.rar, you will see post_processing. Copy this folder to cygwin_new environment. (to C:\cygwin_new\home\smallko )
Please also copy the received.txt to the post_processing folder (C:\cygwin_new\home\smallko\ post_processing)
Click the cygwin_new icon on the desktop
$nalufilter temporal_originaltrace-frameno.txt received.txt 15000 30 > filteredtrace.txt
$BitStreamExtractorStatic.exe temporal.264 temporal-filter.264 –et filteredtrace.txt
$H264AVCDecoderLibTestStatic.exe temporal-filter.264 temporal-filter.yuv
$framefilter filteredtrace.txt 152064 300 temporal-filter.yuv temporal-conceal.yuv
$PSNRStatic.exe 352 288 foreman_cif temporal-conceal.yuv
From the simulation result, you can see that the PSNR is not good as you expect. This is because that multicast sender does not need any acknowledgement from the receiver. Consequently, when the collision occurs, sender does not know that the collision happens
and then to retransmit.
In this example, n0 sends to n1. n1 forwards the received packets. Therefore, the packets sent by n0 and n1 may get collided.
So interested readers can think how to improve the protocol to make the performance better.
相关文章推荐
- 如何利用无线路由中继网络----蹭网
- NS2上如何在有线网络中组播H.264/SVC视频
- 利用NS2进行无线网络模拟
- win7如何设置默认无线网络
- winXP如何删除无线网络连接及修改无线网络密钥图文教程
- 财宝通告诉你如何利用网络POS机及时到账功能养卡
- 方案探讨 军队无线网络如何接入
- 如何在ns2中实现一个简单的网络协议
- 无线网络攻防实战:WEP密钥如何被攻破的
- 如何通过无线网络真机调试android应用
- (5/8 软件漏洞攻击利用技术)如何成为一名黑客(网络安全从业者)——网络攻击技术篇
- 如何利用Android特点及设计模式 设计一个网络下载功能
- 如何利用神经网络和Python生成指定模式的密码
- NS2入门实例 2---无线网络,两节点(TCP连接,FTP应用)
- 浅谈JAVA中如何利用socket进行网络编程(一)
- 【网络开发】组播的时候到底该如何绑定网卡
- 如何利用Java库学习神经网络
- Win8系统如何使用承载网络方式共享无线实现手机上网
- 统一网络访问 如何组建多层无线网络?