Skip to main content

the avatar of Klaas Freitag

Cross platform again

Writing cross platform code is easy nowadays. You use Qt, implement stuff, and it compiles and runs almost everywhere. I also enjoy that in my work on the ownCloud desktop client. But, as you know, there is the other part in the client called csync. Its the syncing engine underneath. And that does not build up on Qt, but is plain C. Adventure starts here.

This bug took me on an interesting (well…) journey into what cross platform really means.It is about a complex thing like filenames containing special characters, my favorite example is the directory “Übergröße”. Directories and files like this could not successfully be synced with the latest client.

Windows does not utf8 by default. As far as I understood it, it does a local encoding by default. If you use normal C functions to access the filesystem, something like readdir or so, you get the names in that encoding. But, because that caused problems in some point, there is another set of functions which often start with _w (for example _wreaddir) and that has an interface to deal with wide characters. This is the way to internationalization.

So what needs to be done is to use the wide character implementations everywhere where you deal with filenames (in my case). That, in turn, requires to use wchar_t instead of normal char. But that again requires a lot of #ifdef _WIN32, if its done the naive way at every place it needs to be done. I learned that typedef helps here and a meta type is defined called _TCHAR. And also for all the needed functions, meta functions are defined which are replaced by tricky defines depending on the platform. For example _treaddir becomes readdir on linux and _wreaddir on win32, while _TCHAR becomes wchar_t on Win and char on linux. The code is written using the meta types to not poison it too much with platform ifdefs.

But that is only the first step. Wide character is not utf8! And since utf8 should be used within the software all over, a conversion from wide character to utf8 and back is needed whenever the file system is accessed. Thankfully from csyncs nature, these places are quite nicely concentrated.

All that combines into a larger patch. And now the “Übergröße” folder can be synced correctly from Windows to Linux and back. Great.

What can we learn from that? Well, easy, and once again: If you have no Qt, you’re alone. Better don’t let that happen. If you have Qt, be happy and aware of what it does for you :-)

a silhouette of a person's head and shoulders, used as a default avatar

Apper

Some applications seems unlucky to find their way in the hearts their intended users.

Reading today  thread  "What does this error message mean?", I can see Apper sinking another few notches.

Is it Apper's fault?

The answer is not, but being visible component that appears when disharmony in software management shows up, it can fall as a victim. Use Google to find out about "opensuse apper" and you can read about a lot of problems, and advice to remove it was given so many times that new user has no problem to find it. 

Do we need simpler software management?
For sure, yes. YaST module Software Management is old guy that is exactly what old Linux users need, versatile tools for software management, not simple install or remove software  utility that we can see in some popular distros. But, times are changing, old, technically inclined computer users that were almost only Linux users are now in minority, and new generation wants to use computers, not to deal with them.

the avatar of Pascal Bleser

Speaking of Packman mirrors...

Speaking of Packman mirrors... we're in a pretty sorry state regarding that so if you're aware of sites that do mirror Packman but never told us (I'm aware of the one at yandex.ru, have to get it on that mirror list), or if you can get in touch with some mirror sites near you or even on your continent to ask them to mirror Packman, please do.

They can then simply contact us on our mailing-list (that's packman followed by an "at" sign followed by "links2linux" and a dot and "de" -- grrr to spammers) and we'll get back to them with the details for rsync.

the avatar of Pascal Bleser

packman.inode.at mirror is down

The Packman mirror at packman.inode.at is down. We don't know yet what happened nor whether it will be back up soon (or not).

In the mean time, please use another mirror in the mean time.

Here's a quick copy'n'paste one-liner you can put in a shell (konsole, gnome-terminal, xterm, urxvt, ...) as root to switch:

perl -p -i.old -e \
's,^(baseurl=).*(/suse/.+)$,${1}http://ftp.halifax.rwth-aachen.de/packman${2}, if /^baseurl=.*packman\.inode\.at.*/' \
/etc/zypp/repos.d/*packman*.repo

the avatar of Andrés G. Aragoneses

Apple and LastFM can still receive open source love

Here we are in an era in which ad-based services (like LastFM) and closed-products (like Apple ones) are on the rise.

But contradicting what you may think, open source is still friendly to them.

If you have an Apple device supported by libgpod* and you're an avid user of LastFM's scrobbling feature, you can today configure Banshee to send all the songs that were played on your device to your LastFM account the next time you connect your device while you have Banshee running.

Pretty handy, especially if you own a device that doesn't have internet connection these days (something definitely not on the rise). You should thank our new Banshee developer Phil Trimble for doing an awesome job on implementing this feature (and on resisting to not sending me to hell when I made the patch reviews...).

The next version of Banshee, in the 2.5.x series, should include this feature. Until then, hold on to your seats! (or compile it yourself from master ;) )

* Beware: not the last generation ones! you would have to donate to libgpod project if you want those recognised.

PS: If you're a developer and want to extend this feature to other kind of devices, you should just implement the interface IBatchScrobblerSource in the corresponding Source class of your device. If you want to make it scrobble to a different service than LastFM, just create a Banshee addin (simple sample here) that subscribes to the ServiceManager.SourceManager.SourceAdded event to then later subscribe to the IBatchScrobbleSource.ReadyToScrobble event from it, to later make the corresponding HttpWebRequests to the scrobbling service.

the avatar of Medwinz's Notes

Ini Adalah Sebuah Proses

Setelah sekian lama tidak menulis, saya beranikan untuk menulis lagi walau kali ini mungkin tulisan saya terkesan berkeluh kesah :-) Saya memang menghindari menulis di blog ini selama beberapa waktu, terakhir sekitar bulan Maret 2011 saat openSUSE 11.4 dirilis. Sekarang 12.1 sudah rilis ya kemarin. Kudos to all. Ya memang ada beberapa perubahan mendasar seperti systemd, silakan dibaca-baca dulu dari sumber-sumber di internet apa sih systemd itu (just search in google, o iya thanks to Lennart Poettering and Kay Sievers for the breakthrough and brave move!).

Back to the laptop eh.. subyek ... whatever it is, saya tidak menulis karena saya takut suasana pekerjaan saya mempengaruhi tulisan saya. Iya kali ini pekerjaan saya menguras emosi dan logika saya he..he...he... Sebagai seorang "opensource believer" yang dapat kerjaan untuk menyebarkannya di kalangan pendidikan dasar dan menengah ternyata membuat saya hampir putus asa. Hanya kesadaran bahwa apa yang saya lakukan ini mungkin bisa dinilai Tuhan sebagai amal jariah agar anak-anak dan adik-adik kita menjadi generasi yang lebih baik dari generasi saya yang membuat saya tetap bertahan. Dan mungkin juga karena saya seorang pemimpi that just want to make my dream come true :-)

Saya bolak-balik Jakarta dan tempat kerja saya, about 600 km several times in a month. Seringkali saya menemukan hal-hal yang tidak sesuai dengan hati kecil saya. Dalam satu acara, seorang pendidik mempresentasikan hasil kerjanya yang penuh dengan "right to copy" tanpa memperhatikan aspek legalitas suatu karya. Saya katakan mohon jika mengutip pekerjaan orang lain pelajari dulu lisensinya, proprietary, gpl, Creative Commons Attribution-Share Alike atau apa? Kita sering menyalahkan orang melakukan korupsi atau menghakimi orang yang mencuri, tetapi kita membiasakan diri melakukannya dan memberi contoh kepada anak didik mengenai pencurian hak cipta. What a mess :-( Mengapa berlaku jujur menjadi suatu hal yang sulit dilakukan?

Saya juga agak kecewa ketika membaca adanya pelajaran yang kurikulumnya disusun oleh Kementerian Pendidikan dan menyebutkan penggunaan software proprietary dengan gamblang. Kenapa kita selalu terjebak dengan hal-hal yang membuat hidup ini seperti tidak ada pilihan. Berikanlah kebebasan atas pilihan-pilhan dalam hidup ini, niscaya orang akan bertanggungjawab terhadap pilihan yang mereka lakukan. Ketika tahun 2009 saya ditawari pekerjaan ini sebenarnya pada saat yang sama ada satu tawaran dari sebuah perusahaan high-tech multinasional bermarkas di Eropa pada saya yang kalau dilihat dari sisi finansial berkali lipat besarnya. Saat itu saya menolaknya dengan pertimbangan kapan lagi saya bisa menyumbangkan sesuatu bagi perkembangan opensource sekaligus memberikan sumbangsih bagi kemajuan pendidikan di Indonesia. Tetapi sekarang saya kadang merasa mungkin pilihan saya waktu itu salah, saya agak frustasi dengan kondisi implementasi, kemampuan dan kemauan guru untuk menggunakan opensource, serta yang paling berat adalah kurikulum yang terasa tidak pro opensource. Saya merasa tidak akan berhasil.

Saat ini saya belum menyerah, bulan-bulan ke depan ini akan menjadi bulan-bulan yang sibuk. Kita akan melanjutkan implementasi di lebih dari 200 sekolah, menyempurnakan pusat data dan memperbaiki kondisi koneksi ke pusat data. Semangat harus dikumpulkan, logika dan emosi harus dijaga ketahanannya, hampir setiap hari saya jogging untuik mengimbangi this turbulence condition. Tidak mudah mencapai suatu tujuan, ini adalah sebuah proses.
the avatar of Medwinz's Notes

Proyek Penerjemahan Dokumentasi openSUSE

Mengingat pengguna openSUSE di Indonesia yang semakin lama semakin banyak jumlahnya, Andi Sugandi, Ketua openSUSE-Indonesia, dan saya terlibat dalam suatu diskusi kecil melalui email dan twitter untuk coba mengangkat kemungkinan menterjemahkan dokumentasi openSUSE ke dalam Bahasa Indonesia. Secara infrastruktur pihak openSUSE, melalui Frank Sundermeyer sebagai dokumenter openSUSE juga sudah menyediakan fasilitas svn untuk proyek ini dalam server svn mereka.

Tentu saja saya membutukan banyak bantuan dan kontribusi dari rekan-reakan sekalian. Jadi sekiranya anda menguasai Bahasa Inggris setidaknya pasif, ada keinginan untuk berkontribusi, punya waktu, dan komitmen memajukan openSUSE di Indonesia, maka anda bisa bergabung ke dalam tim ini. Mengenai hal teknis, bagaimana cara penerjemahannya, bagaimana pembagian kerjanya, tools apa yang dipakai nanti akan kita jelaskan melalui online meeting melalui IRC dan tulisan di blog setelah ada rekan-rekan yang tertarik terlibat. Anda tidak perlu punya pengalaman lain selain hal yang disebutkan di atas untuk dapat bergabung ke dalam proyek ini. Tentu saja kalau anda pengguna openSUSE dan biasa menggunakan emacs, vim atau jedit tentu akan menjadi nilai lebih.

Perlu ditegaskan di sini tidak ada imbalan materi apapun yang akan anda perloleh dalam proyek ini, jadi anda akan bekerja berdasarkan kesadaran bahwa anda membagikan kebahagiaan menggunakan openSUSE kepada orang lain. Tentu saja kami akan memberikan kredit dan menuliskan nama anda dalam tim penerjemah pada dokumen yang dibuat.

Jika berminat segera daftarkan diri anda melalui email ke andisugandi@opensuse.org dan cc ke medwin@opensuse.org, dengan subyek : tim penerjemah dokumentasi openSUSE dan mencantumkan nama, umur, lokasi/tempat tinggal, YM, irc nick/cloack, twitter,
Kami tunggu partisipasi anda semua.

Have a lot of fun
the avatar of Medwinz's Notes

Bandwidth Shaper Script di openSUSE



# Tulisan ini digunakan sebagai bahan dasar saja untuk memahami
# Dibuat sudah lama sekali dan mungkin ada yang deprecated
# Use at your own risk

Seorang rekan menanyakan kenapa mengkonfigurasi openSuSE koq susah sekali. Katanya untuk ngejalanin script sederhana membuat default route aja musti ngebuat script yang njlimet. He…he..he….
Dia bilang kalau di RedHat dan turunannya seperti Fedora dan Centos khan ada rc.local, terus kalau di openSUSE padanannya apa?

OK. Sebetulnya masalah ini sudah pernah saya bahas diblog saya yang dulu dan dibeberapa email saya tapi tak mengapa saya ulang lagi di sini dan saya tambahkan beberapa hal yang saya anggap relevan karena kebetulan ada juga yang nanya tentang load balancing trafik internet ke dua gateway dan implementasi htb (hierarchical tocken bucket) untuk traffic shaping.

Jadi saya akan menjelaskan implementasi load balancing, traffic shaping dan rc.local di openSuSE sekaligus, mumpung lagi ada kesempatan nulis.


LOAD BALANCING TRAFIK INTERNET

Di tempat saya koneksi internet terhubung ke dua ISP, LC 128 kbps ke ISP-A dan ADSL ke ISP-B. Singkat cerita saya menggunakan sebuah server dengan 3 ethernet card

eth0 ip address 202.158.xx.yyy netmask 255.255.255.240 gw 202.158.xx.yyy
eth1 ip address 10.0.50.5 netmask 255.255.255.248 gw 10.0.50.1
eth2 ip address 192.168.117.171 netmask 255.255.255.0 gw 192.168.117.171

Untuk load balancing trafik ini saya mengacu pada dokumen LARTC (Linux Advanced Routing & Traffic Control) How To yang disusun oleh Bert Hubert (thanks Om Bert). Syarat untuk load balancing adalah sudah terinstallnya paket iproute2, yang sudah terinstall saat saya menginstall openSUSE 10.3.

Selanjutnya

# pertama hapus semua default route dari ip route
#
ip route del default
ip route del 10.0.50.0/29
ip route del 202.158.xx.zzz/28
ip route del 169.254.0.0/16

# tambah ip route yang masuk akal
#

ip route add 10.0.50.0/29 dev eth1 proto kernel scope link src 10.0.50.5
ip route add 202.158.xx.zzz/28 dev eth0 proto kernel scope link src 202.158.xx.xxx

# tambah juga load balancing default route (ip router anda)
# weight menandakan mana yang lebih anda pilih, 2 > 1
ip route add default scope global \
nexthop via 202.158.xx.yyy dev eth0 weight 1 \
nexthop via 10.0.50.1 dev eth1 weight 2

# tambah table policy routing
#
ip route add via 202.158.xx.yyy dev eth0 src 202.158.xx.xxx table ISP-A
ip route add via 10.0.50.1 dev eth1 src 10.0.50.5 table ISP-B

# ini musti ditest sometimes we need this
ip route add 192.168.117.0/24 dev eth4 table ISP-A
ip route add 10.0.50.0/29 dev eth1 table ISP-A
ip route add 127.0.0.0/8 dev lo table ISP-A
ip route add 192.168.117.0/24 dev eth4 table ISP-B
ip route add 202.158.xx.yyy/28 dev eth0 table ISP-B
ip route add 127.0.0.0/8 dev lo table ISP-B

# jangan lupa setup dua ip rule agar sistem menggunakan policy routing diatas
#
ip rule add from 202.158.xx.xxx table ISP-A
ip rule add from 10.0.50.5 table ISP-B

# setting IP masquerade
#
iptables -t nat -A POSTROUTING -s 192.168.117.0/24 -d 0/0 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.117.0/24 -d 0/0 -o eth1 -j MASQUERADE

# set TOS field agar router gak bingung, supaya ssh dan ftp bisa jalan

iptables -t mangle -A PREROUTING -j TOS –set-tos 0x00
iptables -t mangle -A OUTPUT -j TOS –set-tos 0x00

perlu diingat bahwa balancing disini tidak sempurna, karena route based, dan routes di-cache. Jadi route ke site yang sering dikunjungi akan selalu melaui provider yang sama.
Contoh di server ini kalau saya traceroute www.detik.com akan selalu lewat ISP-A dan traceroute www.republika.co.id akan selalu melalui ISP-B.


TRAFFIC SHAPING

Tujuan traffic shaping di sini adalah (tentu saja anda bisa melakukan shaping dengan tujuan lain he..he…he..):
- menjaga low latency untuk interactive trafic, jangan sampai upload atau download mengganggu ssh.
- menjaga agar browsing berjalan pada reasonable speeds sementara melalukan up atau downloading.
- menjaga agar upload tidak mengganggu download dan sebaliknya.
- menandakan port atau host yang sering memakan traffic sebagai low priority.

Ada banyak sumber di intenet misalnya tulisan ini dan favorit saya adalah sekali lagi om Bert dengan dokumen LARTC. Jangan lupa baca pre-requisites untuk menjalankan HTB dan pastikan kernel anda mendukungnya.

Implementasi di tempat saya sederhana saja seperti di bawah:

untuk eth0 dan eth1:

DOWNLINK=96 # untuk eth0, untuk eth1 –> DOWNLINK=288
UPLINK=80 # untuk eth0, untuk eth1 –> UPLINK=20
DEV=eth0 # ganti dengan eth1 untuk eth1

# low priority OUTGOING traffic - you can leave this blank if you want
# low priority source netmasks
NOPRIOHOSTSRC=

# low priority destination netmasks
NOPRIOHOSTDST=

# low priority source ports
NOPRIOPORTSRC=

# low priority destination ports
NOPRIOPORTDST=

if [ "$1" = "status" ]
then
tc -s qdisc ls dev $DEV
tc -s class ls dev $DEV
exit
fi

# clean existing down- and uplink qdiscs, hide errors
tc qdisc del dev $DEV root 2> /dev/null > /dev/null
tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null

if [ "$1" = "stop" ]
then
exit
fi

###### uplink

# install root HTB, point default traffic to 1:20:

tc qdisc add dev $DEV root handle 1: htb default 20

# shape everything at $UPLINK speed - this prevents huge queues in your
# DSL modem which destroy latency:

tc class add dev $DEV parent 1: classid 1:1 htb rate ${UPLINK}kbit burst 6k

# high prio class 1:10:

tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${UPLINK}kbit \
burst 6k prio 1

# bulk & default class 1:20 - gets slightly less traffic,
# and a lower priority:

tc class add dev $DEV parent 1:1 classid 1:20 htb rate $[9*$UPLINK/10]kbit \
burst 6k prio 2

tc class add dev $DEV parent 1:1 classid 1:30 htb rate $[8*$UPLINK/10]kbit \
burst 6k prio 2

# all get Stochastic Fairness:
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10

# TOS Minimum Delay (ssh, NOT scp) in 1:10:

tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 \
match ip tos 0x10 0xff flowid 1:10

# ICMP (ip protocol 1) in the interactive class 1:10 so we
# can do measurements & impress our friends:
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 \
match ip protocol 1 0xff flowid 1:10

# To speed up downloads while an upload is going on, put ACK packets in
# the interactive class:

tc filter add dev $DEV parent 1: protocol ip prio 10 u32 \
match ip protocol 6 0xff \
match u8 0x05 0x0f at 0 \
match u16 0x0000 0xffc0 at 2 \
match u8 0x10 0xff at 33 \
flowid 1:10

# rest is ‘non-interactive’ ie ‘bulk’ and ends up in 1:20

# some traffic however suffers a worse fate
for a in $NOPRIOPORTDST
do
tc filter add dev $DEV parent 1: protocol ip prio 14 u32 \
match ip dport $a 0xffff flowid 1:30
done

for a in $NOPRIOPORTSRC
do
tc filter add dev $DEV parent 1: protocol ip prio 15 u32 \
match ip sport $a 0xffff flowid 1:30
done

for a in $NOPRIOHOSTSRC
do
tc filter add dev $DEV parent 1: protocol ip prio 16 u32 \
match ip src $a flowid 1:30
done

for a in $NOPRIOHOSTDST
do
tc filter add dev $DEV parent 1: protocol ip prio 17 u32 \
match ip dst $a flowid 1:30
done

# rest is ‘non-interactive’ ie ‘bulk’ and ends up in 1:20

tc filter add dev $DEV parent 1: protocol ip prio 18 u32 \
match ip dst 0.0.0.0/0 flowid 1:20

########## downlink #############
# slow downloads down to somewhat less than the real speed to prevent
# queuing at our ISP. Tune to see how high you can set it.
# ISPs tend to have *huge* queues to make sure big downloads are fast
#
# attach ingress policer:

tc qdisc add dev $DEV handle ffff: ingress

# filter *everything* to it (0.0.0.0/0), drop everything that’s
# coming in too fast:

tc filter add dev $DEV parent ffff: protocol ip prio 50 u32 match ip src \
0.0.0.0/0 police rate ${DOWNLINK}kbit burst 10k drop flowid :1

Script ini bekerja cukup baik pada ADSL tapi harus dicoba-coba sampai didapat nilai optimum untuk nilai di DOWNLINK dan UPLINK. Masalah umum ADSL adalah kecepatan upload yang jauh dibawah kecepatan download, dan karena sifat TCP/IP yang terus mengirim paket sampai akhirnya tidak ada tempat lagi untuk paket, biasanya modem akan hang. Dengan kecepatan dowload yang kencang biasanya user terus mendownload beberapa sites sekaligus sehingga akumulasi upload menjadi besar. Bila traffic upload ini mencapai modem ADSL maka modem akan hang.

Karena itu harus diatur agar traffic upload kita kontrol dan tidak mencapai modem ADSL hal ini dilakukan dengan menurunkan nilai UPLOAD sampai nilai optimum. Hal ini tercapai jika network latency mencapai nilai terendah dan network tidak putus. Lebih jauh silakan baca pada dokumen LARTC Om Bert di atas.


rc.local di openSUSE

Tidak ada rc.local di openSUSE (he..he…he…)
Kalau kita lihat di RedHat (dan cloningnya) rc.local dijalankan setelah semua service selesai dijalankan di run level 5. Ini gak ada padanannya di openSUSE.

User biasanya mengira boot.local di /etc/init.d adalah padanan dari rc.local. Ini adalah perkiraan yang salah karena boot.local akan jalan paling awal sebelum service-service yang lain dijalankan. Sehingga seringkali user membuat script iptables dan disisipkan pada boot.local kemudian komplain karena scriptnya tidak jalan. Ini terjadi karena script iptables dipanggil sebelum service network dikonfigurasi di run level 3 sehingga sudah pasti tidak akan berfungsi.

Di openSUSE kita harus mengetahui pada saat mana script kita harus jalan apa saja syarat yang dibutuhkan, walaupun umumnya akan jalan di run level 3 dan 5. Misalnya kita ingin menjalankan script load balancing di atas, maka sebelum script ini jalan service network harus sudah jalan dulu.

Untuk dasar dari script tersebut kita dapat menggunakan file /etc/init.d/skeleton sebagai dasar, walaupun tidak tertutup kemungkinan menggunakan script lain seperti yang akan saya contohkan.

Script untuk traffic shapper:
#!/bin/sh
#
#
# /etc/init.d/bwshaper_eth0
#
### BEGIN INIT INFO
# Provides: bwshaper_eth0
# Required-Start: $network
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Custom shapping using htb for eth0 to ISP-A
# Description: decreased the upload traffic on eth0 to ISP-A by doing queuing using htb,
# script by medwin@gmail.com
### END INIT INFO
#

test -s /etc/rc.status && . /etc/rc.status && rc_reset

case "$1" in
start )

## letakkan script and di sini

rc_status -v
;;
stop)
# ok kita test
;;

esac

rc_exit

# end of script

Script di atas hanya satu contoh sederhana saja. Perhatikan bagian:
### BEGIN INIT INFO
# Provides: bwshaper_eth0 —> ini nama service anda
# Required-Start: $network —> ini adalah service yang harus jalan sebelum script anda di jalankan
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: 3 5 —> ini run level script anda bekerja
# Default-Stop: 0 1 2 6
# Short-Description: Custom shapping using htb for eth0 to ISP-A
# Description: decreased the upload traffic on eth0 to ISP-A by doing queuing using htb, script by medwin@gmail.com
### END INIT INFO
bagian ini akan dipelajari oleh insserv untuk menjalankan script anda pada run level berapa.
Copy script anda di /etc/init.d
Untuk memasukkan service anda ke service maka daftarkan dengan perintah

> insserv (nama service)

kemudian check dengan

> chkconfig –list

untuk mengetahui kalau service anda sudah masuk ke daftar service di run level tertentu.

Anda juga bisa berkreasi dengan membuat script service yang bisa dijalankan dan diberhentikan seperti misalnya dengan menyisipkan

case "$1" in

start)

echo -n "Starting bandwidth shaping on eth0: "
start
echo "done"
;;

stop)

echo -n "Stopping bandwidth shaping on eth0: "
stop
echo "done"
;;

restart)

echo -n "Restarting bandwidth shaping on eth0: "
restart
echo "done"
;;

status)

echo "Bandwidth shaping status for $IF:"
show
echo ""
;;

*)

pwd=$(pwd)
echo "Usage: tc.bash {start|stop|restart|status}"
;;

pada script anda. Kemudian melakukan symbolic link file tersebut ke /usr/sbin atau /sbin, misalnya dengan nama rcbwshaper_eth0

> ln-s /etc/init.d/bwshaper_eth0 /usr/sbin/rcbwshaper_eth0

sehingga anda bisa memanggilnya dengan perintah

> rcbwshaper_eth0 {start|stop|restart|status}

OK selamat mencoba.
Till then keep safe and stop global warming.
the avatar of Medwinz's Notes

Traffic Shaping - Bagian 3

Bagian ini adalah bagian terakhir dari penjelasan traffic shaping. Kita akan mendiskusikan sedikit mengenai ingress qdisc. Traffic shaping yang kita bicarakan pada dua tulisan sebelumnya merupakan implementasi egress qdisc, dimana kita men-shape traffic yang meninggalkan eth1 (trafik upload). Untuk trafik yang menuju eth1 (trafik incoming) kita menerapkan ingress qdisc (lihat diagram dari jengelh untuk mendapatkan gambaran mengenai ingress dan egress). Untuk trafik incoming kita tidak dapat melakukan shaping, tetapi yang kita lakukan adalah membuat policy, implementasi di tc adalah police. Yang akan kita lakukan adalah membuat policy untuk melambatkan trafik yang masuk agar tidak terjadi kongesti di server kita.

Perhatikan bagian:

# attach ingress policer;
# ngelambatin download sedikit
tc qdisc add dev eth1 handle ffff: ingress
# lambatin semua paket yang datang terlalu cepat
tc filter add dev eth1 parent ffff: protocol ip prio 50 u32 match ip src \
0.0.0.0/0 police rate ${DOWNLINK}kbit burst 10k drop flowid :1

Arti dari baris tc qdisc add dev eth1 handle ffff: ingress adalah meng-attach ingress qdisc pada eth 1 dengan nama handle ffff: . Hal ini sama halnya dengan ketika mengattach egress qdisc dan membuat root class untuk trafik upload, hanya ingress qdisc berfungsi untuk klasifikasi trafik download.

Selanjutnya pada baris berikutnya ada u32 classifier, yang merupakan salah satu filter classifier yang sangat powerful dalam implementasi tc. u32 akan memfilter paket berdasarkan field dari paket ip (source ip address) yang dianalisa adalah 32 bit header dari paket. Apabila ada kondisi yang sesuai (match) dengan selector maka suatu tindakan (action) akan dilakukan. u32 selector berisi definisi yang akan ditemui pada suatu paket yang sedang diproses berupa informasi bit mana yang harus match di dalam header paket. Metode sederhana ini ternyata sangat powerful.


Dalam script di atas ada juga hal baru yang ditemui yaitu police dan burst. Police merupakan filter yang membatasi rate bandwidth sampai kecepatan tertentu. Burst atau buffer adalah ukuran dari bucket (HTB = hierarchical tocken bucket, atau kadang-kadang disebut juga TBF = tocken bucket filter) dalam byte (1 byte = 8 bit), sebagai patokan untuk kecepatan 10mbit/s dibutuhkan setidaknya ukuran buffer 10 kbyte.

Maksud dari baris
tc filter add dev eth1 parent ffff: protocol ip prio 50 u32 match ip src \
0.0.0.0/0 police rate ${DOWNLINK}kbit burst 10k drop flowid :1

adalah membuat class ingress dari class ffff: untuk protokol ip dengan prioritas 50 dengan source ip dari internet dengan membatasi  kecepatan paket sebesar kecepatan DOWNLINK kbit/s dengan buffer sebesar 10 kbytes, paket yang kecepatannya lebih dari DOWNLINK akan di drop.

Beberapa Contoh Lain

Kombinasi iptables, ip, tc dapat digunakan untuk beberapa hal lain yang sangat menarik, di bawah ini beberapa contohnya.
Anda mempunyai beberapa koneksi internet ke beberapa ISP. Anda menginginkan agar trafik smtp melalui jalur salah satu ISP saja. Anda dapat mengkombinasi iptables dengan ip. Buat perintah untuk script iptables seperti dibawah ini

# iptables -A PREROUTING -i eth0 -t mangle -p tcp –dport 25 \
-j MARK –set-mark 1
# echo 201 mail.out >> /etc/iproute2/rt_tables
# ip rule add fwmark 1 table mail.out
# ip rule ls
0: from all lookup local
32764: from all fwmark          1 lookup mail.out
32766: from all lookup main
32767: from all lookup default

Lalu kita jalankan perintah:
#/sbin/ip route add default via 202.172.43.171 dev eth0 table mail.out
Maka semua email trafik akan melalui eth0 di mesin router kita menuju ISP tertentu.
Contoh lain adalah untuk selector u32 classifier, misalnya kita ingin agar trafik ICMP masuk ke qdisc tertentu kita dapat membuat misalnya:
# tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip protocol 1 0xFF flowid 10:100

Mudah-mudahan penjelasan singkat ini bisa dipahami, dan jangan takut untuk mencoba-coba sendiri. Apa yang saya coba share di sini memang masih kurang lengkap tapi setidaknya bisa menjadi awal bagi anda yang tertarik network dan quality of service di linux.

Have a lot of fun.