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...

Monday, September 28 2009

A monday in Wuhan

After a kind of busy weekend, here comes Monday. After a morning working at the lab on my project, which is going well for now, I took my lunch break outside eating in a "normal restaurant".

By “normal restaurant", let me explain the kind of restaurant you can in China.

  • Self service little restaurant : In this kind of restaurant, there is a person in front of it giving you a plastic box for you to fill with the food you'll find in the shop (or on the side-walk). There is plenty of kind of vegetables or spring roll or tofu, but no meat. Once you filled your box, you go to the cashier and the weight of your box will determine the price you pay, it's usually around 19 Yuans for one kilo, after you paid, you have also the same plastic box full of rice in addition to the dishes you choose before. In this restaurant, the food is exposed at the direct air of street and everyone pic his food in a joyful messy crowd. Maybe your stomach won't appreciate...
  • Little restaurant : In this little restaurant, you have a big choice of dishes, usually between noodles or rice based dishes, and served in a single plate or bowl if you take noddles with soup. It's a single plate, with the rice/noodle, vegetables and very tiny pieces of meet. You can eat there for minimum 5 yuans, or most of the time 7 or 8 yuans. It's cheap because the quantity of meat you have is really, tiny tiny tiny. Same than for the previous description, your stomach may not like this kind of food. I think than health rules are more than basic in this kind of restaurant, but the dishes are tasty.
  • Normal restaurant : A set of crockery wrapped in a plastic bag to tell you your dishes has been clean : a glass, a bowl, a plate and chopsticks. You have a menu and the waiter come at your table to take your order or you can write your order by yourself and simply give him the note. You can separately order dishes, like a plate of vegetables, a plate of fish, meat or a big bowl of soup. When you order the dishes, it takes a really short time to be ready (not like in France) and the waiter also brings you a big bowl of rice, to eat with the dishes you ordered. The "usual" typical order is like one dish for one person, and everyone takes what he/she wants on the table. The rice in China is not really considered as a dish, but only something to be eaten with the dishes. The price for a dish with meat is around 14 or 18 Yuan, but that's really meat and in a very satisfying quantity. For two people, count around 40 yuan for a meal.
  • Fancy restaurant : It's the same than a normal one, except the decoration, you can also have a separate room if you are more than 6 to eat, with your own air conditioner, toilets and tea table. There is also almost all the time a waiter in the room serving the dishes or preparing tea. The quality is superior and so are the prices. Count around 400/500 yuan for 6 people.

So my preference goes to the normal restaurant, first because it's very tasty in most of this kind of restaurant, you have enough to eat (whereas a single plate of rice and vegetables will often let you starve some hours after), you can eat meat, and it's "stomach compliant".

Once returned to my lab after a one hour break, I begin to keep working on my bash script, using vim to insert none printable ASCI characters for doing a spinner which will be displayed while the background task will be done, anyway, doing my job peacefully, when a student in my row go back to seat on his desk. My computer is shut down, power off. Yes, the outlet for electricity is placed on the ground, on a little metallic hatch, and the outlet is kind of not very stable, so my nice lab-mate walked on it or touched it and powered off my computer and the router for the left side of the lab, congratulations !

Yes, the lab is a mess, hubs on the ground, RJ45 wires running everywhere, 2 multi-plug outlets pluged in a row, kind of never seen, but working, but very sensible to any bad move made by a chair or an awkward foot.

After leaving my lab and passing by the local supermarket to buy some fruits and ice creams, I went to run on the stadium I have just at the feet of my building. It belongs to a college, not Wuhan University of Technology, but another one.

Let's talk a little about sport now : In China, in the college campus, what strikes the most is to see the number of basket ball fields and to see all those students playing all day long. It's also funny to see a lot of students, or middle age or old people walking or walking quickly around the stadium, chatting together. Before coming to Wuhan, I feared that because of the pollution I won't be able to do intensive exercise but in fact I can run as well as in France, and I don't have any particular breathing problem due to the not clear air.

Today I met a Chinese student from the university who was also running and we chatted quickly while running. And during a little break I took before two running sessions, and since my tender half wasn't running with me, I was boarded by a student whose English was not clear and mixed up with Chinese, she seemed kind of confuse so I returned to run, I'm not an easy man !

Saturday, September 26 2009

First Chinese course in WHUT

This morning I had my first Chinese course in the campus, from 8 am to almost noon, on a Saturday morning, not easy to wake up. There are courses for foreign students all morning in the week and week ends but since I have to work in the lab from Monday to Friday, I can only go there during the week end.

The only problem is that the students were already at lesson 3 and I'll have to work on my side during the week to keep the same level than them, but since now it's really basic, I'm not lost (yet).

The teacher is I think a student in the university and is competent and interesting, she also explain to us how to write Chinese in a correct way and respecting the order of writing.

Tomorrow, Sunday morning at 8 am, I'll return there for another 4 hours of courses.

Edit:

Today, Sunday 27, I went to the course again, really hard to wake so early on a Sunday to study, but the course was interesting with a funny dynamic young teacher, maybe working too much on the same concepts and vocabulary, but maybe a good way to memorise little by little.

During the weekend courses, we are around 22 students, most of them are coming from Africa, India or Pakistan.

Anyway those courses are not enough for me according to the level of Chinese I wish to reach before the end of my intern-ship, so I'll keep studying by myself in addition.