Vincent in China

To content | To menu | To search

Thursday, October 22 2009

About my internship (2)

This whole afternoon I had the chance to fight with the Linux tc command (traffic control). With this wonderful tool I can easily restrict bandwidth for an user in the network, or also set up an efficient QoS (Quality of Service), favoring some important protocols such as SSH or the TCP Ack packet. over bulk data traffic for which latency and jitter are not important.

So my problem was about the tc filter, filters tell where a packet should be enqueued, in which class they have to be proceed, according to their source. Setting up the filter is easily done by a command like this one:

tc filter add dev eth0 parent 2:0 protocol ip prio 0 handle 20 fw flowid 2.20

Quick explanation, this filter is attached to the eth0 interface, and attached to the root qdisc 2:0 since htb filters (Hierarchical Token Bucket) must be attached directly ot the root class, not matter what. The prio 0 was the cause of my fight, because in my script I didn't need any special priority, so I let it at 0. The handle 20 fw means that the unique identifier of the filter is 20 and will catch the packets marqued in iptables with the value 20, and that those packets will be enqueued in the class 2:20.

If you want to delete dynamically a filter and a class of your interface, without reloading all the iptables/tc setting taking a certain time, the htb qdisc allow dynamic modifications, The only problem resides in the fact that a filter must be declared with a priority, a handle and a type if you want to remove it, else it'll be a lost filter attached ot your qdisc. After trying to remove it, I get some not really explicit messages from the tc command, and after browsing the lartc mailing list, and trying little configuration with tc on my side, I figured out that if the prio of a filter is 0 or 1 and that other filter got also got a prio of 0 or 1, you can't remove them, even if they have a handle and everything required. You need to put a prio of 2 or higher for example to all your filter and then you can delete them. It was a little tricky because in my case I don't need any filter to be prio on any other, else in most of the script using tc you'll see the prio changing.

PS: this article is still a stub that need to be completed about the none explained "things".

Tuesday, September 29 2009

Vim is your friend

Since yesterday I decided to use Vim as text editor. Vim can be considered as a weird text editor, having 2 different modes, insert and command mode, and you have to switch between them to add text or to delete words or copy/past, search for words occurrence and so on.

This Vim is really powerful and with very little simple command you can perform a lot of things, like just place the cursor on the beginning of a word, then write the command "dw" and your word will be deleted, 'd' stands for 'delete' and 'w' for 'word'. The power of Vim resides in the combination of basic instruction like this.

I just spent 2 hours to set up my Vim, and most of the time spent was to have a nice color theme (not the famous desert one). I found a very good theme on this website ( here ). The ir_black.vim file has been modified else it was impossible to read comments on the black background, and so does my Terminal colour profile, changed according to the colours given in the file.

I'll attach the ".vimrc" and ".vim" folder contening the folder for color theme later in this article.

At the end of a day of use, I'm not so mixed up between the input and command mode and I begin to be quicker for certain tasks than with an Ide or a simple Gedit. To be continued...

Tuesday, September 22 2009

About my internship

I'm in China for less than 6 months for an internship in Wuhan University of Technology. My subject is a part of a big project which have been undermine 1 year ago, aiming at developing a router filled with the technology and the hardware required to filter, control the network stream at several levels. Allow some protocols to be used on the networks or not, restrict the bandwidth to users based on their IP, and my part is about QOS (Quality of Service). In a nutshell, I have to manage the bandwidth according to the kind of traffic, and to who it's supposed to be delivered.

For now I've been mostly reading documentation about QOS, routing and Firewall settings, and mostly the two very useful commands iptables and tc available on every Linux distribution.