[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How To Temporarily Suspend Network Traffic

On Tue, Feb 01, 2011 at 03:56:05PM +0200, Volkan YAZICI wrote:
> I want to temporarily suspend the network traffic on a particular
> interface -- if possible, in microsecond granularity. For this purpose,
> ifup/ifdown ioctl() calls doesn't work. That is, for wireless,
> connection isn't get recovered; for wired, it takes at least 2 seconds
> to recover. I tried using tc, but it doesn't accept "rate 0" parameter.
> Neither "iwconfig wlan0 rate 0" has any effect. (Moreover, in iwconfig
> manual it is told that values below 1000 are card specific and are
> usually an index in the bit-rate list.) Do you have any suggestions? Or
> can you point me to some other resource/mailing-list that I can consult?

It depends on exactly what behavior you're aiming for. If you just want all
packets going in or out on that interface to be dropped, you can do it
pretty effectively with iptables. The following will drop all packets
coming in through the wlan0 interface:

iptables -A PREROUTING -i wlan0 -j DROP

This will drop all packets destined to be sent out the wlan0 interface:

iptables -A POSTROUTING -o wlan0 -j DROP

You can remove each rule by changing the -A to a -D.

Now, those are the actual commands to run from the shell. You aren't going
to get microsecond granularity that way. You can, however, dig into the
iptables source and see what system calls it's making as a result of those
options and use it in your own code. I don't know if that will get you to
microsecond granularity, but you'll have to do your own profiling to check.

> Regards.

Reply to: