Simulasi Wireless pada NS 2
Apa itu Jaringan Nirkabel atau wireless ?
Jaringan nirkabel adalah sistem komunikasi yang mentransmisikan dan menerima sinyal radio melalui media udara. Jaringan nirkabel umumnya mengacu pada jaringan Wifi atau layanan data 3g / 4g.
http://ns2simulator.com/wp-content/uploads/2015/10/Architecture-of-Wireless-Network1.png
Contoh code NS 2 Jaringan Nirkabel
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) 3 ;# number of mobilenodes
set val(rp) DSR ;# routing protocol
set val(x) 1200 ;# X dimension of topography
set val(y) 1000 ;# Y dimension of topography
set val(stop) 50 ;# time of simulation end
set val(err) UniformErrorProc
# Set up topography object
#-------------------------------------------
set ns [new Simulator]
set tracefd [open simple.tr w]
set windowVsTime2 [open win.tr w]
set namtrace [open simwrls.nam w]
$ns use-newtrace
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
proc UniformErrorProc {} {
puts "dfdfad-----------------------------"
set err [new ErrorModel]
$err unit pkt
$err set rate_ 0.1
return $err
}
create-god $val(nn)
$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 [new $val(chan)] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace OFF \
-macTrace OFF \
-movementTrace OFF \
-IncomingErrProc $val(err)\
-OutgoingErrProc $val(err)
# -IncomingErrorProc ($err) \
# -OutcomingErrorProc UniformErrorProc
for {set i 0} {$i < $val(nn) } { incr i } {
set node_($i) [$ns node]
}
$node_(0) set X_ 600.0
$node_(0) set Y_ 500.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 800.0
$node_(1) set Y_ 400.0
$node_(1) set Z_ 0.0
$node_(2) set X_ 1000.0
$node_(2) set Y_ 400.0
$node_(2) set Z_ 0.0
set tcp [new Agent/TCP/Newreno]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node_(0) $tcp
$ns attach-agent $node_(2) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 1.0 "$ftp start"
set cbr_(0) [new Application/Traffic/CBR]
$cbr_(0) set packetSize_ 200
$cbr_(0) set interval_ 0.01
$cbr_(0) set random_ 1
$cbr_(0) set maxpkts_ 10000
$cbr_(0) attach-agent $udp_(0)
$ns connect $udp_(0) $null_(0)
$ns at 11.0 "$cbr_(0) start"
# Printing the window size
proc plotWindow {tcpSource file} {
global ns
set time 5.00
set now [$ns now]
set cwnd [$tcpSource set cwnd_]
puts $file "$now $cwnd"
$ns at [expr $now+$time] "plotWindow $tcpSource $file" }
$ns at 10.1 "plotWindow $tcp $windowVsTime2"
# Define node initial position in nam
for {set i 0} {$i < $val(nn)} { incr i } {
# 30 defines the node size for nam
$ns initial_node_pos $node_($i) 30
}
# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "$node_($i) reset";
}
proc stop {} {
global ns tracefd namtrace
$ns flush-trace
close $tracefd
close $namtrace
}
$ns run
sumber : http://ns2simulator.com , http://www.pengertianku.net/2015/01/pengertian-wireless-dan-cara-kerjanya-lebih-lengkap.html
Jaringan nirkabel adalah sistem komunikasi yang mentransmisikan dan menerima sinyal radio melalui media udara. Jaringan nirkabel umumnya mengacu pada jaringan Wifi atau layanan data 3g / 4g.
http://ns2simulator.com/wp-content/uploads/2015/10/Architecture-of-Wireless-Network1.png
Kelebihan Wireless, sebagai mana di bawah ini :
- Pembagunan jaringan yang cepat.
- Mudah dan murah untuk direlokasi.
- Biaya pemeliharaannya murah.
- Infrastruktur berdimensi kecil.
- Mudah untuk dikembangkan.
- Sumber-sumber file bisa pindahkan dengan mudah tanpa menggunakan media kabel.
- Mudah sekali untuk di-setup, dan juga handal sehingga cocok untuk pemakaian di kantor maupun di rumah.
Kekurangan wireless, dimana ada kelebihan tentunya pasti ada kekurangannya, antara lain :
- Keamanan atau kerahasiaan data data rentan.
- Interferensi gelombang radio.
- Delay (kelambatan) yang besar.
- Biaya peralatan rata-rata mahal.
- Produk dari produsen yang berbeda-beda kadang tidak kompatibel/cocok.
- Kualitas sinyalnya dipengaruhi oleh keadaan udara maupun cuaca, artinya kualitas dari koneksinya saat cuaca bagus akan berbeda, saat kualitas koneksi cuaca buruk (kalau dipakai diluar gedung/ruangan) dan dipengaruhi juga oleh batas-batas dinding gedung atau ruangan.
- Mahal dalam investasinya, kalau dibanding dengan menggunakan media kabel.
- Kemungkinan penyadapan koneksinya lebih besar terjadi, jika dibandingkan dengan menggunakan media kabel.
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) 3 ;# number of mobilenodes
set val(rp) DSR ;# routing protocol
set val(x) 1200 ;# X dimension of topography
set val(y) 1000 ;# Y dimension of topography
set val(stop) 50 ;# time of simulation end
set val(err) UniformErrorProc
# Set up topography object
#-------------------------------------------
set ns [new Simulator]
set tracefd [open simple.tr w]
set windowVsTime2 [open win.tr w]
set namtrace [open simwrls.nam w]
$ns use-newtrace
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
proc UniformErrorProc {} {
puts "dfdfad-----------------------------"
set err [new ErrorModel]
$err unit pkt
$err set rate_ 0.1
return $err
}
create-god $val(nn)
$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 [new $val(chan)] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace OFF \
-macTrace OFF \
-movementTrace OFF \
-IncomingErrProc $val(err)\
-OutgoingErrProc $val(err)
# -IncomingErrorProc ($err) \
# -OutcomingErrorProc UniformErrorProc
for {set i 0} {$i < $val(nn) } { incr i } {
set node_($i) [$ns node]
}
$node_(0) set X_ 600.0
$node_(0) set Y_ 500.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 800.0
$node_(1) set Y_ 400.0
$node_(1) set Z_ 0.0
$node_(2) set X_ 1000.0
$node_(2) set Y_ 400.0
$node_(2) set Z_ 0.0
set tcp [new Agent/TCP/Newreno]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node_(0) $tcp
$ns attach-agent $node_(2) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 1.0 "$ftp start"
set cbr_(0) [new Application/Traffic/CBR]
$cbr_(0) set packetSize_ 200
$cbr_(0) set interval_ 0.01
$cbr_(0) set random_ 1
$cbr_(0) set maxpkts_ 10000
$cbr_(0) attach-agent $udp_(0)
$ns connect $udp_(0) $null_(0)
$ns at 11.0 "$cbr_(0) start"
# Printing the window size
proc plotWindow {tcpSource file} {
global ns
set time 5.00
set now [$ns now]
set cwnd [$tcpSource set cwnd_]
puts $file "$now $cwnd"
$ns at [expr $now+$time] "plotWindow $tcpSource $file" }
$ns at 10.1 "plotWindow $tcp $windowVsTime2"
# Define node initial position in nam
for {set i 0} {$i < $val(nn)} { incr i } {
# 30 defines the node size for nam
$ns initial_node_pos $node_($i) 30
}
# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "$node_($i) reset";
}
proc stop {} {
global ns tracefd namtrace
$ns flush-trace
close $tracefd
close $namtrace
}
$ns run
sumber : http://ns2simulator.com , http://www.pengertianku.net/2015/01/pengertian-wireless-dan-cara-kerjanya-lebih-lengkap.html
Komentar
Posting Komentar