This shows you the differences between two versions of the page.
saisp:labs:11:contents:06 [2014/05/18 12:32] mihai.carabas [06. Lorem ipsum] |
saisp:labs:11:contents:06 [2014/05/18 14:27] (current) mihai.carabas |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== 06. Colectare statistici folosind ''tc'' ==== | + | ==== 06. [15p] Politici de limitare per client ==== |
- | Pe lângă controlul traficului, utilitarul ''tc'' ne furnizează și statistici despre traficul transferat de fiecare clasă:<code bash> | + | Ștergeți qdisc-ul root adăugat anterior. |
- | root@gateway:~# tc -s class show dev eth0 | + | |
- | </code> | + | |
- | Scrieți un script care extrage numărul de octeți trimiși pentru una din clase. Utilizați acest script să generați un grafic folosind informațiile prezentate în [[saisp:labs:03:contents:05|]]. | + | Realizați configurațiile necesare astfel încât să limitați stația ''client1'' la 5 mbps, iar stația ''client2'' la 3mbps. În plus dorim ca cei 3mbps ai stației ''client2'' să fie împărțiți după cum urmează: |
+ | * 1mbps pentru traficul ce ajunge pe portul 1111 (Hint: folosiți 2 reguli de ''match'' ale clasificatorului ''u32'') | ||
+ | * 2mbps pentru traficul de pe restul porturilor | ||
+ | Testați folosind ''iperf''. | ||
+ | <solution -hidden> | ||
+ | <code bash> | ||
+ | root@gateway:~# tc qdisc del dev eth0 root | ||
+ | root@gateway:~# tc qdisc add dev eth0 root handle 1: htb | ||
+ | root@gateway:~# tc class add dev eth0 parent 1: classid 1:1 htb rate 5mbit burst 128k | ||
+ | |||
+ | root@gateway:~# tc class add dev eth0 parent 1: classid 1:2 htb rate 3mbit burst 128k | ||
+ | root@gateway:~# tc class add dev eth0 parent 1:2 classid 1:3 htb rate 1mbit burst 128k | ||
+ | root@gateway:~# tc class add dev eth0 parent 1:2 classid 1:4 htb rate 2mbit burst 128k | ||
+ | |||
+ | root@gateway:~# tc filter add dev eth0 protocol ip parent 1: prio 1 u32 match ip dst 192.168.1.1 flowid 1:1 | ||
+ | root@gateway:~# tc filter add dev eth0 protocol ip parent 1: prio 1 u32 match ip dst 192.168.1.2 match ip dport 1111 0xffff flowid 1:3 | ||
+ | root@gateway:~# tc filter add dev eth0 protocol ip parent 1: prio 1 u32 match ip dst 192.168.1.2 flowid 1:4 | ||
+ | </code> | ||
+ | </solution> |