20
BMS BMS (Bandwidth Management (Bandwidth Management System) System) Akses Internet Akses Internet Nyoman Bogi Nurul Fitria

Bandwidth Management System - Case Study

Embed Size (px)

DESCRIPTION

explain a case study of a Bandwidth Management System implementation in IMTelkom (http://www.imtelkom.ac.id) using FreeBSD

Citation preview

Page 1: Bandwidth Management System - Case Study

BMSBMS(Bandwidth Management (Bandwidth Management

System) System) Akses InternetAkses Internet

Nyoman BogiNurul Fitria

Page 2: Bandwidth Management System - Case Study

BMS (Bandwidth Management System) adalah suatu sistem untuk mengontrol penggunaan bandwidth agar efisien.

Mengapa perlu BMS ?Bandwidth sebagai suatu resource yang tidak tak terbatas dan tidak free, penggunaannya perlu dikontrol karena tingkat kepentingan suatu trafik dan user berbeda-beda.

Apa yang bisa dilakukan BMS ? membagi bandwidth berdasarkan IP address user

membagi bandwidth berdasarkan port aplikasi meminjamkan idle bandwidth ke user/aplikasi yang lain mengantrikan trafik saat peak time sesuai prioritasnya

Apa itu BMS ?

Page 3: Bandwidth Management System - Case Study

Ada beberapa alasan mengapa BMS dibutuhkan di IM Telkom:

1. Pimpinan dan dosen/staf membutuhkan jaminan bandwidth saat jam kerja

2. Mahasiswa dapat menggunakan idle bandwidth diluar jam kerja pimpinan/dosen/staf

3. Dengan banyaknya aplikasi download, user yang menggunakan aplikasi download ini dapat merebut jatah bandwidth sebanyak banyaknya dan tidak terkontrol. Adanya BMS, sistem antrian menyebabkan setiap user dalam kelas yg sama akan mendapat jatah bandwidth yg sama

4. Pengontrolan port aplikasi akan dapat mengatur penggunaan streaming multimedia

Mengapa IM Telkom perlu BMS ?

Page 4: Bandwidth Management System - Case Study

BMS diimplementasikan pada link Internet karena sifatnya yang terbatas (hanya 2Mbps) namun memiliki utilitas yang sangat tinggi (semua user ingin koneksi ke Internet).Di IM Telkom agar dapat terkoneksi ke Internet, user harus terlebih dahulu login menggunakan VPN (autentikasi user) dan selanjutnya menggunakan proxy (accounting dan web caching) untuk dapat browsing ke Internet, maka implementasi BMS harus disesuaikan dengan kondisi tersebut.

Implementasi BMS di IM TelkomPendahuluan

Page 5: Bandwidth Management System - Case Study

MPD (VPN) IPFWPF SQUID (PROXY)

Pipe 1 (Pimpinan)

Pipe 3(Mahasiswa)

Pipe 2 (Dosen TPA)

SQUID

1 2

3 4

5MPD

USERINTERNET

ALTQCBQ

MYSQL

PHP

Graphic Interface

6

7

8

Implementasi BMS di IM TelkomDiagram Blok

Page 6: Bandwidth Management System - Case Study

1. Pengujian bandwidth untuk masing masing kelas Skenario X.1.1 Kelas1download Kelas 2 + Kelas 3

idle Skenario X.1.2 Kelas 2 download Kelas 1 + Kelas 3

idle Skenario X.1.3 Kelas 1 + kelas 2 idle Kelas 3 download 2. Pengujian proses peminjaman bandwidth Skenario X.2.1 Kelas 1 idle Kelas 2 + Kelas 3 download

Skenario X.2.2 Kelas 2 idle Kelas 1 + kelas 3

download Skenario X.2.3 Kelas 3 idle Kelas 1 + kelas 2

download Skenario X.2.4 Kelas 1 + Kelas 2 + Kelas 3 download3. SQUID (Skenario A.3) Pengaruh ke jumlah Hit / Miss di access.log.4. Processor dan memory server (Skenario A.4) Analisa jumlah proses yang ada disistem, status penggunaan CPU, dan status penggunaan memory.

Analisa BMS di IM TelkomSkenario

Page 7: Bandwidth Management System - Case Study

Gambar 4.1 Trafik Pimpinan

Gambar 4.2 Trafik Pegawai

Gambar 4.3 Trafik Mahasiswa

Analisa BMS di IM TelkomAnalisa Trafik

Page 8: Bandwidth Management System - Case Study

Gambar 4.4 Trafik Pimpinan untuk proses peminjaman bandwidth

Gambar 4.5 Trafik Pegawai untuk proses peminjaman bandwidth

Gambar 4.6 Trafik Mahasiswa untuk proses peminjaman bandwidth

Analisa BMS di IM TelkomAnalisa Trafik

Page 9: Bandwidth Management System - Case Study

Analisa BMS di IM TelkomAnalisa System

Gambar 4.7. Grafik Persentase Hit

suatu object ada di web cache

Gambar 4.9. Grafik Persentase utilitas CPU Total dan utilitas SQUID di server

Gambar 4.8. Grafik Jumlah Proses

yang running di server

Gambar 4.10. Grafik Persentase Utilitas Memory di server

Page 10: Bandwidth Management System - Case Study

Kesimpulan

• Dengan bandwidth management CBQ, besar bandwidth untuk masing masing kelas dapat terbagikan. Artinya dalam men-download file masing masing kelas tidak saling berebutan pemakaian bandwidthnya.

• Begitu juga dengan proses peminjaman bandwidth, CBQ mampu melakukannya. Besar bandwidth dari kelas yang idle, dapat dipinjamkan sementara oleh kelas lainnya.

• Penerapan Bandwidth management ini tidak berpengaruh terhadap :• jumlah Hit/Miss di access.log proxy server• jumlah proses server yang running di server • persentase utilitas memory di server

Page 11: Bandwidth Management System - Case Study

ext_if = "fxp0“

altq on $ext_if cbq bandwidth 10240Kb queue { deflt, bms }queue deflt bandwidth 80% cbq(default)queue bms bandwidth 20% cbq(borrow red) { pimpinan , staf , mahasiswa }queue pimpinan bandwidth 12.5% priority 1 cbq(borrow red)queue staf bandwidth 25% priority 2 cbq(borrow red)queue mahasiswa bandwidth 62.5% priority 3 cbq(borrow red)

pass in on $ext_if inet proto tcp from 172.16.1.0/24 to 172.16.1.1 port 8080 keep state queue pimpinanpass in on $ext_if inet proto tcp from 172.16.5.0/24 to 172.16.1.1 port 8080 keep state queue stafpass in on $ext_if inet proto tcp from 172.16.10.0/21 to 172.16.1.1 port 8080 keep state queue mahasiswapass in on $ext_if inet proto tcp from 172.16.16.0/20 to 172.16.1.1 port 8080 keep state queue mahasiswapass out on $ext_if inet proto tcp from any to any keep statepass in on $ext_if inet proto tcp from any to any keep statepass out on $ext_if inet all keep statepass in on $ext_if inet proto tcp from 172.16.3.0/24 to 172.16.1.1 port 8080 keep state queue mahasiswapass out on $ext_if inet proto tcp from any to any port 22 keep statepass in on $ext_if inet proto tcp from any to any port 22 keep statepass out on $ext_if inet all keep state

Lampiran/etc/pf.conf

Page 12: Bandwidth Management System - Case Study

*/5 * * * * /root/update_traffic_counter.sh*/5 * * * * /root/update_system_status.sh

Keterangan : system menjalankan program shell script tersebut secara otomatis setiap 5 menit sekali

Lampirancrontab

Page 13: Bandwidth Management System - Case Study

#!/bin/sh/usr/bin/top -u -d1 > ./top1.txt/usr/bin/top -u -d2 > ./top2.txtPROCESS=`/bin/cat ./top1.txt | /usr/bin/grep 'processes' | /usr/bin/awk '{print $1}'`CPU=`/bin/cat ./top2.txt | /usr/bin/grep 'CPU states' | /usr/bin/awk '{print $11}'`MEM_A=`/bin/cat ./top1.txt | /usr/bin/grep 'Mem' | /usr/bin/awk '{print $2}'`MEM_I=`/bin/cat ./top1.txt | /usr/bin/grep 'Mem' | /usr/bin/awk '{print $4}'`MEM_W=`/bin/cat ./top1.txt | /usr/bin/grep 'Mem' | /usr/bin/awk '{print $6}'`MEM_C=`/bin/cat ./top1.txt | /usr/bin/grep 'Mem' | /usr/bin/awk '{print $8}'`MEM_B=`/bin/cat ./top1.txt | /usr/bin/grep 'Mem' | /usr/bin/awk '{print $10}'`MYSQLD=`/bin/cat ./top1.txt | /usr/bin/grep 'mysqld' | /usr/bin/awk '{print $10}'`SQUID=`/bin/cat ./top1.txt | /usr/bin/grep 'squid' | /usr/bin/awk '{print $10}'`MPD=`/bin/cat ./top1.txt | /usr/bin/grep 'mpd' | /usr/bin/grep -v 'snmpd' | /usr/bin/awk '{print $10}'`HTTPD=`/bin/cat ./top1.txt | /usr/bin/grep 'httpd' |/usr/bin/awk '{print $10}'`VPN=`/sbin/ifconfig | /usr/bin/grep -c '172.16'`TODAY=`date "+%Y%m%d%H%M"`

/usr/local/bin/mysql -u user -ppassword -Dstatus --execute="insert into system_status set time=${TODAY},process='${PROCESS}',cpu='${CPU}',mem='${MEM_A}',mem_inact='${MEM_I}',mem_wired='${MEM_W}',mem_cache='${MEM_C}',mem_buf='${MEM_B}',mysqld=left('${MYSQLD}',locate('%','${MYSQLD}')),squid=left('${SQUID}',locate('%','${SQUID}')),mpd=left('${MPD}',locate('%','${MPD}')),httpd=left('${HTTPD}',locate('%','${HTTPD}')),vpn='${VPN}'"

/usr/local/bin/php /root/cpu.php/usr/local/bin/php /root/memory.php/usr/local/bin/php /root/service.php/usr/local/bin/php /root/vpn.php

Lampiran Scriptupdate_system_status.sh

Page 14: Bandwidth Management System - Case Study

<?phpfunction graph() {$arg=func_num_args();$filename=func_get_arg(0);$x=func_get_arg(1);if ($arg>=3) $y1=func_get_arg(2);if ($arg>=4) $y2=func_get_arg(3);if ($arg>=5) $y3=func_get_arg(4);if ($arg>=6) $y4=func_get_arg(5);if ($arg>=7) $y5=func_get_arg(6);$total_data_x=count($x)-1;$total_data_y=count($y1)-1;if ($total_data_x!=$total_data_y) {return ("number of x values must be the same with y values");}$total_data=$total_data_x;

header("Content-type: image/png");$imgWidth=600;$imgHeight=170;

$image=imagecreate($imgWidth, $imgHeight);$colorWhite=imagecolorallocate($image, 255, 255, 255);$colorGrey=imagecolorallocate($image, 220, 220, 220);$colorBlack=imagecolorallocate($image, 0, 0, 0);$colorDarkBlue=imagecolorallocate($image, 0, 0, 196);$colorLightBlue=imagecolorallocate($image, 184, 212, 250);$colorRed=imagecolorallocate($image, 255, 0, 0);$colorGreen=imagecolorallocate($image, 0, 196, 0);$colorYellow=imagecolorallocate($image, 200, 200, 0);$colorMagenta=imagecolorallocate($image, 0, 200, 200);

$offset_x=50;$offset_y=40;imagefilledrectangle($image, $offset_x, $offset_y, $offset_x+440, $offset_y+100, $colorWhite);

$interval=floor(440/$total_data);$j=0;for ($i=1; $i<=$total_data; $i++){ if (!strcmp(substr($x[$i],10,2),"00")) { imagedashedline($image, $offset_x+($i*$interval), $offset_y+4, $offset_x+($i*$interval), $offset_y+96, $colorGrey); $j=$j+1; if (($j%2)==1) { imagestringup($image, 1, $offset_x+($i*$interval)-3, $offset_y+125, substr($x[$i],8,2).'.00', $colorBlack); } } }

Lampiran Scriptgraph.php (part 1)

Page 15: Bandwidth Management System - Case Study

Lampiran Scriptgraph.php (part 2)

$max_y=0;for ($i=1; $i<=$total_data; $i++){ if ($arg>=3) if ($max_y<$y1[$i]) {$max_y=$y1[$i];} if ($arg>=4) if ($max_y<$y2[$i]) {$max_y=$y2[$i];} if ($arg>=5) if ($max_y<$y3[$i]) {$max_y=$y3[$i];} if ($arg>=6) if ($max_y<$y4[$i]) {$max_y=$y4[$i];} if ($arg>=7) if ($max_y<$y5[$i]) {$max_y=$y5[$i];}}$max_y=ceil($max_y/25)*25;if ($max_y==0) $max_y=100;for ($i=1; $i<4; $i++){ imageline($image, $offset_x+4, $offset_y+($i*100/4), $offset_x+436, $offset_y+($i*100/4), $colorGrey);}imagestring($image, 1, $offset_x-10, 138, 0, $colorBlack);imagestring($image, 1, $offset_x-15, 88, $max_y/2, $colorBlack);imagestring($image, 1, $offset_x-20, 38, $max_y, $colorBlack);

imagestring($image, 3, $offset_x, $offset_y-30, $x[0], $colorBlack);

if ($arg>=3) { for ($i=2; $i<=$total_data; $i++) imageline($image, $offset_x+($i*$interval), $offset_y+100-round($y1[$i]/$max_y*100), $offset_x+(($i-1)*$interval),$offset_y+100-round($y1[$i-1]/$max_y*100), $colorRed); imagefilledrectangle($image, $offset_x+450, $offset_y+10, $offset_x+455, $offset_y+15, $colorRed); imagestring($image, 1, $offset_x+460, $offset_y+9, $y1[0], $colorBlack);}

if ($arg>=4) { for ($i=2; $i<=$total_data; $i++) imageline($image, $offset_x+($i*$interval), $offset_y+100-round($y2[$i]/$max_y*100), $offset_x+(($i-1)*$interval),$offset_y+100-round($y2[$i-1]/$max_y*100), $colorGreen); imagefilledrectangle($image, $offset_x+450, $offset_y+25, $offset_x+455, $offset_y+30, $colorGreen); imagestring($image, 1, $offset_x+460, $offset_y+24, $y2[0], $colorBlack);}

Page 16: Bandwidth Management System - Case Study

Lampiran Scriptgraph.php (part 3)

if ($arg>=5) { for ($i=2; $i<=$total_data; $i++) imageline($image, $offset_x+($i*$interval), $offset_y+100-round($y3[$i]/$max_y*100), $offset_x+(($i-1)*$interval),$offset_y+100-round($y3[$i-1]/$max_y*100), $colorDarkBlue); imagefilledrectangle($image, $offset_x+450, $offset_y+40, $offset_x+455, $offset_y+45, $colorDarkBlue); imagestring($image, 1, $offset_x+460, $offset_y+39, $y3[0], $colorBlack);}

if ($arg>=6) { for ($i=2; $i<=$total_data; $i++) imageline($image, $offset_x+($i*$interval), $offset_y+100-round($y4[$i]/$max_y*100), $offset_x+(($i-1)*$interval),$offset_y+100-round($y4[$i-1]/$max_y*100), $colorYellow); imagefilledrectangle($image, $offset_x+450, $offset_y+55, $offset_x+455, $offset_y+60, $colorYellow); imagestring($image, 1, $offset_x+460, $offset_y+54, $y4[0], $colorBlack);}

if ($arg>=7) { for ($i=2; $i<=$total_data; $i++) imageline($image, $offset_x+($i*$interval), $offset_y+100-round($y5[$i]/$max_y*100), $offset_x+(($i-1)*$interval),$offset_y+100-round($y5[$i-1]/$max_y*100), $colorMagenta); imagefilledrectangle($image, $offset_x+450, $offset_y+70, $offset_x+455, $offset_y+75, $colorMagenta); imagestring($image, 1, $offset_x+460, $offset_y+69, $y5[0], $colorBlack);}

imagepng($image, $filename);

imagedestroy($img);imagedestroy($image);

}

?>

Page 17: Bandwidth Management System - Case Study

<?phpinclude("graph.php");$link=mysql_connect("localhost",“user",“password");$result=mysql_query("select count(*) from status.system_status",$link);$jml_data=mysql_fetch_row($result);mysql_free_result($result);$jml_data[0]=$jml_data[0]-440;

$result1=mysql_query("select time,mem,mem_inact,mem_wired,mem_cache,mem_buf from status.system_status order by nomor asc limit $jml_data[0],440",$link);$x=array(0); $x[0] ='Persentase Utilitas Memory';$y1=array(0);$y1[0]='Active Memory';$y2=array(0);$y2[0]='Inactive Memory';$y3=array(0);$y3[0]='Wired Memory';$y4=array(0);$y4[0]='Cache Memory';$y5=array(0);$y5[0]='Buffer Memory';$max_mem=2500;for ($i=1; $i<=440; $i++){ $row=mysql_fetch_row($result1); $x[]=$row[0]; $y1[]=floor(100*$row[1]/$max_mem); $y2[]=floor(100*$row[2]/$max_mem); $y3[]=floor(100*$row[3]/$max_mem); $y4[]=floor(100*$row[4]/$max_mem); $y5[]=floor(100*$row[5]/$max_mem);}mysql_close($link);mysql_free_result($result1);$filename="memory.png";graph($filename,$x,$y1,$y2,$y3,$y4,$y5);?>

Lampiran Scriptmem.php

Page 18: Bandwidth Management System - Case Study

<?phpinclude("graph.php");$link=mysql_connect("localhost",“user",“password");$result=mysql_query("select count(*) from status.system_status",$link);$jml_data=mysql_fetch_row($result);mysql_free_result($result);$jml_data[0]=$jml_data[0]-440;

$result1=mysql_query("select time,cpu from status.system_status order by nomor asc limit $jml_data[0],440",$link);$x=array(0); $x[0] ='Persentase Utilitas CPU';$y1=array(0);$y1[0]='CPU usage';

for ($i=1; $i<=440; $i++){ $row=mysql_fetch_row($result1); $x[]=$row[0]; $y1[]=100-$row[1];}mysql_close($link);mysql_free_result($result1);

$filename="cpu.png";graph($filename,$x,$y1);?>

Lampiran Scriptcpu.php

Page 19: Bandwidth Management System - Case Study

#!/bin/shTODAY=`date "+%Y%m%d%H%M"`SQUID="/usr/local/sbin/squid"SQUID_OPTION="-f /usr/local/etc/squid/squid.conf -k rotate"TEMP_FOLDER="/data/log"

/bin/cat /usr/local/squid/logs/access.log.0 | /usr/bin/grep 'MISS' | /usr/bin/awk '{print $3 "\t" $5}' > ${TEMP_FOLDER}/usage.txtHIT=`/bin/cat /usr/local/squid/logs/access.log.0 | /usr/bin/grep -c 'HIT'`MISS=`/bin/cat /usr/local/squid/logs/access.log.0 | /usr/bin/grep -c 'MISS'`OTHER=`/bin/cat /usr/local/squid/logs/access.log.0 | /usr/bin/grep -v 'HIT' | /usr/bin/grep -v 'MISS' | /usr/bin/grep -c ''`

Lampiran Scripthitmiss.sh

Page 20: Bandwidth Management System - Case Study

http://www.imtelkom.ac.id