Created
June 2, 2015 14:29
-
-
Save digilist/d4b8ecd92b9af7aa0492 to your computer and use it in GitHub Desktop.
Delaying network traffic to a specific IP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
interface=lo | |
ip=10.0.0.1 | |
delay=100ms | |
tc qdisc add dev $interface root handle 1: prio | |
tc filter add dev $interface parent 1:0 protocol ip prio 1 u32 match ip dst $ip flowid 2:1 | |
tc qdisc add dev $interface parent 1:1 handle 2: netem delay $delay |
You need to divide your traffic into three parts packets for ip1 , packets for ip2 and packets for ip2.
This is possible please go through all the links I have given in the code (start).
There is a lot to learn and your problem is not a simple copy paste from stack overflow .
It seems all solutions are qdisc-prio-based, but qdisc-prio has a limit of 16 priorities, so one can't use it for 17 or more routes
This will somehow affects my SSH connect to the remote server where those command runs while successfully delaying certain IP flow. Don't know how to fix it. TAT
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks @deepanshu-yadav I'll go through the Python file. A quick qstn, do I need to change parentid/flow id? I see following error
Error: Exclusivity flag on, cannot modify.
when I tried following codedelay.sh
tc qdisc add dev $interface root handle 1: prio
tc filter add dev $interface parent 1:0 protocol ip prio 1 u32 match ip dst $ip1 flowid 2:1
tc qdisc add dev $interface parent 1:1 handle 2: netem delay $delay1
tc filter add dev $interface parent 1:0 protocol ip prio 1 u32 match ip dst $ip2 flowid 2:1
tc qdisc add dev $interface parent 1:1 handle 2: netem delay $delay2