-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfigure-5.10-congctrl_dynamics.py
47 lines (40 loc) · 1.59 KB
/
figure-5.10-congctrl_dynamics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# congctrl-dynamics.py - phase plots for congestion control dynamis
# RMM, 7 Apr 2024
import matplotlib.pyplot as plt
import numpy as np
import control as ct
import fbs # FBS plotting customizations
# Define the system dynamics
def _congctrl_update(t, x, u, params):
# Number of sources per state of the simulation
M = x.size - 1 # general case
assert M == 1 # make sure nothing funny happens here
# Remaining parameters
N = params.get('N', M) # number of sources
rho = params.get('rho', 2e-4) # RED parameter = pbar / (bupper-blower)
c = params.get('c', 10) # link capacity (Mp/ms)
# Compute the derivative (last state = bdot)
return np.append(
c / x[M] - (rho * c) * (1 + (x[:-1]**2) / 2),
N/M * np.sum(x[:-1]) * c / x[M] - c)
congctrl = ct.nlsys(
_congctrl_update, states=2, inputs=0,
params={'N': 60, 'rho': 2e-4, 'c': 10})
fbs.figure()
ct.phase_plane_plot(congctrl, [0, 10, 10, 500], 100)
plt.axis([0, 10, 0, 500])
plt.suptitle("")
plt.title("$\\rho = 2 \\times 10^{-4}$, $c = 10$ pkts/msec")
plt.xlabel("Window size, $w$ [pkts]")
plt.ylabel("Buffer size, $b$ [pkts]")
fbs.savefig('figure-5.10-congctrl_dynamics-pp1.png')
fbs.figure()
ct.phase_plane_plot(
congctrl, [0, 10, 10, 500], 100,
params={'rho': 4e-4, 'c': 20})
plt.axis([0, 10, 0, 500])
plt.suptitle("")
plt.title("$\\rho = 4 \\times 10^{-4}$, $c = 20$ pkts/msec")
plt.xlabel("Window size, $w$ [pkts]")
plt.ylabel("Buffer size, $b$ [pkts]")
fbs.savefig('figure-5.10-congctrl_dynamics-pp2.png')