LAMPIRAN A DIAGRAM ALIR PROSES SIMULASI MULAI
MASUKKAN DATA
DEFINIS AWAL VARIABEL SIMULASI
WAKTU SIMULASI DIHALANKAN
F
TIDAK
C
N1 = 1: length(ebn0)
YA PROSES PEMBANGKITAN DATA
PENAMBAHAN HEADER PADA DATA
PROSES PEMECAHAN DATA MENJADI SEGMEN
YA
UKURAN DATA > 65511 byte
TIDAK
SEGMEN = 1
PENAMBAHAN HEADER IP PADA TIAP SEGMEN
PROSES PEMECAHAN SEGMEN MENJADI PAKET
YA
UKURAN DATA > 1500 byte
TIDAK
PAKET = 1
A
Universitas Sumatera Utara
A
PENAMBAHAN HEADER ETHERNET PADA TIAP PAKET
PERHITUNGAN DELAY ENGKAPSULASI DIJALANKAN
PELEPASAN HEADER ETHERNET PADA TIAP PAKET
PERHITUNGAN DELAY DEENGKAPSULASI DIJALANKAN
PROSES PENAMBAHAN HEADER PCF PADA TIAP SEGEMEN
PERHITUNGAN DELAY ENGKAPSULASI DIJALANKAN
PELEPASAN HEADER PCF PADA TIAP PAKET
PERHITUNGAN DELAY DEENGKAPSULASI DIJALANKAN
PROSES PENGGABUNGAN DATA DAN PENAMBAHAN HEADER SDU
PERHITUNGAN DELAY ENGKAPSULASI DIJALANKAN
PROSES PENENTUAN UKURAN BIT INFORMASI BERDASARKAN UKURAN PHYSICAL BIT
B
Universitas Sumatera Utara
B
PROSES PENENTUAN BANYAK FRAME YANG AKAN DIKIRIMKAN DAN NILAI REPETISI BERDASARKAN UKURAN BIT INFORMASI
PROSES PEMECAHAN DATA SDU MENJADI N_MAC RADIO BLOK BERDASARKAN UKURAN BIT INFORMASI
N = 1 : N_MAC
E
TIDAK
PERHITUNGAN BER DIJALANKAN
YA PENAMBAHAN FCS DAN TAIL PADA TIAP RADIO BLOK C
DATA DIPULIKASI SEBANYAK DUA KALI
TIDAK
CODE = 1
YA FUNGSI PENGKODEAN DIJALANKAN DENGAN CODE RATE = 1/3
FUNGSI INTERLEAVING DIJALANKAN
FUNGSI MAPPING QAM DIJALANKAN
TIDAK
PB == 3072
YA FUNGSI MAPPING PSK DIJALANKAN
PROSES PENENTUAN PARAMETER AIRLINK
DATA DIREPETISI SESUAI DENGAN NIALAI REPETISI
D
Universitas Sumatera Utara
D
PROSES PENENTUAN SLOT
PENAMBAHAN NOISE AWGN
PROSES PELEPASAN SLOT
FUNGSI DEMAPPING QAM DIJALANKAN
TIDAK
PB == 3072
YA
FUNGSI DEMAPPING PSK DIJALANKAN
PROSES DEINTERLEAVING
PENGHAPUSAN DIPULIKASI DATA
TIDAK
CODE = 1
YA FUNGSI PENGDEKODEAN DIJALANKAN DENGAN CODE RATE = 1/3
PEMASUKAN DATA HASIL DECODING KE DALAM ARRAY DATA_TERIMA
E
Universitas Sumatera Utara
F
PROSES PERHITUNGAN DELAY AIRLINK, DEENKAPSULASI SDU, DELAY TRANSMISI DAN DELAY PROPAGASI
PERHITUNGAN DELAY TOTAL
PERHITUNGAN TROUGHPUT
MUNCULKAN GRAFIK
SELESAI
Universitas Sumatera Utara
LAMPIRAN B SCRIPT PROGRAM SIMULASI evdo.m clear all; clc; disp('% SIMULASI KINERJA LAYANAN DATA BERKECEPATAN TINGGI %'); disp('%PADA SISTEM CDMA 2000 1X EV-DO (EVOLUTION DATA OPTIMIZED %'); disp('% NANDO BOY INTON SIDAURUK %'); disp('% 040402080 %'); ukuran_data=input('Masukkan ukuran data yang ingin dikirimkan (byte) = '); pb = input('Masukkan ukuran physical bit yang dikirim (bit) = '); code = 1; ebn0 = 10:2:30; R = 1000; wr = 3e8; tic for n1 = 1:length(ebn0); for zz=1:30; SNR = ebn0(n1); data = round(rand(1,ukuran_data)*10); header_tcp=zeros(1,20); header_udp=zeros(1,8); data_segmen = [header_tcp data]; data
%penambahan header tcp pada
if size(data_segmen(1,2)) > 65511; segmen = fix(length(data_segmen)/65511); datap_segmen = reshape(data_segmen,segmen,65511); else segmen = 1; datap_segmen = data_segmen; end header_ip = zeros(segmen,20); datap_segmen = [header_ip datap_segmen]; data_datagram = datap_segmen; %ukuran_datagram = size(data_datagram); if length(data_datagram) > 1500; m = mod(length(data_datagram),1500); if m ~= 0 pecah = fix(length(data_datagram)/1500); datagram1 = data_datagram(1,1:pecah*1500); datagram2 = data_datagram(1,(pecah*1500)+1:length(data_datagram));
Universitas Sumatera Utara
datap_datagram1 = reshape(datagram1,pecah,1500); datap_datagram2 = reshape(datagram2,1,length(datagram2)); header_ethernet = zeros (1,25); data_ethernet2=[header_ethernet datap_datagram2]; else datagram = (length(data_datagram)/1500); datap_datagram1 = reshape(data_datagram,datagram,1500); datap_datagram2 = [];data_ethernet2 = []; end else pecah = 1; datap_datagram1 = data_datagram; end header_ethernet = zeros (pecah,25); data_ethernet1=[header_ethernet datap_datagram1]; sink_dataeth1 = reshape(data_ethernet1,1,length(data_ethernet1)*pecah); total_feth = [sink_dataeth1 data_ethernet2]; delay_enkapPDSN = length(total_feth)*8/1e9; %*****************PCF****************************************** delay_deenkapPDSN = length(total_feth)*8/100e6; data_ethernet1=datap_datagram1; data_ethernet2=datap_datagram2; delay_enkapPCF = ((length(datap_datagram1)*pecah)+length(datap_datagram2))*8/100e6; %******************SDU********************* delay_deenkapPCF = ((length(datap_datagram1)*pecah)+length(datap_datagram2))*8/155.52 e6; atur = pecah*length(data_ethernet1); if m ~= 0 data_SDU = [reshape(data_ethernet1,1,atur) data_ethernet2]; else data_SDU = reshape(data_ethernet1,1,atur); end data_SDU = de2bi(data_SDU,8,'left-msb'); data_SDU = data_SDU'; data_SDU = reshape(data_SDU,1,length(data_SDU)*8); header_SDU = zeros (1,30); data_PDU = [header_SDU data_SDU]; %menentukan ukuran bit informasi dalam 1 frame physical bit if pb == 1024; bi = pb-16-6; n_mod=2; elseif pb == 2048 bi = pb-22-16-6; n_mod=2;
Universitas Sumatera Utara
elseif pb == 3072 bi = pb-44-16-6; n_mod=8; elseif pb == 4096 bi = pb-66-16-6; n_mod=4; end mPDU = mod(length(data_PDU),bi); fPDU = fix(length(data_PDU)/bi); if mPDU ~= 0 sink_PDU = []; PDU2 = data_PDU (1,((bi*fPDU)+1):length(data_PDU)); atur1 = fix(bi/length(PDU2)); atur2 = mod(bi,length(PDU2)); for n = 1:atur1 sink_PDU = [sink_PDU PDU2]; end if atur2 ~= 0 sink_PDU = [sink_PDU PDU2(1,1:atur2)]; end data_PDU = [data_PDU(1,1:bi*fPDU) sink_PDU]; end N_MAC = length(data_PDU)/bi; footer = zeros(1,pb-bi); if pb == 1024 repetisi = 1; elseif pb == 2048 repetisi = 2.04; else repetisi = 1.02; end data_terima = []; for n = 1:N_MAC %********************Proses diPengirim********************% data_kirim = data_PDU(1,1+(n-1)*bi:n*bi); data_kirim = [data_kirim footer]; if code == 1 out =acak(data_kirim); out = out'; out = reshape(out,1,length(out)*3); else out = [data_kirim data_kirim data_kirim]; end nilai_inter = length(out); data_interleaved = interleaving (out,nilai_inter,n_mod,1); if pb==3072; data_transmit = maping2(data_interleaved,1); else data_transmit = mapping (data_interleaved,n_mod,1); end %*****************Proses diPenerima************************% [preamble,mac,pilot,slot,data_rate]=parameter_airlink(pb); data_repetisi = ulang(data_transmit,repetisi);
Universitas Sumatera Utara
data_slot = urutan(preamble,data_repetisi,slot); data_noise(n1,:) = awgn(data_slot,SNR); data_slotrx = urutanrx(data_noise(n1,:),slot,preamble); if pb==3072; data_mappingrx = maping2(data_slotrx,0); else data_mappingrx = mapping(data_slotrx,n_mod,0); end data_interleavedrx = interleaving (data_mappingrx,nilai_inter,n_mod,0); data_interleavedrx =reshape(data_interleavedrx,3,length(data_interleavedrx)/3); if code == 1 data_interleavedrx = data_interleavedrx'; out_terima = deacak(data_interleavedrx); out_terima = out_terima(1,1:bi); else out_terima = data_interleavedrx(1,:); out_terima = out_terima(1,1:bi); end data_terima = [data_terima out_terima]; delay_airlink(n,1)=length(data_slot)/data_rate; end if pb == 3072 if SNR > 16 ber(n1,1)=0; else ber(n1,1)=mean(data_terima(:)~=data_PDU(:)); end else ber(n1,1)=mean(data_terima(:)~=data_PDU(:)); end BER(zz,1)=ber(n1,1); end ber(n1,1)=mean(BER); end delay_enkapSDU = (pb*N_MAC)/155.52e6; delay_airlink = mean(delay_airlink(:)); delay_deenkapSDU = (pb*N_MAC/pb)*(slot*1.67e-3); %**************Perhitungan Delay Transmisi******************** delay_RP = length(total_feth)*8/100e6; delay_A8 = ((length(datap_datagram1)*pecah)+length(datap_datagram2))*8/155.52 e6; delay_Abis = pb*N_MAC/155.52e6; delay_Um = (pb*N_MAC/pb)*(slot*1.67e-3); %*****************Perhitungan Delay Propagasi****************** delay_prop = (3+N_MAC)*R/3e8; %**************************************************************
Universitas Sumatera Utara
waktu=toc; delay_total = delay_enkapPDSN + delay_deenkapPDSN + delay_enkapPCF + ... delay_deenkapPCF + delay_enkapSDU + delay_airlink + delay_deenkapSDU + ... delay_RP + delay_A8 + delay_Abis + delay_Um + delay_prop; troughput=length(data_terima)/delay_total; fprintf('Nilai ber untuk tiap EbN0\n'); fprintf('|------------------------|\n'); fprintf('| EbN0 (dB) | BER |\n'); fprintf('|------------------------|\n'); for ss = 1:length(ber) fprintf('| %2.0f | %0.3f |\n',ebn0(ss),ber(ss)); end fprintf('|----------------------------|\n\n'); fprintf('Delay total adalah %3.2f detik \n',delay_total); fprintf('Troughput adalah %3.2f bps \n',troughput); fprintf('Waktu Simulasi adalah %3.2f detik \n',waktu); plot(ebn0,ber); grid on; hold on;
acak.m function [out] = acak(data_kirim) seed=zeros(1,8); data_encode=[]; for i=1:length(data_kirim) x=data_kirim(i); y=seed(1); for ii = 1:3 switch ii case 1 x1=xor(x,seed(2)); x1=xor(x1,seed(3)); x1=xor(x1,seed(5)); x1=xor(x1,seed(6)); x1=xor(x1,seed(7)); x1=xor(x1,seed(8)); case 2 x2=xor(y,y); x2=xor(x2,seed(3)); x2=xor(x2,seed(4)); x2=xor(x2,seed(7)); x2=xor(x2,seed(8)); case 3 x3=xor(x,seed(1)); x3=xor(x3,seed(2));
Universitas Sumatera Utara
x3=xor(x3,seed(5)); x3=xor(x3,seed(8)); end end d=[x1 x2 x3]; data_encode(i,:) = d; for next=length(seed):-1:1 if next == 1; seed(next)=data_kirim(i); else seed(next)=seed(next-1); end end end out = data_encode; return;
deacak.m function [out] = deacak(data_terima); seed=zeros(1,8); data_encode=[]; for i=1:length(data_terima) y=seed(1); for ii = 1:3 switch ii case 1 x=data_terima(i,ii); x1=xor(x,seed(8)); x1=xor(x1,seed(7)); x1=xor(x1,seed(6)); x1=xor(x1,seed(5)); x1=xor(x1,seed(3)); x1=xor(x1,seed(2)); case 2 x2=data_terima(i,ii); x2=xor(x2,seed(8)); x2=xor(x2,seed(7)); x2=xor(x2,seed(4)); x2=xor(x2,seed(3)); x22=xor(y,y); x2=xor(x2,x22); case 3 x3=data_terima(i,ii); x3=xor(x3,seed(8)); x3=xor(x3,seed(5)); x3=xor(x3,seed(2)); x3=xor(x3,seed(1)); end end d=or(x1,x3); data_dencode(1,i) = d; for next=length(seed):-1:1 if next == 1; seed(next)=d; else
Universitas Sumatera Utara
seed(next)=seed(next-1); end end end out = data_dencode; return;
Parameter constellation.m function [M,M1,M2,type_map,c] =parameters_constellation(n_mod_type);
switch n_mod_type case 1 type_map = 'MPSK'; M = 2; M1 = 0; M2 = 0; c = 1; case 2 type_map = 'QAM'; c = 1/sqrt(2); case 4 type_map = 'QAM'; c = 1/sqrt(10); case 6 type_map = 'QAM'; c = 1/sqrt(42); end if n_mod_type~=1 M = 0; M1 = sqrt(2^n_mod_type); M2 = sqrt(2^n_mod_type); end
% for BPSK
% for QPSK(or 4-QAM)
% for 16-QAM
% for 64-QAM
mapping.m function data_mapping = mapping( data_interleaving, n_mod_type,Tx) [M,M1,M2,type_mapping,c] = parameters_constellation(n_mod_type); alphabet = bit_symbol(M,type_mapping,M1,M2); if n_mod_type~=1 constellation_gray = alphabet(:,3) + j*alphabet(:,2); else constellation_gray = [0 1]'; end l = length(data_interleaving);
if Tx==1
Universitas Sumatera Utara
matrix_data = reshape (data_interleaving,n_mod_type,l/n_mod_type); m_data_decimal = bi2de (matrix_data','left-msb'); for i=1:(l/n_mod_type) v_data_decimal = m_data_decimal (i); v_encode = genqammod(v_data_decimal,constellation_gray); output(:,i) = v_encode; end data_mapping = c.*output; elseif Tx==0 data_normalized = data_interleaving ./ c; for i=1:l v_data_mapping = data_normalized (i); v_decode = genqamdemod(v_data_mapping,constellation_gray); data_decimal(:,i) = v_decode; data_mapping = de2bi(data_decimal,n_mod_type,'left-msb')'; data_mapping = data_mapping(:)'; end end
mapping2.m function [data_mapping]=maping2(data,Tx) if Tx == 1; data=reshape(data,length(data)/3,3); data=bi2de(data,'left-msb'); x=length(data)/8; data=reshape(data,8,x); for nn=1:x data_map(:,nn)=pskmod(data(:,nn),8,pi/8); end data_mapping=reshape(data_map,1,x*8); elseif Tx == 0; x2=length(data)/8; data=reshape(data,8,x2); for nn=1:x2; data_demap(:,nn)=pskdemod(data(:,nn),8,pi/8); end data_demap=reshape(data_demap,length(data_demap)*8,1); data_demap=de2bi(data_demap,3,'left-msb')'; data_mapping=reshape(data_demap,1,length(data_demap)*3); end
interleaving.m function [data_interleave] = interleaving(data_convolutional,nilai,Ncpc,Tx);
Universitas Sumatera Utara
switch Ncpc case 1 Ncbps=192; case 2 Ncbps=nilai; case 4 Ncbps=nilai; case 8 Ncbps=nilai; end
% for BPSK % for QPSK % for 16-QAM % for 64-QAM
s=ceil(Ncpc/2); if Tx==1 k = 0:Ncbps-1; mk = ((Ncbps/12)*mod(k,12))+floor(k/12); jk = s*floor(mk/s)+mod(mk+Ncbps-floor(12*mk/Ncbps),s); [a c] = sort(jk);
elseif Tx==0 j = 0:Ncbps-1; mj = s*floor(j/s) + mod((j + floor(12*j/Ncbps)),s); kj = 12*mj-(Ncbps-1)*floor(12*mj/Ncbps); [a c]= sort(kj); end
i = 1:Ncbps-1; data_interleave = zeros(1,Ncbps); data_interleave(i) = data_convolutional(c(i)); parameter_airlink.m function [preamble,mac,pilot,slot,data_rate,modulasi]=parameter_airlink(pb) switch pb case 1024 preamble = zeros(1,64); mac = 256; pilot = 192; slot = 1; data_rate = 614.4; case 2048 preamble = zeros(1,128); mac = 1024; pilot = 768; slot = 4; data_rate = 307.2; case 3072 preamble = zeros(1,64); mac = 512; pilot = 384; slot = 2; data_rate = 921.6; case 4096 preamble = zeros(1,64);
Universitas Sumatera Utara
mac = 512; pilot = 384; slot = 2; data_rate = 1228.8; end urutan slot.m function[data_slot]=urutan(preamble,data,slot) mac1=zeros(1,64); pilot1=zeros(1,96); urutan_pm=[mac1 pilot1 mac1]; panjang_data1 = 400-length(preamble); urutan_data1 = data(1,1:panjang_data1); panjang_data2=panjang_data1+1200; switch slot case 1 data_slot = [preamble urutan_data1 urutan_pm data(1,panjang_data1+1:panjang_data1+800) urutan_pm data(1,panjang_data1+801:panjang_data2)]; case 2 data_slot = [preamble urutan_data1 urutan_pm data(1,panjang_data1+1:panjang_data1+800) urutan_pm data(1,panjang_data1+801:panjang_data2) ... data(1,panjang_data2+1:panjang_data2+400) urutan_pm data(1,panjang_data2+401:panjang_data2+1200) urutan_pm data(1,panjang_data2+1201:panjang_data2+1600)]; case 4 data_slot = [preamble urutan_data1 urutan_pm data(1,panjang_data1+1:panjang_data1+800) urutan_pm data(1,panjang_data1+801:panjang_data2) ... data(1,panjang_data2+1:panjang_data2+400) urutan_pm data(1,panjang_data2+401:panjang_data2+1200) urutan_pm data(1,panjang_data2+1201:panjang_data2+1600) ... data(1,panjang_data2+1601:panjang_data2+2000) urutan_pm data(1,panjang_data2+2001:panjang_data2+2800) urutan_pm data(1,panjang_data2+2801:panjang_data2+3200) ... data(1,panjang_data2+3201:panjang_data2+3600) urutan_pm data(1,panjang_data2+3601:panjang_data2+4400) urutan_pm data(1,panjang_data2+4401:panjang_data2+4800)]; end ulang.m function [data]=ulang(data_transmit,repetisi) if repetisi == 1; data = data_transmit; elseif repetisi == 2.04 m=mod(6272,3072); data_tambah = data_transmit(1,1:m); data=[data_transmit data_transmit data_tambah]; elseif repetisi == 1.02; m=mod(3136,3072); data_tambah = data_transmit(1,1:m);
Universitas Sumatera Utara
data=[data_transmit data_tambah]; end urutanrx.m function[data_slotrx]=urutanrx(data_noise,slot,preamble) p=length(preamble); l=224; s=2*l+1600; switch slot case 1 data_slotrx = [data_noise(1,p+1:400) data_noise(1,625:1424) data_noise(1,1649:2048)]; case 2 data_slotrx = [data_noise(1,p+1:400) data_noise(1,625:1424) data_noise(1,1649:2048) ... data_noise(1,2049:2448) data_noise(1,2673:3472) data_noise(1,3697:4096)] ; case 4 data_slotrx = [data_noise(1,p+1:400) data_noise(1,625:1424) data_noise(1,1649:2048) ... data_noise(1,2049:2448) data_noise(1,2673:3472) data_noise(1,3697:4096) ... data_noise(1,4097:4496) data_noise(1,4721:5520) data_noise(1,5745:6144) ... data_noise(1,6145:6544) data_noise(1,6769:7568) data_noise(1,7793:8192)]; end bit_symbol.m function [alphabet] = bit_symbol(M,type,M1,M2) if strcmp(type,'QAM') k1 = ceil(log2(M1)); k2 = ceil(log2(M2)); M1 = 2^k1; M2 = 2^k2; M = M1*M2; Aicd = zeros(1,k1); Aisd = zeros(1,k2); table1 = zeros(M1,2); table2 = zeros(M2,2); alphabet = zeros(M,3); d1 = 0:1:M1-1; d1 = d1'; d2 = 0:1:M2-1; d2 = d2'; ind1 = bi2de(fliplr(gray2bi(fliplr(de2bi(d1))))); table1 = [d1,ind1+1]; ind2 = bi2de(fliplr(gray2bi(fliplr(de2bi(d2))))); table2 = [d2,ind2+1]; else k = ceil(log2(M));
Universitas Sumatera Utara
M = 2^k; Aicd = zeros(1,k); Aisd = zeros(1,k); table = zeros(M,2); % A table with indices alphabet = zeros(M,3); % Alphabet d = 0:1:M-1; d = d'; ind=bi2de(fliplr(gray2bi(fliplr(de2bi(d))))); table = [d,ind+1]; end if strcmp(type,'PAM') Aicd = -(M-1):2:M-1; Aisd = []; for i=1:M index = find_index(i-1,table); alphabet(i,:) = [i-1,Aicd(index),0]; end elseif strcmp(type,'MPSK') angle = 0:2*pi/M:2*pi*(M-1)/M; Aicd = cos(angle); Aisd = sin(angle); for i=1:M index = find_index(i-1,table); alphabet(i,:) = [i-1,Aicd(index),Aisd(index)]; end elseif strcmp(type,'QAM') Aicd = -(M1-1):2:M1-1; Aisd = (M2-1):-2:-(M2-1); for i=1:M1 for j=1:M2 index1 = find_index(i-1,table1); index2 = find_index(j-1,table2); l = i+M1*(j-1); alphabet(l,:) = [l-1,Aicd(index1),Aisd(index2)]; end end end function b = gray2bi( g ) gray2bi.m % copy the msb: b(:,1) = g(:,1); for i = 2:size(g,2), b(:,i) = xor( b(:,i-1), g(:,i) ); end return;
Universitas Sumatera Utara