LAMPIRAN 1
Masukan pada Script mac802_16SS.h
class Mac802_16SS : public Mac802_16 {
friend class BwRequest;
public:
Mac802_16SS();
//Kecepatan
double v_1=0; //Kecepatan Mobile 1
double v_2=1.39; //Kecepatan Mobile 2
double v_3=4.44; //Kecepatan Mobile 3
double v_4=6.67; //Kecepatan Mobile 4
//Posisi
double xbs_0=1000; //Posisi koordinat X BTS
double ybs_0=1000; //Posisi koordinat Y BTS
double D_; //Jarak BTS ke Mobile
double x_; //Posisi koordinat X
double y_; //Posisi koordinat Y
//power receive
double Pr_origin;
double Pr_dBm_;
double Pt_=10; //Power Transmit
double Gr_=1; //Gain antena receive
double Gt_=1; //Gain antena Transmit
double L_=1; //Loss pada Sistem
double pi_=3.14;
double lambda=0.12; //kecepatan cahaya dibagi frekuensi kerja 2.5 GHz
double B_=5e+6; //Bandwidth
//KONSUMSI_ENERGI
double initial;
double energyTotal;
double battery=72000;
double energyTemp;
double idlePower=0.06;
double sleepPower=0.29;
double sendPower=0.17;
double recPower=0.07;
double ULPower=1;
double DLPower=1;
LAMPIRAN 2
Masukan pada Script mac802_16SS.cc
A Record konsumsi energi
energyTemp=(NOW-a)*recPower;
energyTotal=energyTotal+energyTemp;
battery=battery-energyTemp;
debug ("Energy model: at %f in Mac %d,battery: %.17f energy: %.17f total
energy %.17f\n", NOW, addr(), battery, energyTemp, energyTotal);
B Record Jarak
void Mac802_16SS::receive ()
{
double a=initial;
assert (pktRx_);
struct hdr_cmn *ch = HDR_CMN(pktRx_);
//Pada Subscriber station 1 if(index_==1){
nn++;
sb++;
x_=600;
//***
//MENGHITUNG JARAK BS ke SS
D_=sqrt((pow((x_-xbs_0),2))+(pow((y_-ybs_0),2)));
//power receive dalam watt
Pr_origin=(((Pt_*Gt_*Gr_*pow(lambda,2))/(pow((4*pi_*D_),2)*L_)));
Pr_=Pr_origin;
//power receive dalam dBm
Pr_dBm_=(10*log10(Pr_))+30;
}
//***
//Pada Subscriber station 2
}else if(index_==2){
nn++;
sb++;
x_=500/559.01*(v_2*NOW)+700;
D_=sqrt((pow((x_-xbs_0),2))+(pow((y_-ybs_0),2)));
//*** //***
//Pada Subscriber station 3
}else if(index_==3){
nn++;
sb++;
x_=200/585.23*(v_3*NOW)+1100;
y_=550/585.23*(v_3*NOW)+800;
//*** //***
//Pada Subscriber station 4
}else if(index_==4){
nn++;
sb++;
x_=-600/813.94*(v_4*NOW)+1200;
y_=-550/813.94*(v_4*NOW)+1100;
//*** //***
LAMPIRAN 3 Script wimax_uplink.Tcl
# Topology scenario: #
#check input parameters if {$argc != 0} {
puts ""
puts "Wrong Number of Arguments! No arguments in this topology" puts ""
exit (1) }
# set global variables
set nb_mn 4 ;# max number of mobile node
set packet_size 1052 ;# packet size in bytes at CBR applications set output_dir .
set gap_size 0 ;#compute gap size between packets puts "gap size=$gap_size"
set traffic_start 30
#Define WiMAX Parameters Mac/802_16 set rtg_ 20 Mac/802_16 set ttg_ 20
Mac/802_16 set frame_duration_ 0.004
Mac/802_16 set client_timeout_ 110 ;#to avoid BS disconnecting the SS since the traffic starts a 100s
Phy/WirelessPhy/OFDM set g_ 0.0; # Cyclic Prefix 0
WimaxScheduler/BS set dlratio_ 0.50; # 50% of Bandwidth is for downloading
#define coverage area for base station: 1000m coverage Phy/WirelessPhy set Pt_ 0.281838
Phy/WirelessPhy set freq_ 5e+6
#Phy/WirelessPhy set RXThresh_ 2.90781e-09
Phy/WirelessPhy set RXThresh_ 1.42681e-12 ;#1000m radius
Phy/WirelessPhy set CSThresh_ [expr 0.9*[Phy/WirelessPhy set RXThresh_]]
# Parameter for wireless nodes
set opt(chan) Channel/WirelessChannel ;# channel type
Mac/802_11 set basicRate_ 11Mb Mac/802_11 set dataRate_ 11Mb Mac/802_11 set bandwidth_ 11Mb
#defines function for flushing and closing files proc finish {} {
global ns tf output_dir nb_mn $ns flush-trace
close $tf
#Execute nam on the trace file exec nam out1a.nam &
#create the simulator set ns [new Simulator] $ns use-newtrace
#create the topography set topo [new Topography]
$topo load_flatgrid $opt(x) $opt(y) #puts "Topology created"
#open file for trace
set tf [open $output_dir/out1a.res w] $ns trace-all $tf
#initialize network animator set namtrace [open out1a.nam w]
$ns namtrace-all-wireless $namtrace $opt(x) $opt(y) #puts "Output file configured"
# set up for hierarchical routing (needed for routing over a basestation) #puts "start hierarchical addressing"
$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 1 [expr ($nb_mn+1)] ;# number of nodes for each cluster (1 for sink and one for mobile nodes + base station
AddrParams set nodes_num_ $eilastlevel
puts "Configuration of hierarchical addressing done" # Create God
create-god [expr ($nb_mn + 2)] ;# nb_mn + 2 (base
station and sink node) #puts "God node created"
#creates the sink node in first addressing space. set sinkNode [$ns node 0.0.0]
#provide some co-ord (fixed) to base station node $sinkNode set X_ 1050.0
$sinkNode set Y_ 1050.0 $sinkNode set Z_ 0.0 #puts "sink node created"
$ns node-config -adhocRouting $opt(adhocRouting) \ #puts "Configuration of base station"
set bstation [$ns node 1.0.0] $bstation random-motion 0 #puts "Base-Station node created"
#provide some co-ord (fixed) to base station node $bstation set X_ 1000.0
$bstation set Y_ 1000.0 $bstation set Z_ 0.0
[$bstation set mac_(0)] set-channel 0
# create the link between sink node and base station
$ns duplex-link $sinkNode $bstation 100Mb 1ms DropTail $ns queue-limit $sinkNode $bstation 50
# creation trace traffic
set max_fragmented_size 1024
#add udp header(8 bytes) and IP header (20bytes) set packetSize 1052
set original_file_name st20_20x 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
set time [expr int(($tmp2_ - $pre_time)*1000000.0)]
puts $trace_file_id "$time $length_ $type_v $prio_p $max_fragmented_size" set pre_time $tmp2_
}
close $original_file_id close $trace_file_id set end_sim_time $tmp2_ puts "$end_sim_time"
set trace_file [new Tracefile]
$trace_file filename $trace_file_name
# creation of the mobile nodes
$ns node-config -macType Mac/802_16/SS \ -wiredRouting OFF \
$wl_node_($i) random-motion 0 ;# disable random
motion
if {$i == 0 } {
#compute position of the node $wl_node_($i) set X_ 600 $wl_node_($i) set Y_ 800 $wl_node_($i) set Z_ 0.0
$ns at 0 "$wl_node_($i) setdest 1100.0 1050 0.0" ;#Fixed camera }
if {$i == 1 } {
#compute position of the node $wl_node_($i) set X_ 700 $wl_node_($i) set Y_ 900 $wl_node_($i) set Z_ 0.0
$ns at 0 "$wl_node_($i) setdest 1200.0 1150 1.39" ;#Walking speed average: 5km/h according Wikipedia
}
if {$i == 2 } {
#compute position of the node $wl_node_($i) set X_ 1100 $wl_node_($i) set Y_ 800 $wl_node_($i) set Z_ 0.0
$ns at 0 "$wl_node_($i) setdest 1300.0 1350 4.44" ;#Tram speed average: 16km/h based on Yarra tram
}
if {$i == 3 } {
#compute position of the node $wl_node_($i) set X_ 1200 $wl_node_($i) set Y_ 1100 $wl_node_($i) set Z_ 0.0
$ns at 0 "$wl_node_($i) setdest 600.0 550 6.67" ;#Bus speed in city: average 24km/h based on Swedish city
}
puts "wireless node $i created ..." ;# debug info
[$wl_node_($i) set mac_(0)] set-channel 0
[$wl_node_($i) set mac_(0)] set-diuc 7 ;# Change the node profile here (7=64QAM_3_4)
#create source traffic
#Create a UDP agent and attach it to node n0 set udp_($i) [new Agent/myUDP]
$udp_($i) set packetSize_ 1052 #$udp_($i) set set_max_fd_ 0.3 #$udp_($i) set ccdelay_ 0.0 #$udp_($i) set set_win_ 0
#$udp_($i) set set_ack_distance 10 $udp_($i) set set_window_ 0
$ns attach-agent $wl_node_($i) $udp_($i)
# Attach video traffic source
set video1a_($i) [new Application/Traffic/myEvalvid] $video1a_($i) attach-tracefile $trace_file
$video1a_($i) attach-agent $udp_($i)
# Create the Null agent to sink traffic set null_($i) [new Agent/myEvalvid_Sink] $null_($i) set_filename udpRec1a_($i) $ns attach-agent $sinkNode $null_($i)
# Attach the 2 agents
$ns connect $udp_($i) $null_($i) }
# Traffic scenario: if all the nodes start talking at the same
# time, we may see packet loss due to bandwidth request collision set traffic_stop 271
set diff 0.1
for {set i 0} {$i < $nb_mn} {incr i} {
$ns at [expr $traffic_start+$i*$diff] "$video1a_($i) start" $ns at [expr $traffic_stop+$i*$diff] "$video1a_($i) stop" }
#$ns at 4 "$nd_(1) dump-table" #$ns at 5 "$nd_(1) send-rs" #$ns at 6 "$nd_(1) dump-table" #$ns at 8 "$nd_(1) dump-table"
$ns at 275 "finish"
#$ns at $simulation_stop "$ns halt" # Run the simulation
puts "Running simulation for $nb_mn mobile nodes..." $ns run
LAMPIRAN 4
A. Tanpa Pengaturan Beban
159 P 4671 6 11.52
160 P 5064 6 11.6
161 P 5037 6 11.68
162 P 4390 6 11.76
163 P 5171 6 11.84
164 P 4301 6 11.92
105 I 15999 16 10.4
106 P 7559 9 10.52
107 P 5412 6 10.64
108 P 6276 8 10.76
109 P 5996 7 10.88
110 P 6379 8 11
111 P 9082 11 11.12
112 P 3265 4 11.16
113 I 15783 16 11.2
114 P 8158 9 11.32
115 P 8234 9 11.44
116 P 7053 9 11.56
117 P 7719 9 11.68
118 P 6987 9 11.8
119 P 6875 9 11.92
LAMPIRAN 5
Proses Saat Menjalankan Simulasi NS-2
1. Hal yang pertama dilakukan adalah membuka “command line” pada OS Ubuntu 12.35. Dengan cara “ Ctrl + Alt + T “, apabila sudah dilakukan akan terlihat pada gambar berikut.
Gambar Terminal Pada Ubuntu 12.35
Gambar Membuat Folder dan Meletakkan File .Tcl
3. Apabila sudah selesai dilakukan, maka kembali ke “command line” untuk proses pengujian simulasi pada NS-2. Pada “command line” ketik sebuah perintah “cd” yang mana fungsinya kita untuk masuk kedalam folder yang kita buat sebelumnya, kalau pada simulasi ini nama foldernya “Tanpa Pengaturan beban
protokol” yang dapat terlihat pada gambar dibawah. Kemudian tekan “Enter”.
Gambar Command Line Pada Ubuntu 12.35
Gambar Command Line Pada Ubuntu 12.35
5. Pada gambar dibawah, menunjukkan program NS-2 sedang berjalan.
Gambar Pogram NS-2 Sedang Berjalan
7. Kemudian, dari simulasi pada NS-2 didapat sebuah file yang berbentuk .txt yang nantinya kita olah kedalam Ms.Exel untuk mendapat hasil simulasi yang kita inginkan. Untuk Tugas akhir ini hanya menganalisa permintaan client saja sehingga file dengan nama “udprec” yang diolah nantinya. Seperi yang terlihat pada gambar dibawah.
8. Pada Gambar dibawah, itu adalah salah satu isi hasil simulasi yang telah dilakukan dan hasil simulasi tersebut di olah menggunakan Ms.Exel agar didapat perhitungan delaydan packet loss.