% congctrl_dynamics.m - plots for congestion control examples
% 
% RMM, 11 Jul 06

aminit;					% initialize MATLAB

% Set the parameters for the system
congctrl_params;			% load congestion control parameters

% Figure out the equilibrium points for the system
[weq, beq] = congctrl_equil(N, rho, c)

figure(1); clf; subplot(221);
amaxis([0 10 0 500]);
[a, h] = amphaseplot('congctrl', 'timepts', [2 6 18 54], nan, ...
  [0 0; 0 100; 0 200; 0 400; 1 490; 3 490; 5 490; 7 490; ...
   10 100; 10 300; 10 400; 1 0.01; 3 0.01; 5 0.01; 7 0.01; 8.5 0.01], ...
  0:1:200, N, rho, c);
amaxis normal; grid off;
hold on; plot([weq], [beq], 'k.', 'MarkerSize', AM_data_markersize*3);

xlabel('Window size, {\itw} [pkts]');
ylabel('Buffer size, {\itb} [pkts]', 'Rotation', 90); 
  
amprint('congctrlpp-1.eps');

[weq, beq] = congctrl_equil(N, rho*2, c*2)

figure(2); clf; subplot(222);
amaxis([0 10 0 500]);
[a, h] = amphaseplot('congctrl', 'timepts', [2 6 18], nan, ...
  [0 0; 0 100; 0 200; 0 400; 1 495; 3 495; 5 495; 7 495; ...
   10 100; 10 300; 10 400; 1 0.01; 3 0.01; 5 0.01; 7 0.01; 8.5 0.01], ...
  0:1:200, N, rho*2, c*2);
amaxis normal; grid off;

xlabel('Window size, {\itw} [pkts]');
ylabel('Buffer size, {\itb} [pkts]', 'Rotation', 90); 
hold on; plot([weq], [beq], 'k.', 'MarkerSize', AM_data_markersize*3);

amprint('congctrlpp-2.eps');
