Entries Tagged as ''

Progress 10%

I have been touched by David blog, which is, he lives 3 lives. I actually live 3 lives as well. For living, I have to work. For better living, I have to recharge myself at the night. For best living, I must take responsible for my family.

Today, as what I have planed, I pass the written exam. Although only 10% progress to my goal, it is still a mile stone for me. At least, I know which part I need to improvement.

Next, as Henry Zheng said, it may take 7 months to prepare lab. I wanna be a real CCIE, from R&D point of view. Maybe I have done a lot marketing support job before. Maybe R&D will be more suitable for me.

Simulate a Slow Link by Linux Bridge

To simulate the real world slow link network, sometimes network equipment is not enough. For example, LAN Switch can do rate-limit on each egress port, but it cannot allow packet forwarding delay, or, it cannot setup packet loss rate. The four major elements of QoS are: Bandwidth, Delay, Packet Loss and Jitter. So, in order to achieve the real situation, we can use Linux bridge plus traffic control (tc) features.

Setup Linux Bridge

Two NICs cannot be a bridge unless we install a bridge utility. “yum -y install bridge-utils” can be applied. Sorry I didn’t mention in Ubuntu distribution since I am always working on Fedora Core. Then, we need to plan which two NICs to be the member of the bridge. In my case, I use eth1 and eth2. So, make sure there is no ip on both of Ethernet cards first. Then, we need to type the following commands:

ifconfig eth0 0.0.0.0 up
ifconfig eth1 0.0.0.0 up
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 eth1
ifconfig br0 up

We can assign an IP address to br0, like we assign vlan interface IP address in LAN Switch.

ifconfig br0 192.168.50.50 netmask 255.255.255.0 gw 192.168.50.254

However, since there is no routing over the bridge. we can just leave it as pure bridge.

Brief Introduction of TC

Traffic Control (TC) is a tool that do egress traffic shaping on every port. The primitive purpose to create a module named shaper.o is to slow down interface. It didn’t measure traffic instead, it was only able to decrease interface speed by suing PWM (Pulse Width Modulation). For example, you can transfer power equal to 12V from 36V by switching supply off for 2ms then switch on for 1ms. PWM has one advantage that it didn’t require much cpu usage.

Then, the CBQ (Class Based Queue) is appeared. It can classify traffic but it works in the same way as PWM.

Then, the HTB (Hierarchy Token Bucket) is coming. It controls traffic per packet instead of time slots. It allows to implement very precise control in expense of higher CPU usage.

The detailed description is available in tc manual.

Create a Delay Network

To make a simple work, we don’t need to use classes. We only need to add delay to root. However, very important, each time we have to clear “queue discipline”.

tc qdisc del dev eth1 root
tc qdisc del dev eth2 root

Then, we setup a 500 mini second delay.

tc qdisc add dev eth1 root handle 1:0 netem delay 500msec
tc qdisc add dev eth2 root handle 1:0 netem delay 500msec

Create a Low Bandwidth Network

Still, I didn’t compose any fancy shell script, instead I just use only two lines to achieve a 128K link.

tc qdisc del dev eth1 root
tc qdisc del dev eth2 root
tc qdisc add dev eth2 root tbf rate 128kbit burst 1024kbit latency 50ms
tc qdisc add dev eth1 root tbf rate 128kbit burst 1024kbit latency 50ms

So far I only got this level. I saw quite a lot blogs and tutorials in the web, which have more complicated network.

Process States in Linux

To help me memorize, I list all process states for Linux, which is actually from UNIX.

  • R – runnable which means the process has done a context switch and has the kernel.
  • S – sleeping which means the process is waiting on I/O completion (blocked), a pipe, memory, etc.
  • T – process has been stopped – sent a SIGSTOP usually with ctrl/z
  • Z – zombie – a process that has a process image in memory but no context, ie., not swappable.
  • O – means the process is the one that currenlty has the cpu