Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use dockerfile to install ns3 and ns3-ai autoly #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ cd $YOUR_NS3_CODE/contrib/ns3-ai/py_interface
pip3 install . --user
```

### use docker to quick install

auto install ns3 and ns3-ai by docker

usage

``` shell
git clone https://github.com/hust-diangroup/ns3-ai.git

cd ns3-ai/docker && sudo sh build.sh
```

#### Baisc usage
``` Python
import py_interface
Expand Down
81 changes: 81 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
FROM ubuntu:latest

ADD sources.list /etc/apt/

RUN apt-get update

RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata

# General dependencies
RUN apt-get install -y \
git \
mercurial
RUN apt-get install -y \
wget \
vim \
autoconf \
bzr \
cvs
RUN apt-get install -y \
unrar \
build-essential \
clang \
valgrind \
gsl-bin
RUN apt-get install -y \
libgslcblas0 \
libgsl-dev \
flex \
bison \
libfl-dev \
tcpdump \
sqlite
RUN apt-get install -y \
sqlite3 \
libsqlite3-dev \
libxml2 \
libxml2-dev \
vtun \
lxc

# QT4 components
RUN apt-get install -y \
qtbase5-dev

# Python components
RUN apt-get install -y \
python \
python-dev \
python-setuptools \
cmake \
libc6-dev \
libc6-dev-i386 \
g++-multilib

# NS-3

# Create working directory
RUN mkdir -p /usr/ns3
WORKDIR /usr

# Fetch NS-3 source
RUN wget http://www.nsnam.org/release/ns-allinone-3.30.tar.bz2
RUN tar -xf ns-allinone-3.30.tar.bz2

# Configure and compile NS-3
RUN cd ns-allinone-3.30&& ./build.py --enable-examples --enable-tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using ns-allinone-3.30 version, can we try to use git to support different versions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you can use "RUN git clone ns3" instead of "wget ns3.tar"

but I don't find the repo of ns3, I'm an ns3 beginner.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NS3 repository is hosted on gitlab: https://gitlab.com/nsnam/ns-3-dev.


RUN ln -s /usr/ns-allinone-3.30/ns-3.30/ /usr/ns3/

# Cleanup
RUN apt-get clean && \
rm -rf /var/lib/apt && \
rm /usr/ns-allinone-3.30.tar.bz2

RUN apt update
RUN apt install unzip

RUN cd /usr/ns-allinone-3.30/ns-3.30/contrib && git clone https://gitee.com/lyon1998/ns3-ai
RUN apt install python3 python3-pip -y
RUN cd /usr/ns-allinone-3.30/ns-3.30 && ./waf configure && ./waf
RUN cd /usr/ns-allinone-3.30/ns-3.30/contrib/ns3-ai/py_interface && pip3 install . --user
7 changes: 7 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
docker rmi -f ns3-3.30
docker build -t ns3-3.30 .

docker stop ns3-3.30
docker rm ns3-3.30

docker run -it --name ns3-3.30 --restart=always ns3-3.30 bash
10 changes: 10 additions & 0 deletions docker/sources.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse