76
LAMPIRAN A LISTING PROGRAM
1. Listing Program Simulasi DSDV
Definisi variabel yang digunakan set valchan ChannelWirelessChannel ; tipe channel
set valprop PropagationTwoRayGround ; model radio propagasi set valnetifPhyWirelessPhy
; tipe network interface set valmac Mac802_11
; tipe MAC set valifq QueueDropTailPriQueue ; tipe antrian interface
set valll LL ; tipe link layer
set valant AntennaOmniAntenna ; model antena set valifqlen
50 ; maks paket di antrian
set valnn 10 ; jumlah node
set valrp DSDV ; protokol routing
set valx 500 ; dimensi topografi X
set valy 500 ; dimensi topografi Y
set valstop 200 ; lamanya simulasi
inisialisai pemangguilan skenario dari cbrgen dan RW-mobility set valnod .node10node6.txt
set valcon .koneksi7koneksi.txt set ns_ [new Simulator]
set tracefd [open dsdv6.tr w] set namtrace [open dsdv.nam w]
ns_ use-newtrace ns_ trace-all tracefd
ns_ namtrace-all-wireless namtrace valx valy
Set up objek topografi set topo [new Topography]
topo load_flatgrid valx valy proc create-god { nodes } {
global ns_ god_ tracefd set god_ [new God]
god_ num_nodes nodes }
create-god valnn Konfigurasi node
ns_ node-config -adhocRouting valrp \ -llType valll \
-macType valmac \ -ifqType valifq \
-ifqLen valifqlen \ -antType valant \
-propType valprop \ -phyType valnetif \
-topoInstance topo \ -agentTrace ON \
-routerTrace ON \ -macTrace OFF \
-movementTrace ON \ -channelType valchan\
for {set i 0} {i valnn } {incr i} { set node_i [ns_ node]
node_i random-motion 1; }
Pemanggilan skenario mobile node source valnod
Pemanggilan skenario koneksi source valcon
menginisialisasi posisi node dalam NAM for {set i 0} {i valnn} { incr i } {
ukuran node dalam NAM ns_ initial_node_pos node_i 30 }
Memberitahu node bahwa simulsai telah berakhir for {set i 0 } {i valnn } { incr i } {
ns_ at valstop node_i reset; }
Mengakhiri simulasi NAM ns_ at valstop ns_ nam-end-wireless valstop
ns_ at valstop stop ns_ at 200.0 puts \end simulation\; ns_ halt
proc stop {} { global ns_ namtrace
ns_ flush-trace close namtrace
exec nam dsdv.nam }
ns_ run
Gambar A.1 Listing program simulasi DSDV.
2. Listing Program Simulasi OLSR