[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 07:40:06PM +0200, Volkan YAZICI wrote:
> On Tue, 1 Feb 2011 09:16:16 -0500, Gregory Seidman writes:
> Thanks Greg, but there is a small anomaly with this method. For
> instance, if I
> 1. issue
>      $ pv -q -L 10k /tmp/200k.dat | nc 7000
>    from terminal A,
> 2. and after a few seconds issue
>      # iptables -A OUTPUT -i wlan0 -j DROP && \
>      > sleep 2 && \
>      > iptables -D OUTPUT -i wlan0 -j DROP
>    command (pay attention that I used OUTPUT chain instead of
>    {PRE,POST}ROUTING), as expected, transfer hangs up for 2 seconds, and
>    finishes without a problem.

I note that you are only doing this once, so there is a 2 second
interruption as expected.

> On the other hand, in the 2nd step, if I issue
>   # while /bin/true; do \
>   > iptables -A OUTPUT -i wlan0 -j DROP && \
>   > usleep 100000 && \
>   > iptables -D OUTPUT -i wlan0 -j DROP
> command (usleep is a small C program I wrote, see the attachment),
> transfer hangs after some point and stops for ~30-40secs and finishes
> when I stop the while loop. Do I miss anything? Any suggestions?

Here you are interrupting for 100,000 usecs (which is 100msecs, I believe),
but you don't sleep at all between interruptions in the while loop. That
means that it only has the time between the execution of the iptables
command at the end of the loop and the execution of the iptables command at
the beginning of the loop to actually transmit any packets. It is
unsurprising that it hangs. Make sure you sleep for a while after removing
the iptables rule.

> Best.

Reply to: