facebookarchive / augmented-traffic-control

Augmented Traffic Control: A tool to simulate network conditions
https://facebook.github.io/augmented-traffic-control
Other
4.33k stars 600 forks source link

Why the packet loss rate is set to 100, and then use socket to send messages and sometimes can be sent successfully? #247

Closed qxmmxi closed 8 years ago

qxmmxi commented 8 years ago

Why the packet loss rate is set to 100, and then use IM to send messages and sometimes can be sent successfully? Not a message is not sent out?

chantra commented 8 years ago

@mgjnana I am not sure I clearly understand your question.

If you set packet loss to 100%, all packets will be dropped by ATC unless you misconfigured ATC.

Can you confirm that when setting lower bandwith, some packet loss, ATC is actually limiting the bandwidth, dropping some packet? If this is not the case, the you may want to doublecheck that:

  1. the traffic from your device is actually routed through ATC
  2. you correctly use the right wan and lan interfaces when starting ATCd. Failing to do so, your traffic will not be shaped.
chantra commented 8 years ago

@mgjnana did you doublecheck your settings. If this does not work, can you copy in a gist the following:

qxmmxi commented 8 years ago

@chantra
Thanks for you kind reply. I checked it according to your suggestion.but there is no problem finding.I use ap-hotspot. I guess may be to retreat to the background, to make the request not normal to send, follow-up time I will use the app to directly call API to dynamically adjust the network, realize my needs and test this hypothesis. Thank you anyway :)

ip a :

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc htb state UP group default qlen 1000 link/ether 04:7d:7b:48:ac:89 brd ff:ff:ff:ff:ff:ff inet 10.0.25.86/22 brd 10.0.27.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::67d:7bff:fe48:ac89/64 scope link valid_lft forever preferred_lft forever 3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc htb state DOWN group default qlen 1000 link/ether 74:de:2b:e7:bf:2d brd ff:ff:ff:ff:ff:ff inet 192.168.150.1/24 brd 192.168.150.255 scope global wlan0 valid_lft forever preferred_lft forever inet6 fe80::76de:2bff:fee7:bf2d/64 scope link valid_lft forever preferred_lft forever 27: mon.wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN group default qlen 1000 link/ieee802.11/radiotap 74:de:2b:e7:bf:2d brd ff:ff:ff:ff:ff:ff

ip r :

default via 10.0.24.1 dev eth0 proto static 10.0.24.0/22 dev eth0 proto kernel scope link src 10.0.25.86 metric 1 192.168.150.0/24 dev wlan0 proto kernel scope link src 192.168.150.1

command:

sudo atcd --atcd-lan wlan0

chantra commented 8 years ago

@mgjnana can you also post to https://gist.github.com/ some of the logs from /var/log/messages (or whichever your OS is using) when you shape and unshape traffic.

qxmmxi commented 8 years ago

I can't visit this website.Can i give you a email with this log file?

chantra commented 8 years ago

You can't go to gist.github.com? Can you paste it in this github issue then. I only care about atcd messages. Tks

qxmmxi commented 8 years ago

I need to cross the wall to visit some website,but recently is not good.

qxmmxi commented 8 years ago

I can't upload the log file.always go wrong.

qxmmxi commented 8 years ago

Mar 10 10:19:22 nana-ThinkPad-Edge deleting filter on IFID eth0, handle 2 Mar 10 10:19:22 nana-ThinkPad-Edge deleting class on IFID eth0, classid 1:2 Mar 10 10:19:22 nana-ThinkPad-Edge Unshaping ip 192.168.150.10 on interface wlan0 Mar 10 10:19:22 nana-ThinkPad-Edge Running /sbin/iptables -t mangle -D FORWARD -s 192.168.150.10 -i wlan0 -j MARK --set-mark 2 Mar 10 10:19:22 nana-ThinkPad-Edge deleting filter on IFID wlan0, handle 2 Mar 10 10:19:22 nana-ThinkPad-Edge deleting class on IFID wlan0, classid 1:2 Mar 10 10:19:26 nana-ThinkPad-Edge Request startShaping TrafficControl(device=TrafficControlledDevice(controllingIP='192.168.150.10', controlledIP='192.168.150.10'), timeout=86400, settings=TrafficControlSetting(down=Shaping(loss=Loss(percentage=100.0, correlation=0.0), delay=Delay(delay=123, jitter=0, correlation=0.0), rate=211, iptables_options=[], corruption=Corruption(percentage=80.0, correlation=0.0), reorder=Reorder(percentage=80.0, correlation=0.0, gap=0)), up=Shaping(loss=Loss(percentage=100.0, correlation=0.0), delay=Delay(delay=0, jitter=0, correlation=0.0), rate=241, iptables_options=[], corruption=Corruption(percentage=80.0, correlation=0.0), reorder=Reorder(percentage=80.0, correlation=0.0, gap=0)))) Mar 10 10:19:26 nana-ThinkPad-Edge Shaping ip 192.168.150.10 on interface eth0 Mar 10 10:19:26 nana-ThinkPad-Edge create new HTB class on IFID eth0, classid 1:2,parent 1:0, rate 241kbits Mar 10 10:19:26 nana-ThinkPad-Edge create new Netem qdisc on IFID eth0, parent 1:2, loss 100.0%, delay 0 Mar 10 10:19:26 nana-ThinkPad-Edge create new FW filter on IFID eth0, classid 1:2, handle 2, rate: 241kbits Mar 10 10:19:26 nana-ThinkPad-Edge Running /sbin/iptables -t mangle -A FORWARD -d 192.168.150.10 -i eth0 -j MARK --set-mark 2 Mar 10 10:19:26 nana-ThinkPad-Edge Shaping ip 192.168.150.10 on interface wlan0 Mar 10 10:19:26 nana-ThinkPad-Edge create new HTB class on IFID wlan0, classid 1:2,parent 1:0, rate 211kbits Mar 10 10:19:26 nana-ThinkPad-Edge create new Netem qdisc on IFID wlan0, parent 1:2, loss 100.0%, delay 123000 Mar 10 10:19:26 nana-ThinkPad-Edge create new FW filter on IFID wlan0, classid 1:2, handle 2, rate: 211kbits Mar 10 10:19:26 nana-ThinkPad-Edge Running /sbin/iptables -t mangle -A FORWARD -s 192.168.150.10 -i wlan0 -j MARK --set-mark 2 Mar 10 10:19:26 nana-ThinkPad-Edge Unshaping ip 192.168.150.10 on interface eth0 Mar 10 10:19:26 nana-ThinkPad-Edge Running /sbin/iptables -t mangle -D FORWARD -d 192.168.150.10 -i eth0 -j MARK --set-mark 3 Mar 10 10:19:26 nana-ThinkPad-Edge deleting filter on IFID eth0, handle 3 Mar 10 10:19:26 nana-ThinkPad-Edge deleting class on IFID eth0, classid 1:3 Mar 10 10:19:26 nana-ThinkPad-Edge Unshaping ip 192.168.150.10 on interface wlan0 Mar 10 10:19:26 nana-ThinkPad-Edge Running /sbin/iptables -t mangle -D FORWARD -s 192.168.150.10 -i wlan0 -j MARK --set-mark 3 Mar 10 10:19:26 nana-ThinkPad-Edge deleting filter on IFID wlan0, handle 3 Mar 10 10:19:26 nana-ThinkPad-Edge deleting class on IFID wlan0, classid 1:3 Mar 10 10:19:34 nana-ThinkPad-Edge Request startShaping TrafficControl(device=TrafficControlledDevice(controllingIP='192.168.150.10', controlledIP='192.168.150.10'), timeout=86400, settings=TrafficControlSetting(down=Shaping(loss=Loss(percentage=100.0, correlation=0.0), delay=Delay(delay=265, jitter=0, correlation=0.0), rate=2, iptables_options=[], corruption=Corruption(percentage=80.0, correlation=0.0), reorder=Reorder(percentage=80.0, correlation=0.0, gap=0)), up=Shaping(loss=Loss(percentage=100.0, correlation=0.0), delay=Delay(delay=0, jitter=0, correlation=0.0), rate=2, iptables_options=[], corruption=Corruption(percentage=80.0, correlation=0.0), reorder=Reorder(percentage=80.0, correlation=0.0, gap=0))))

chantra commented 8 years ago

thanks @mgjnana This should work... after shaping, can you run the script from https://github.com/facebook/augmented-traffic-control/blob/60e38611a535273c887a0a08ff94286ab19ecd9b/utils/dump_system_info.sh

./dump_system_info.sh eth0 wlan0

and post the content. I wonder what tc has to report.

qxmmxi commented 8 years ago

I can't run this shell ,it report syntax error"}",but looked all right.

chantra commented 8 years ago

@mgjnana can you try to debug this on your end. this is working fine for me.

qxmmxi commented 8 years ago

@chantra I need use bash to run it .

######### cat /etc/os-release #########

NAME="Ubuntu"
VERSION="14.04.4 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.4 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

######### pip freeze #########

adium-theme-ubuntu==0.3.4
apt-xapian-index==0.45
atc-thrift==0.1.3
atcd==0.1.3
chardet==2.0.1
colorama==0.2.5
command-not-found==0.3
daemonize==2.4.2
debtagshw==0.1
defer==1.0.6
dirspec==13.10
Django==1.7b2
django-atc-api==0.1.3
django-atc-profile-storage==0.1.3
django-bootstrap-themes==3.1.2
django-static-jquery==1.11.1
djangorestframework==3.3.2
duplicity==0.6.23
futures==3.0.5
html5lib==0.999
httplib2==0.8
lockfile==0.8
lxml==3.3.3
oauthlib==0.6.1
oneconf==0.3.7
PAM==0.4.2
pexpect==3.1
Pillow==2.3.0
piston-mini-client==0.7.5
pycrypto==2.6.1
pycups==1.9.66
pycurl==7.19.3
pygobject==3.12.0
pyOpenSSL==0.13
pyotp==1.4.1
pyroute2==0.3.3
pyserial==2.6
pysmbc==1.0.14.1
python-apt==0.9.3.5
python-debian===0.1.21-nmu2ubuntu2
pyxdg==0.25
reportlab==3.0
requests==2.2.1
sessioninstaller==0.0.0
six==1.5.2
software-center-aptd-plugins==0.0.0
South==1.0.2
sparts==0.7.1
system-service==0.1.6
thrift==0.9.3
Twisted-Core==13.2.0
Twisted-Web==13.2.0
unity-lens-photos==1.0
urllib3==1.7.1
wheel==0.24.0
xdiagnose===3.6.3build2
zope.interface==4.0.5
The directory '/home/nana/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
You are using pip version 8.0.2, however version 8.1.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

######### ip a #########

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc htb state UP group default qlen 1000
    link/ether 04:7d:7b:48:ac:89 brd ff:ff:ff:ff:ff:ff
    inet 10.0.25.86/22 brd 10.0.27.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::67d:7bff:fe48:ac89/64 scope link 
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc htb state UP group default qlen 1000
    link/ether 74:de:2b:e7:bf:2d brd ff:ff:ff:ff:ff:ff
    inet 192.168.150.1/24 brd 192.168.150.255 scope global wlan0
       valid_lft forever preferred_lft forever
    inet6 fe80::76de:2bff:fee7:bf2d/64 scope link 
       valid_lft forever preferred_lft forever
28: mon.wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN group default qlen 1000
    link/ieee802.11/radiotap 74:de:2b:e7:bf:2d brd ff:ff:ff:ff:ff:ff

######### ip r #########

default via 10.0.24.1 dev eth0  proto static 
10.0.24.0/22 dev eth0  proto kernel  scope link  src 10.0.25.86  metric 1 
192.168.150.0/24 dev wlan0  proto kernel  scope link  src 192.168.150.1 

######### iptables-save #########

# Generated by iptables-save v1.4.21 on Thu Mar 10 14:11:59 2016
*nat
:PREROUTING ACCEPT [11582:906078]
:INPUT ACCEPT [2438:380599]
:OUTPUT ACCEPT [6271:438990]
:POSTROUTING ACCEPT [2841:182648]
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
# Completed on Thu Mar 10 14:11:59 2016
# Generated by iptables-save v1.4.21 on Thu Mar 10 14:11:59 2016
*mangle
:PREROUTING ACCEPT [267063:98917987]
:INPUT ACCEPT [259519:98433226]
:FORWARD ACCEPT [6792:445261]
:OUTPUT ACCEPT [18034:2438570]
:POSTROUTING ACCEPT [24876:2910850]
-A FORWARD -d 192.168.150.10/32 -i eth0 -j MARK --set-xmark 0x3/0xffffffff
-A FORWARD -s 192.168.150.10/32 -i wlan0 -j MARK --set-xmark 0x3/0xffffffff
COMMIT
# Completed on Thu Mar 10 14:11:59 2016

######### tc qdisc show dev wlan0 #########

qdisc htb 1: root refcnt 5 r2q 10 default 0 direct_packets_stat 3036 direct_qlen 1000
qdisc netem 8d64: parent 1:3 limit 1000 delay 205.0ms loss 100% reorder 80% corrupt 80% gap 1

######### tc class show dev wlan0 #########

class htb 1:3 root leaf 8d64: prio 0 rate 2000bit ceil 2000bit burst 1600b cburst 1600b 

######### tc filter show dev wlan0 #########

filter parent 1: protocol ip pref 1 fw 
filter parent 1: protocol ip pref 1 fw handle 0x3 classid 1:3  police 0xd64 rate 2000bit burst 12000b mtu 2Kb action drop overhead 0b 
ref 1 bind 1
chantra commented 8 years ago

For some reason, this is missing the output of tc for eth0 but anyhow, it seems this is correctly setup. you should get 100% packet loss.

Can you try to do a speed test? Also to confirm, the remote device you are doing messaging with is not on the same network then the device you are shaping traffic for. If using a phone, can you confirm that no fallback on cellular data happens.

qxmmxi commented 8 years ago

I use atc to do a irregular change, the first weak network, the normal speed, abnormal parameters; after 100% of the packet loss rate of the network, and then switch to the normal network, so the cycle. So it is possible that it is possible to switch over and over in time.

Now is not much impact, web is not a good way to use, If I have time, I will try to use the app call interface to achieve, when there is a problem to ask you.

Thanks for you kind reply. #。#