Saturday, November 14, 2009

802.1q tagging

In a recent project, we want to send packets with 802.1q header. It may seem easy to do this, however it turns out to be very tricky to do this in reality.

First, the NIC card will automatically strip the header when they receive it. Thus, you need configure the NIC card not to do this. For broadcom nics, you need to add "PreserveVlanInfoInRxPacket=1" in the registry. For intel nics, there is instruction, however it seems no effect when I tried on our Intel Pro 1000 PT NIC card.

Second, we want to control IP tos field when we send packet. As one may think, we can use setsockopt() to configure IP_TOS field. However, when you do this on a windows xp/2003 machine, you need to configure the registry, i.e. add DisableuserTOSSetting=0 in TCPIP/Parameters. More information can be find in technet.