您的位置:首页 > 理论基础 > 计算机网络

ATC, Facebook开源模拟网络环境的工具

2015-07-20 16:11 579 查看
Augmented Traffic Control (ATC) 是Facebook开源的一款移动网络测试工具,可以模拟各种网络环境。开发者可以通过ATC配置移动设备连接的网络的状况,可以模拟高速的、或者移动网络下受限的网络。

通过ATC可以控制网络的下述方面:

1. Bandwith,带宽

2. Latency, 延迟

3. Packet loss, 丢包率

4. Packet corruption,错包率

5. Packet reordering,乱序率

通过上面参数的设置,可以模拟出各类常用的网络环境,例如2G,3G,4G,WiFi等等。可以参考Comcast中的参数配置。

ATC安装

Important: Before trying to install ATC, please make sure you meet the following requirements.

ATC is designed to be running on:

A Network Getaway: ATC will shape the traffic that is forwarded through it. To do this, ATC will typically have 1 network interface conencted to your local network and an other that connects you to the internet.

Linux: ATC makes uses of both iptables and the tc subsystem. As such, Linux is a hard requirement.

Python 2.7: Currently, ATC is only supported on python version 2.7.

我们首先要注意ATC需要使用iptable和tc的支持,因此只能在Linux系统上使用,此外目前ATC只支持python2.7。本文直接在Ubuntu14.04真机上完成环境的搭建。

在Ubuntu中设置WiFi热点

直接参考Ubuntu 14.04 快速创建无线接入点供移动设备连接上网,讲解的很详细。我按照上面的配置以后,手机一直收不到AP热点,重启一下才收到,坑了很多时间……)

ATC环境搭建

官网上已经给出了很详细的介绍,可以参考Augmented Traffic Control。下面我实际的配置过程。

安装python2.7以及pip

Ubuntu14.04自带了python2.7,如果系统没有安装,先安装python2.7。然后安装pip:

sudo apt-get install python-pip python-dev build-essential
sudo pip install --upgrade pip


使用pip安装需要的ATC组件

pip install atc_thrift atcd django-atc-api django-atc-demo-ui django-atc-profile-storage


部署和安装ATC的Django web工程

使用django-admin生成一个新的django工程:

django-admin startproject atcui


修改/atcui/setting.py,按照在INSTALLED_APPS中增加相关内容

INSTALLED_APPS = (
...
# Django ATC API
'rest_framework',
'atc_api',
# Django ATC Demo UI
'bootstrap_themes',
'django_static_jquery',
'atc_demo_ui',
# Django ATC Profile Storage
'atc_profile_storage',
)


修改atcui/urls.py,在urlpatterns中增加ATC的url页面:

...
from django.views.generic.base import RedirectView

urlpatterns = patterns('',
...
# Django ATC API
url(r'^api/v1/', include('atc_api.urls')),
# Django ATC Demo UI
url(r'^atc_demo_ui/', include('atc_demo_ui.urls')),
# Django ATC profile storage
url(r'^api/v1/profiles/', include('atc_profile_storage.urls')),
url(r'^$', RedirectView.as_view(url='/atc_demo_ui/', permanent=False)),
)


最后,执行migrate命令,更新数据库

python manage.py migrate


启动AP热点,运行ATC

根据上文中设置的AP热点,启动AP热点,然后启动ATC组件。

sudo atcd --atcd-wan eth0 --atcd-lan wlan0


上述命令表示使用eth0网卡作为公网连接,wlan0作为AP内网连接。

5. 运行ATC UI

python manage.py runserver 0.0.0.0:8000


通过上述配置,我们就可以在连接上AP热点的手机浏览器上访问ATC UI。例如我设置本机的wlan0的ip是192.168.0.1,直接通过http://192.168.0.1:8000访问到控制界面。



我们可以在上述的表达中填入想设置的丢包率吧、延迟等参数,就可以控制手机访问的网络环境。

【参考】

1. Augmented Traffic Control

2. Facebook网络模拟测试工具ATC使用

3. Ubuntu 14.04 快速创建无线接入点供移动设备连接上网
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: