Skip to content

Commit

Permalink
Add PCC to congestion control algorithms.
Browse files Browse the repository at this point in the history
Minor fix.
  • Loading branch information
Unknown committed Feb 8, 2019
1 parent 478df3d commit fa804fd
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ venv.bak/
.mypy_cache/

################################################### Misc
contrib/oflops
contrib/openflow
.DS_Store
*.sublime-workspace
*.sublime-project
Expand All @@ -148,3 +146,4 @@ dc_gym/data
plots/
dc_gym/control/node_control
dc_gym/monitor/qdisc_stats
*.ko
1 change: 1 addition & 0 deletions contrib/pcc
Submodule pcc added at 2eeadf
6 changes: 3 additions & 3 deletions dc_gym/factories.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import sys
import os
cwd = os.getcwd()
lib_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, lib_dir)
FILE_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, FILE_DIR)


DEFAULT_ENV_CONFIG = {
"input_dir": lib_dir + '/inputs',
"input_dir": FILE_DIR + '/inputs',
"output_dir": cwd + '/results',
"topo": "dumbbell",
"agent": "PPO",
Expand Down
21 changes: 21 additions & 0 deletions dc_gym/topos/topo_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import random
import string

Expand All @@ -9,6 +10,10 @@
from mininet.node import CPULimitedHost
from mininet.util import custom

cwd = os.getcwd()
FILE_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, FILE_DIR)


class BaseTopo():
NAME = "base"
Expand All @@ -23,6 +28,7 @@ def __init__(self, options):
self.host_ctrl_map = {}
self.host_ips = []
self.switch_id = self._generate_switch_id(options)
self.prev_cc = self._get_active_congestion_control()
self._set_congestion_control(options)

def _generate_switch_id(self, options):
Expand All @@ -36,16 +42,25 @@ def _generate_switch_id(self, options):
for ch in range(5)])) for _ in range(5))
return sw_id

def _get_active_congestion_control(self):
prev_cc = os.popen("sysctl -n net.ipv4.tcp_congestion_control").read()
return prev_cc

def _set_congestion_control(self, options):
self.dctcp = False
self.tcp_nv = False
self.pcc = False
if "dctcp" in options:
os.system("modprobe tcp_dctcp")
os.system("sysctl -w net.ipv4.tcp_ecn=1")
self.dctcp = True
elif "tcp_nv" in options:
self.tcp_nv = True
os.system("modprobe tcp_nv")
elif "pcc" in options:
self.pcc = True
if (os.popen("lsmod | grep pcc").read() == ""):
os.system("insmod %s/tcp_pcc.ko" % FILE_DIR)

def _set_host_ip(self, net, topo):
raise NotImplementedError("Method _set_host_ip not implemented!")
Expand Down Expand Up @@ -192,6 +207,8 @@ def _configure_hosts(self):
host.cmd("sysctl -w net.ipv4.tcp_ecn_fallback=0")
elif self.tcp_nv:
host.cmd("sysctl -w net.ipv4.tcp_congestion_control=nv")
elif self.pcc:
host.cmd("sysctl -w net.ipv4.tcp_congestion_control=pcc")

def _configure_network(self):
c0 = RemoteController(self.switch_id + "c0")
Expand All @@ -216,6 +233,10 @@ def get_topo(self):
def delete_topo(self):
if (self.dctcp):
os.system("sysctl -w net.ipv4.tcp_ecn=0")
# reset the active host congestion control to the previous value
cmd = "sysctl -w net.ipv4.tcp_congestion_control=%s" % self.prev_cc
os.system(cmd)
# destroy the mininet
self.net.stop()

def get_sw_ports(self):
Expand Down
7 changes: 7 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ cd contrib
cd ..
fi


# install the PCC kernel module
if [[ $1 = "--pcc" ]]; then
make -C contrib/pcc/src/
cp contrib/pcc/src/tcp_pcc.ko dc_gym/topos
fi

# required for traffic adjustment
sudo apt install -y libnl-route-3-dev

Expand Down
4 changes: 2 additions & 2 deletions run_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
PARSER.add_argument('--transport', dest='transport', default="udp",
help='Choose the transport protocol of the hosts.')
PARSER.add_argument('--agent', '-a', dest='agent', default="PG",
help='must be string of either: PG,'
' DCTCP, TCP_NV or TCP', type=str.lower)
help='must be string of either: PPO, DDPG, PG,'
' DCTCP, TCP_NV, PCC, or TCP', type=str.lower)
ARGS = PARSER.parse_args()


Expand Down
4 changes: 2 additions & 2 deletions run_ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
default='dumbbell', help='The topology to operate on.')
PARSER.add_argument('--agent', '-a', dest='agent', default="PG",
help='must be string of either: PPO, DDPG, PG,'
' DCTCP, TCP_NV or TCP', type=str.lower)
' DCTCP, TCP_NV, PCC, or TCP', type=str.lower)
PARSER.add_argument('--timesteps', '-t', dest='timesteps',
type=int, default=10000,
help='total number of timesteps to train rl agent, '
Expand Down Expand Up @@ -158,7 +158,7 @@ def get_agent(agent_name):
except Exception as e:
print ("%s Loading basic algorithm" % e)
# We use PG as the base class for experiments
agent_class = type(agent_name, (MaxAgent,), {})
agent_class = type(agent_name.upper(), (MaxAgent,), {})
return agent_class


Expand Down

0 comments on commit fa804fd

Please sign in to comment.