_StriveG Blog

ubuntu下搭建ATC弱网测试环境

前言

看到了Fresco的弱网测试框架,尝试一下。github地址

  1. 安装python virtualenv

    1
    sudo apt-get install python-virtualenv
  2. 创建一个python 2.7的虚拟环境

1
virtualenv python2.7 --python=python2.7
  1. 切换到虚拟环境

    1
    source python2.7/bin.activate
  2. 安装django,版本必须1.10

    1
    sudo pip install django==1.10
  3. 安装ATC相关东西

    1
    sudo pip install atc_thrift atcd django-atc-api django-atc-demo-ui django-atc-profile-storage
  4. 初始化一个django项目

    1
    2
    django-admin startproject atcui
    cd atcui
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    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',
    )
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    from django.views.generic.base import RedirectView
    from django.conf.urls import include,url
    urlpatterns = [
    ...
    # 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)),
    ]
1
python manage.py migrate
  1. 启动atcd

    注意,启动的时候得指定wan和lan,通过ifconfig查看,第一个为wan,最后一个为lan

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    cd python2.7/bin/
    sudo ./atcd --atcd-wan wan名称 --atcd-lan lan名称
    ```
    8. 启动django
    ```
    python manage.py runserver 0.0.0.0:8000
  2. 测试

    本机链接localhost:8000

    手机链接IP

最近访客