NS2上如何利用无线网络组播H.264/SVC视频
来源:互联网 发布:java的api文档在哪里 编辑:程序博客网 时间:2024/06/05 12:11
本文转载网址: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
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);
}
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 )
#===================================
# 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
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.
- NS2上如何利用无线网络组播H.264/SVC视频
- NS2上如何在有线网络中组播H.264/SVC视频
- NS2中H.264/SVC评估(框架)
- 基于SDN的SVC视频组播系统搭建一
- 基于SDN的SVC视频组播系统搭建二
- 基于SDN的SVC视频组播系统搭建三
- 利用NS2进行无线网络模拟
- H.264 SVC标准流程图--来自中华视频网
- H.264/svc入门
- SVC H.264
- H.264 SVC
- H.264 SVC 与H.264 AVC 有什么区别?
- 利用IP组播技术传输视频信息
- 利用IP组播技术传输视频信息
- 如何利用快播雷达搜索全国范围内共享的视频
- jsvm编码SVC视频
- Tutorial: The H.264 Scalable Video Codec (SVC)
- H.264 SVC的三种Inter Layer Prediction模式
- iOS面试题(转自网络)
- db2 "with ur"
- 图片垂直居中css写法
- Dbhelper
- [Python] 控制台输入密码的方法
- NS2上如何利用无线网络组播H.264/SVC视频
- RA-12519, TNS:no appropriate service handler found The Connection descriptor used by the client was
- 解决关闭,暂停 vmware 虚拟机时导致系统很卡问题
- 使用TableView实现多级树型menu
- Java 线程池的原理与实现
- Android对Linux内核的增强
- 新发现框架
- 《企业软件交付:敏捷与高效管理精要》迷你书
- 识别码知识-UUID