20#ifdef _TEST_CONGESTION_
24#define clamp(val, lo, hi) min(max(val, lo), hi)
26#define tcp_time_stamp ((UINT32)(pstruEventDetails->dEventTime/1000))
29#define BICTCP_BETA_SCALE 1024
35#define HYSTART_ACK_TRAIN 0x1
36#define HYSTART_DELAY 0x2
39#define HYSTART_MIN_SAMPLES 8
40#define HYSTART_DELAY_MIN (4U<<3)
41#define HYSTART_DELAY_MAX (16U<<3)
42#define HYSTART_DELAY_THRESH(x) clamp(x, HYSTART_DELAY_MIN, HYSTART_DELAY_MAX)
127 assert(var->
cwnd < 65535);
185 assert(var->
cwnd < 65535);
212 return dividend / divisor;
215#define do_div(x,y) (x=x/y)
219 return (
int)(seq1 - seq2) < 0;
221#define after(seq2, seq1) before(seq1, seq2)
228 int len = (int)strlen(
a);
229 for (i = 0; i < len; i++)
332#pragma warning(disable:4310)
334#pragma warning(default:4310)
340#ifdef _TEST_CONGESTION_
341 fp = fopen(
"Congestion.csv",
"w");
342 fprintf(fp,
"Called For,Time,CWND,ssThres,Flight Size,Ackno,UNA,\n");
362 static const UINT8 v[] = {
363 0, 54, 54, 54, 118, 118, 118, 118,
364 123, 129, 134, 138, 143, 147, 151, 156,
365 157, 161, 164, 168, 170, 173, 176, 179,
366 181, 185, 187, 190, 192, 194, 197, 199,
367 200, 202, 204, 206, 209, 211, 213, 215,
368 217, 219, 221, 222, 224, 225, 227, 229,
369 231, 232, 234, 236, 237, 239, 240, 242,
370 244, 245, 246, 248, 250, 251, 252, 254,
379 b = ((b * 84) >> 8) - 1;
380 shift = (
UINT32)(
a >> (b * 3));
391 x = ((x * 341) >> 10);
424 UINT32 delta, bic_target, max_cnt;
486 offs = ca->
bic_K - t;
488 offs = t - ca->
bic_K;
498 if (bic_target > cwnd)
500 ca->
cnt = cwnd / (bic_target - cwnd);
504 ca->
cnt = 100 * cwnd;
520 delta = (cwnd * scale) >> 3;
521 while (delta && ca->
ack_cnt > delta)
530 max_cnt = cwnd / delta;
531 if (ca->
cnt > max_cnt)
728#ifdef _TEST_CONGESTION_
729 fprintf(fp,
"Ack,%lf,%d,%d,%d,%d,%d\n",
static void cubictcp_acked(PNETSIM_SOCKET sk)
static void cubictcp_update(PNETSIM_SOCKET sk, UINT32 acked)
static bool before(UINT32 seq1, UINT32 seq2)
static void set_congestionvar(PNETSIM_SOCKET s, PCONGESTIONVAR data)
static void slowStart(PNETSIM_SOCKET s, PCONGESTIONVAR var)
static void hystart_update(PNETSIM_SOCKET sk, UINT32 delay)
static UINT32 get_ssthres(PNETSIM_SOCKET s)
#define HYSTART_DELAY_THRESH(x)
#define HYSTART_MIN_SAMPLES
static UINT32 cubictcp_recalc_ssthresh(PNETSIM_SOCKET sk)
static void cubictcp_hystart_reset(PNETSIM_SOCKET sk)
struct stru_cubic * PCUBIC
void cubic_ack_received(PNETSIM_SOCKET s)
static UINT64 div64_u64(UINT64 dividend, UINT64 divisor)
void init_cubic(PNETSIM_SOCKET s)
static void set_ssthres(PNETSIM_SOCKET s, UINT32 newssthres)
static UINT count_bit(UINT64 n)
static bool isDupAck(PNETSIM_SOCKET s, PCONGESTIONVAR var)
static void cubictcp_cong_avoid(PNETSIM_SOCKET sk, UINT32 segmentAcked)
struct stru_congestion_var * PCONGESTIONVAR
static UINT32 cubic_root(UINT64 a)
#define BICTCP_BETA_SCALE
static PCONGESTIONVAR get_congestionvar(PNETSIM_SOCKET s)
static void increase_cwnd(PNETSIM_SOCKET s, UINT16 increase)
#define after(seq2, seq1)
static int tcp_friendliness
static void cubictcp_fastretransmit(PNETSIM_SOCKET s)
static UINT32 get_cwnd(PNETSIM_SOCKET s)
#define HYSTART_ACK_TRAIN
static int hystart_detect
static bool tcp_in_slow_start(PNETSIM_SOCKET s)
static void set_cwnd(PNETSIM_SOCKET s, UINT32 newcwnd)
static void cubictcp_init(PNETSIM_SOCKET sk, PTCP_DEV_VAR tcp)
struct stru_congestion_var CONGESTIONVAR
static UINT32 cubictcp_clock(void)
static UINT32 cube_factor
static void cubictcp_reset(PCUBIC ca)
static void FastRecovery(PNETSIM_SOCKET s, PCONGESTIONVAR var)
static int fast_convergence
static UINT32 cube_rtt_scale
UINT32 get_cwnd_print(PNETSIM_SOCKET s)
static struct stru_802_11_Phy_Parameters_HT a
bool tcp_sack_lossRecoveryPhase(PNETSIM_SOCKET s)
UINT32 get_highAck(PNETSIM_SOCKET s)
void tcp_sack_fastRetransmit(PNETSIM_SOCKET s)
bool tcp_sack_isLost(PNETSIM_SOCKET s, UINT seqNum)
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
double get_RTT(PTCB tcb, UINT ackNo)
static PTCP_DEV_VAR GET_TCP_DEV_VAR(NETSIM_ID d)
UINT32 window_scale_get_cwnd(PNETSIM_SOCKET s)
void resend_segment_without_timeout(PNETSIM_SOCKET s, UINT seq)
UINT32 hystart_low_window
UINT16 IW
Size of the sender's congestion window after the three-way handshake is completed.
UINT16 RMSS
To store the size of the largest segment that the receiver is willing to accept.
UINT16 ssthresh
To store slow start threshold value.
UINT16 rwnd
To store the most recently advertised receiver window size value.
UINT16 SMSS
To store the size of the largest segment that the sender can transmit.
UINT16 cwnd
To store Congestion window size value.
UINT32 hystart_low_window
struct stru_tcp_Transmission_Control_Block::stru_tcb_send_seq_var SND
UINT16(* get_MSS)(PNETSIM_SOCKET)
struct stru_tcp_Transmission_Control_Block::stru_tcp_snd Snd
struct stru_tcp_Transmission_Control_Block::stru_tcb_curr_seg_var SEG