NetSim Source Code Help
Loading...
Searching...
No Matches
Congestion.c
Go to the documentation of this file.
1/************************************************************************************
2* Copyright (C) 2020 *
3* TETCOS, Bangalore. India *
4* *
5* Tetcos owns the intellectual property rights in the Product and its content. *
6* The copying, redistribution, reselling or publication of any or all of the *
7* Product or its content without express prior written consent of Tetcos is *
8* prohibited. Ownership and / or any other right relating to the software and all *
9* intellectual property rights therein shall remain at all times with Tetcos. *
10* *
11* Author: Shashi Kant Suman *
12* *
13* ---------------------------------------------------------------------------------*/
14#include "main.h"
15#include "TCP.h"
16
17//#define _TEST_CONGESTION_
18
19#ifdef _TEST_CONGESTION_
20static FILE* fp;
21#endif
24
25#define BICTCP_BETA_SCALE 1024 /* Scale factor beta calculation
26 * max_cwnd = snd_cwnd * beta
27 */
28
29#define BICTCP_B 4 /*
30 * In binary search,
31 * go to point (max+min)/N
32 */
34typedef struct stru_bic
39 double beta;
42 UINT32 cnt; /* increase cwnd by 1 after ACKs */
43 UINT32 last_max_cwnd; /* last maximum snd_cwnd */
44 UINT32 loss_cwnd; /* congestion window at last loss */
45 UINT32 last_cwnd; /* the last snd_cwnd */
46 UINT32 last_time; /* time when updated last_cwnd */
47 UINT32 epoch_start; /* beginning of an epoch */
48#define ACK_RATIO_SHIFT 4
49 UINT32 delayed_ack; /* estimate the ratio of Packets/ACKs << 4 */
50
54typedef struct stru_congestion_var
56 UINT16 SMSS; ///< To store the size of the largest segment that the sender can transmit.
57 UINT16 RMSS; ///< To store the size of the largest segment that the receiver is willing to accept.
58 UINT16 IW; ///< Size of the sender's congestion window after the three-way handshake is completed.
59 UINT16 LW;
60 UINT16 ssthresh; ///< To store slow start threshold value
61 UINT16 cwnd; ///< To store Congestion window size value.
62 UINT16 rwnd; ///< To store the most recently advertised receiver window size value.
63 double lastWinUpdateTime;
64
65 //Fast Retransmit
69 //Fast Recovery
70 bool isFastRecovery;
72 //new reno modification for fast recovery
75 //SACK
78 //BIC
79 BIC bic;
81
82static inline bool isReno(PNETSIM_SOCKET s)
84 return s->tcb->variant == TCPVariant_RENO ||
86}
87
88static inline bool isBIC(PNETSIM_SOCKET s)
89{
90 return s->tcb->variant == TCPVariant_BIC;
91}
92
93static inline bool isNewReno(PNETSIM_SOCKET s)
94{
95 return s->tcb->variant == TCPVariant_NEWRENO;
96}
97
98static inline bool isFastRetransmit(PNETSIM_SOCKET s)
99{
100 return s->tcb->variant == TCPVariant_TAHOE ||
101 s->tcb->variant == TCPVariant_RENO ||
103}
104
105static inline bool isFastRecovery(PNETSIM_SOCKET s)
106{
107 return s->tcb->variant == TCPVariant_RENO ||
110}
111
113{
115}
116
118{
119 s->tcb->congestionData = data;
120}
121
123{
124 return get_congestionvar(s)->SMSS;
125}
126
128{
129 return get_congestionvar(s)->cwnd;
130}
131
133{
135 if (s->tcb->isWindowScaling)
136 {
137 UINT32 c = var->rwnd;
138 return c << s->tcb->Rcv.Wind_Shift;
139 }
140 else
142 return var->rwnd;
143 }
144}
145
146static void set_ssthres(PNETSIM_SOCKET s, UINT32 newssthres)
147{
149 if (s->tcb->isWindowScaling)
150 {
151 UINT32 c = (UINT32)newssthres;
152 var->ssthresh = (UINT16)(c >> s->tcb->Snd.Wind_Shift);
153 }
154 else
156 var->ssthresh = (UINT16)newssthres;
157 }
158}
159
161{
163 UINT32 c = (UINT32)var->ssthresh;
164 if (s->tcb->isWindowScaling)
165 {
166 return c << s->tcb->Snd.Wind_Shift;
167 }
168 else
170 return c;
171 }
172}
173
174static void set_cwnd(PNETSIM_SOCKET s, UINT32 newcwnd)
175{
177 if (s->tcb->isWindowScaling)
178 {
179 UINT32 c = (UINT32)newcwnd;
180 var->cwnd = (UINT16)(c >> s->tcb->Snd.Wind_Shift);
181 assert(var->cwnd < 65535);
182 if (!var->cwnd)
183 var->cwnd = 1;
184 }
185 else
187 var->cwnd = (UINT16)newcwnd;
188 }
189}
190
192{
194 UINT32 c = (UINT32)var->cwnd;
195 if (s->tcb->isWindowScaling)
196 {
197 return c << s->tcb->Snd.Wind_Shift;
198 }
199 else
201 return c;
202 }
203}
204
206{
208 if (s->tcb->isWindowScaling)
209 {
210 UINT32 c = (UINT32)var->cwnd;
211 return (UINT32)(c << s->tcb->Snd.Wind_Shift);
212 }
213 else
215 return (UINT32)var->cwnd;
216 }
217}
218
220{
221 return (get_cwnd(s) <= get_ssthres(s));
222}
223
224static inline void bictcp_reset(PBIC ca)
225{
226 ca->cnt = 0;
227 ca->last_max_cwnd = 0;
228 ca->last_cwnd = 0;
229 ca->last_time = 0;
230 ca->epoch_start = 0;
231 ca->delayed_ack = 2 << ACK_RATIO_SHIFT;
232}
233
234static void bictcp_init(PNETSIM_SOCKET sk, PTCP_DEV_VAR tcp)
235{
236 PBIC bic = &get_congestionvar(sk)->bic;
237
238 bictcp_reset(bic);
239 bic->loss_cwnd = 0;
240
241 bic->low_window = tcp->low_window;
242 bic->max_increment = tcp->max_increment;
243 bic->fast_convergence = true;
244 bic->beta = tcp->beta;
245 bic->smooth_part = tcp->smooth_part;
246}
247
248static void init_congestion(PNETSIM_SOCKET s)
249{
252 if (!var)
253 {
254 var = (PCONGESTIONVAR)calloc(1, sizeof* var);
255 set_congestionvar(s, var);
256 }
257 var->SMSS = tcp->MSS;
258 var->RMSS = tcp->MSS;
259 set_ssthres(s, tcp->initSSThresh);
260 var->cwnd = var->ssthresh;
261 var->rwnd = var->ssthresh;
262
264
265 if(isNewReno(s))
266 var->recover = s->tcb->ISS;
267
268 if (isBIC(s))
269 bictcp_init(s, tcp);
270
271#ifdef _TEST_CONGESTION_
272 fp = fopen("Congestion.csv","w");
273 fprintf(fp, "Called For,Time,CWND,ssThres,Flight Size,Ackno,UNA,\n");
274 fflush(fp);
275#endif
276}
277
278static void increase_cwnd(PNETSIM_SOCKET s, UINT16 increase)
279{
281 if (s->tcb->isWindowScaling)
282 {
284 c += increase;
285 UINT32 cwnd = c >> s->tcb->Snd.Wind_Shift;
286 if (cwnd >= 65535)
287 var->cwnd = 65535; // Don't want to do this. But no option.
288 else
289 var->cwnd = (UINT16)cwnd;
290 assert(var->cwnd <= 65535);
291 }
292 else
293 {
294 UINT32 c = var->cwnd + increase;
295 if (c >= 65535)
296 var->cwnd = 65535; // Don't want to do this. But no option.
297 else
298 var->cwnd = var->cwnd + increase;
299 }
300}
301
302//RFC 3390
304{
307
308 if (var->SMSS > 2190)
309 var->IW = max(2 * var->SMSS, 2 * t->MSS);
310 else if (var->SMSS > 1095)
311 var->IW = max(3 * var->SMSS, 3 * t->MSS);
312 else if (var->SMSS <= 1095)
313 var->IW = max(4 * var->SMSS, 4 * t->MSS);
314}
315
316static void congestion_set_MSS(PNETSIM_SOCKET s, UINT16 mss)
317{
319 var->SMSS = min(var->SMSS, mss);
320 var->RMSS = min(var->RMSS, mss);
321
323
324 var->LW = var->SMSS;
326 set_cwnd(s, var->IW);
327 var->rwnd = var->IW;
328}
329
331{
332 return (s->tcb->SEG.ACK <= s->tcb->SND.UNA);
333}
334
336{
337 return s->tcb->SEG.ACK >= var->recover;
338}
339
340static void slowStart(PNETSIM_SOCKET s, PCONGESTIONVAR var)
341{
342 //Slow start mode
343 UINT16 N; /* N is the number of previously unacknowledged
344 * bytes acknowledged in the incoming ACK.
345 */
346 N = (UINT16)(s->tcb->SEG.ACK - s->tcb->SND.UNA);
347 increase_cwnd(s, min(N, var->SMSS));
348}
349
351{
352 //Congestion avoidance mode
353 double RTT = get_RTT(s->tcb, s->tcb->SEG.ACK);
354 if (var->lastWinUpdateTime +
355 RTT < pstruEventDetails->dEventTime)
356 {
358 UINT16 N = (UINT16)(s->tcb->SEG.ACK - s->tcb->SND.UNA);
359 increase_cwnd(s, min(N, var->SMSS));
360 }
361}
362
364{
365 /* RFC 5681 page 9*/
366 if (var->dupAckCount == TCP_DupThresh)
367 {
368 /*
369 2. When the third duplicate ACK is received, a TCP MUST set ssthresh
370 to no more than the value given in equation (4)
371 ssthresh = max (FlightSize / 2, 2*SMSS) (4)
372 */
373 UINT16 FlightSize = (UINT16)(s->tcb->SND.NXT - s->tcb->SND.UNA);
374 set_ssthres(s, max(FlightSize / 2, 2 * var->SMSS));
375
376 /*
377 3. The lost segment starting at SND.UNA MUST be retransmitted and
378 cwnd set to ssthresh plus 3*SMSS. This artificially "inflates"
379 the congestion window by the number of segments (three) that have
380 left the network and which the receiver has buffered.
381 */
382 set_cwnd(s, get_ssthres(s) + TCP_DupThresh * var->SMSS);
384
386
387 if (s->tcb->isSackOption)
388 {
390 var->isLossRecoveryPhase = true;
391 }
392 }
393 else
394 {
395 /*
396 4. For each additional duplicate ACK received(after the third),
397 cwnd MUST be incremented by SMSS.This artificially inflates the
398 congestion window in order to reflect the additional segment that
399 has left the network.
400 */
401 increase_cwnd(s, var->SMSS);
402
403 if (s->tcb->isSackOption &&
405 {
407 }
408 }
409}
410
412{
413 var->isFastRecovery = false;
414 var->dupAckCount = 0;
415 set_cwnd(s, get_ssthres(s));
416}
417
419{
420 var->dupAckCount = 0;
421 if (isFullAck(s, var))
422 {
423 //Full Ack
424 UINT16 FlightSize = (UINT16)(s->tcb->SND.NXT - s->tcb->SND.UNA);
425 set_cwnd(s,
427 max(FlightSize, var->SMSS) + var->SMSS)); //---(1)
428
429 //var->cwnd = var->ssthresh; //----(2)
430 var->isFastRecovery = false;
431 }
432 else
433 {
434 //Partial Ack
435 increase_cwnd (s, (UINT16)(s->tcb->SEG.ACK - var->recover));
437 }
438}
440/*
441* behave like Reno until low_window is reached,
442* then increase congestion window slowly
443*/
445{
446 PBIC ca = &get_congestionvar(sk)->bic;
447
448 UINT32 segCwnd = (UINT32)get_cwnd(sk)/sk->tcb->get_MSS(sk);
449
450 ca->epoch_start = 0; /* end of epoch */
451
452 /* Wmax and fast convergence */
453 if (segCwnd < ca->last_max_cwnd && ca->fast_convergence)
454 {
455 ca->last_max_cwnd = (UINT32)(segCwnd * ca->beta);
456 }
457 else
458 {
459 ca->last_max_cwnd = segCwnd;
460 }
461 ca->loss_cwnd = segCwnd;
462 UINT16 FlightSize = (UINT16)(sk->tcb->SND.NXT - sk->tcb->SND.UNA);
463
464 if (segCwnd <= ca->low_window)
465 return max(2 * sk->tcb->get_MSS(sk), FlightSize / 2);
466 else
467 return (UINT32)(max(segCwnd * ca->beta, 2.0) * sk->tcb->get_MSS(sk));
469
470/*
471* Compute congestion window to use.
472*/
473static inline void bictcp_update(PNETSIM_SOCKET sk)
474{
476 PBIC ca = &c->bic;
477 UINT32 cwnd = (UINT32)get_cwnd(sk)/sk->tcb->get_MSS(sk);
478
479 ca->last_cwnd = cwnd;
481
482 if (ca->epoch_start == 0) /* record the beginning of an epoch */
484
485 /* start off normal */
486 if (cwnd <= ca->low_window)
487 {
488 ca->cnt = cwnd;
489 return;
490 }
491
492 /* binary increase */
493 if (cwnd < ca->last_max_cwnd)
494 {
495 UINT32 dist = (ca->last_max_cwnd - cwnd) / BICTCP_B;
496
497 if (dist > ca->max_increment)
498 {
499 /* linear increase */
500 ca->cnt = cwnd / ca->max_increment;
501 }
502 else if (dist <= 1U)
503 {
504 /* smoothed binary search increase: when our window is really
505 * close to the last maximum, we parameterize in m_smoothPart the number
506 * of RTT needed to reach that window.
507 */
508 ca->cnt = (cwnd * ca->smooth_part) / BICTCP_B;
509 }
510 else
511 {
512 /* binary search increase */
513 ca->cnt = cwnd / dist;
514 }
515 }
516 else
517 {
518 /* slow start AMD linear increase */
519 if (cwnd < ca->last_max_cwnd + BICTCP_B)
520 {
521 /* slow start */
522 ca->cnt = (cwnd * ca->smooth_part) / BICTCP_B;
523 }
524 else if (cwnd < ca->last_max_cwnd + ca->max_increment*(BICTCP_B - 1))
525 {
526 /* slow start */
527 ca->cnt = (cwnd * (BICTCP_B - 1))
528 / (cwnd - ca->last_max_cwnd);
529 }
530 else
531 {
532 /* linear increase */
533 ca->cnt = cwnd / ca->max_increment;
534 }
535 }
536 /* if in slow start or link utilization is very low */
537 if (ca->last_max_cwnd == 0)
538 {
539 if (ca->cnt > 20) /* increase cwnd 5% per RTT */
540 ca->cnt = 20;
541 }
542
543 ca->cnt = (ca->cnt << ACK_RATIO_SHIFT) / ca->delayed_ack;
544 if (ca->cnt == 0) /* cannot be zero */
545 ca->cnt = 1;
546
547}
548
549static void bictcp_cong_avoid(PNETSIM_SOCKET sk, UINT32 segmentAcked)
550{
552
553 if (tcp_in_slow_start(sk))
554 {
556 segmentAcked--;
557 }
558
559 if(!tcp_in_slow_start(sk) && segmentAcked > 0)
560 {
561 PBIC bic = &var->bic;
562
563 bic->cwndcnt += segmentAcked;
564 bictcp_update(sk);
565 UINT32 cnt = bic->cnt;
566 /* According to the BIC paper and RFC 6356 even once the new cwnd is
567 * calculated you must compare this to the number of ACKs received since
568 * the last cwnd update. If not enough ACKs have been received then cwnd
569 * cannot be updated.
570 */
571 if (bic->cwndcnt > cnt)
572 {
573 increase_cwnd(sk, var->SMSS);
574 bic->cwndcnt = 0;
575 }
576 else
577 {
578 //Not enough segments have been ACKed to increment cwnd
579 }
580 }
581}
582
584{
586
587 if (var->dupAckCount == TCP_DupThresh)
588 {
589 UINT32 ssThresh = bictcp_recalc_ssthresh(s);
590 set_ssthres(s, (UINT16)ssThresh);
591
592 /*
593 3. The lost segment starting at SND.UNA MUST be retransmitted and
594 cwnd set to ssthresh plus 3*SMSS. This artificially "inflates"
595 the congestion window by the number of segments (three) that have
596 left the network and which the receiver has buffered.
597 */
598 set_cwnd(s, get_ssthres(s) + TCP_DupThresh * var->SMSS);
600
602
603 if (s->tcb->isSackOption)
604 {
606 var->isLossRecoveryPhase = true;
607 }
608 }
609 else
610 {
611 /*
612 4. For each additional duplicate ACK received(after the third),
613 cwnd MUST be incremented by SMSS.This artificially inflates the
614 congestion window in order to reflect the additional segment that
615 has left the network.
616 */
617 increase_cwnd(s, var->SMSS);
618
619 if (s->tcb->isSackOption &&
621 {
623 }
624 }
626
627/* Track delayed acknowledgment ratio using sliding window
628* ratio = (15*ratio + sample) / 16
629*/
630static void bictcp_acked(PNETSIM_SOCKET sk)
631{
632 BIC ca = get_congestionvar(sk)->bic;
633
634 UINT32 pkts_acked = (sk->tcb->SEG.ACK - sk->tcb->SND.UNA) /
635 sk->tcb->get_MSS(sk);
637 ca.delayed_ack += pkts_acked -
639}
640
642{
644
645 if (get_cwnd(s) <= get_ssthres(s))
646 slowStart(s, var);
647 else
648 CongestionAvoidance(s, var);
649
650#ifdef _TEST_CONGESTION_
651 fprintf(fp, "Ack,%lf,%d,%d,%d,%d,%d\n",
654 get_ssthres(s),
655 s->tcb->SND.NXT - s->tcb->SND.UNA,
656 s->tcb->SEG.ACK,s->tcb->SND.UNA);
657 fflush(fp);
658#endif
659}
660
662{
664 bool isdup = isDupAck(s, var);
665 if (isdup)
666 {
667 var->dupAckCount++;
668 if (var->dupAckCount < TCP_DupThresh)
669 {
670 if (s->tcb->isSackOption &&
671 tcp_sack_isLost(s, get_highAck(s) + 1))
672 FastRetransmit(s, var);
673 }
674 else
675 {
676 FastRetransmit(s, var);
677 }
678 }
679 else if (var->dupAckCount)
680 {
681 var->dupAckCount = 0;
682 set_cwnd(s, var->LW);
683 }
684 else
685 {
686 if (get_cwnd(s) <= get_ssthres(s))
687 slowStart(s, var);
688 else
689 CongestionAvoidance(s, var);
690 }
691
692#ifdef _TEST_CONGESTION_
693 fprintf(fp, "Ack,%lf,%d,%d,%d,%d,%d\n",
696 get_ssthres(s),
697 s->tcb->SND.NXT - s->tcb->SND.UNA,
698 s->tcb->SEG.ACK,s->tcb->SND.UNA);
699 fflush(fp);
700#endif
701}
702
704{
706 bool isdup = isDupAck(s, var);
707 if (isdup)
708 {
709 var->dupAckCount++;
710 if (var->dupAckCount < TCP_DupThresh)
711 {
712 if (s->tcb->isSackOption &&
713 tcp_sack_isLost(s, get_highAck(s) + 1))
714 FastRetransmit(s, var);
715 }
716 else
717 {
718 FastRetransmit(s, var);
719 }
720 }
721 else if (var->isFastRecovery)
722 {
723 FastRecovery(s, var);
724 }
725 else
726 {
727 if (get_cwnd(s) <= get_ssthres(s))
728 slowStart(s, var);
729 else
730 CongestionAvoidance(s, var);
731 }
732
733#ifdef _TEST_CONGESTION_
734 fprintf(fp, "Ack,%lf,%d,%d,%d,%d,%d\n",
737 get_ssthres(s),
738 s->tcb->SND.NXT - s->tcb->SND.UNA,
739 s->tcb->SEG.ACK, s->tcb->SND.UNA);
740 fflush(fp);
741#endif
742}
743
745{
747 bool isdup = isDupAck(s, var);
748 if (isdup)
749 {
750 var->dupAckCount++;
751 if (var->dupAckCount < TCP_DupThresh)
752 {
753 if (s->tcb->isSackOption &&
754 tcp_sack_isLost(s, get_highAck(s) + 1))
755 FastRetransmit(s, var);
756 }
757 else
758 {
759 if (var->recover < s->tcb->SEG.ACK - 1)
760 {
761 var->recover = s->tcb->SND.NXT;
762
763 FastRetransmit(s, var);
764 }
765 }
766 }
767 else if (var->isFastRecovery)
768 {
769 newReno_FastRecovery(s, var);
770 }
771 else
772 {
773 if (get_cwnd(s) <= get_ssthres(s))
774 slowStart(s, var);
775 else
776 CongestionAvoidance(s, var);
777 }
778
779#ifdef _TEST_CONGESTION_
780 fprintf(fp, "Ack,%lf,%d,%d,%d,%d,%d\n",
783 get_ssthres(s),
784 s->tcb->SND.NXT - s->tcb->SND.UNA,
785 s->tcb->SEG.ACK, s->tcb->SND.UNA);
786 fflush(fp);
787#endif
788}
789
790static void bic_ack_received(PNETSIM_SOCKET s)
791{
793 UINT32 segmentAcked = (s->tcb->SEG.ACK - s->tcb->SND.UNA)/
794 s->tcb->get_MSS(s);
795
796 bool isdup = isDupAck(s, var);
797 if (isdup)
798 {
799 var->dupAckCount++;
800 if (var->dupAckCount < TCP_DupThresh)
801 {
802 if (s->tcb->isSackOption &&
803 tcp_sack_isLost(s, get_highAck(s) + 1))
804 {
806 }
807 }
808 else
809 {
811 }
812 }
813 else if (var->isFastRecovery)
814 {
815 FastRecovery(s, var);
816 }
817 else
818 {
819 bictcp_acked(s);
820 bictcp_cong_avoid(s,segmentAcked);
821 }
822
823#ifdef _TEST_CONGESTION_
824 fprintf(fp, "Ack,%lf,%d,%d,%d,%d,%d\n",
827 get_ssthres(s),
828 s->tcb->SND.NXT - s->tcb->SND.UNA,
829 s->tcb->SEG.ACK, s->tcb->SND.UNA);
830 fflush(fp);
831#endif
832}
833
835{
837 UINT16 FlightSize = (UINT16)(s->tcb->SND.NXT - s->tcb->SND.UNA);
838 set_ssthres(s, max(FlightSize / 2, 2 * var->SMSS));
839 set_cwnd(s, var->LW);
840
841 if (isNewReno(s))
842 {
843 var->recover = s->tcb->SND.NXT;
844 var->isFastRecovery = false;
845 }
846
847#ifdef _TEST_CONGESTION_
848 fprintf(fp, "RTO,%lf,%d,%d,%d,%d,%d\n",
851 get_ssthres(s),
852 s->tcb->SND.NXT - s->tcb->SND.UNA,
853 s->tcb->SEG.ACK, s->tcb->SND.UNA);
854 fflush(fp);
855#endif
856}
857
859{
861
862 switch (s->tcb->variant)
863 {
866 break;
867 case TCPVariant_TAHOE:
869 break;
870 case TCPVariant_RENO:
872 break;
875 break;
876 case TCPVariant_BIC:
878 break;
879 case TCPVariant_CUBIC:
882 //Other function will work as both structure are same initially. :):)
883 //But is it correct to do? Nope.
884 break;
885 default:
886 fnNetSimError("Unknown TCP variant %d in %s\n",
887 s->tcb->variant,
888 __FUNCTION__);
889 break;
890 }
891
897
899}
static bool isReno(PNETSIM_SOCKET s)
Definition: Congestion.c:77
static void set_congestionvar(PNETSIM_SOCKET s, PCONGESTIONVAR data)
Definition: Congestion.c:112
static void bic_ack_received(PNETSIM_SOCKET s)
Definition: Congestion.c:785
static UINT16 congestion_get_WND(PNETSIM_SOCKET s)
Definition: Congestion.c:122
static void slowStart(PNETSIM_SOCKET s, PCONGESTIONVAR var)
Definition: Congestion.c:335
static bool isBIC(PNETSIM_SOCKET s)
Definition: Congestion.c:83
static UINT32 get_ssthres(PNETSIM_SOCKET s)
Definition: Congestion.c:155
#define ACK_RATIO_SHIFT
Definition: Congestion.c:43
static void newReno_FastRecovery(PNETSIM_SOCKET s, PCONGESTIONVAR var)
Definition: Congestion.c:413
static bool isFastRecovery(PNETSIM_SOCKET s)
Definition: Congestion.c:100
void cubic_ack_received(PNETSIM_SOCKET s)
Definition: CUBIC.c:693
static void congestion_set_IW(PNETSIM_SOCKET s)
Definition: Congestion.c:298
static bool isNewReno(PNETSIM_SOCKET s)
Definition: Congestion.c:88
static void bictcp_acked(PNETSIM_SOCKET sk)
Definition: Congestion.c:625
struct stru_congestion_var * PCONGESTIONVAR
static bool isFastRetransmit(PNETSIM_SOCKET s)
Definition: Congestion.c:93
void init_cubic(PNETSIM_SOCKET s)
Definition: CUBIC.c:290
static void set_ssthres(PNETSIM_SOCKET s, UINT32 newssthres)
Definition: Congestion.c:141
static bool isDupAck(PNETSIM_SOCKET s, PCONGESTIONVAR var)
Definition: Congestion.c:325
static bool isFullAck(PNETSIM_SOCKET s, PCONGESTIONVAR var)
Definition: Congestion.c:330
static UINT16 congestion_get_MSS(PNETSIM_SOCKET s)
Definition: Congestion.c:117
static void FastRetransmit(PNETSIM_SOCKET s, PCONGESTIONVAR var)
Definition: Congestion.c:358
static void bictcp_fastretransmit(PNETSIM_SOCKET s)
Definition: Congestion.c:578
static UINT32 bictcp_recalc_ssthresh(PNETSIM_SOCKET sk)
Definition: Congestion.c:439
static PCONGESTIONVAR get_congestionvar(PNETSIM_SOCKET s)
Definition: Congestion.c:107
static void bictcp_cong_avoid(PNETSIM_SOCKET sk, UINT32 segmentAcked)
Definition: Congestion.c:544
static void increase_cwnd(PNETSIM_SOCKET s, UINT16 increase)
Definition: Congestion.c:273
static void bictcp_init(PNETSIM_SOCKET sk, PTCP_DEV_VAR tcp)
Definition: Congestion.c:229
static void init_congestion(PNETSIM_SOCKET s)
Definition: Congestion.c:243
static void congestion_rto_timeout(PNETSIM_SOCKET s)
Definition: Congestion.c:829
static void bictcp_update(PNETSIM_SOCKET sk)
Definition: Congestion.c:468
static UINT32 get_cwnd(PNETSIM_SOCKET s)
Definition: Congestion.c:186
static bool tcp_in_slow_start(PNETSIM_SOCKET s)
Definition: Congestion.c:214
static void oldtahoe_ack_received(PNETSIM_SOCKET s)
Definition: Congestion.c:636
void congestion_setcallback(PNETSIM_SOCKET s)
Definition: Congestion.c:853
static void bictcp_reset(PBIC ca)
Definition: Congestion.c:219
#define BICTCP_B
Definition: Congestion.c:27
UINT32 get_cwnd_print(PNETSIM_SOCKET s)
Definition: Congestion.c:200
static void set_cwnd(PNETSIM_SOCKET s, UINT32 newcwnd)
Definition: Congestion.c:169
static void congestion_set_MSS(PNETSIM_SOCKET s, UINT16 mss)
Definition: Congestion.c:311
static void tahoe_ack_received(PNETSIM_SOCKET s)
Definition: Congestion.c:656
static UINT32 congestion_get_RCV_WND(PNETSIM_SOCKET s)
Definition: Congestion.c:127
struct stru_bic BIC
struct stru_congestion_var CONGESTIONVAR
struct stru_bic * PBIC
static void reno_ack_received(PNETSIM_SOCKET s)
Definition: Congestion.c:698
static void CongestionAvoidance(PNETSIM_SOCKET s, PCONGESTIONVAR var)
Definition: Congestion.c:345
static void newreno_ack_received(PNETSIM_SOCKET s)
Definition: Congestion.c:739
static void FastRecovery(PNETSIM_SOCKET s, PCONGESTIONVAR var)
Definition: Congestion.c:406
#define c
#define UINT
Definition: Linux.h:38
#define UINT32
Definition: Linux.h:35
#define fnNetSimError(x,...)
Definition: Linux.h:56
#define UINT16
Definition: Linux.h:33
#define min(a, b)
Definition: Linux.h:106
#define max(a, b)
Definition: Linux.h:107
#define calloc(c, s)
Definition: Memory.h:29
bool tcp_sack_lossRecoveryPhase(PNETSIM_SOCKET s)
Definition: SACK.c:321
UINT32 get_highAck(PNETSIM_SOCKET s)
Definition: SACK.c:23
void tcp_sack_fastRetransmit(PNETSIM_SOCKET s)
Definition: SACK.c:312
bool tcp_sack_isLost(PNETSIM_SOCKET s, UINT seqNum)
Definition: SACK.c:170
EXPORTED struct stru_NetSim_EventDetails * pstruEventDetails
Definition: Stack.h:837
double get_RTT(PTCB tcb, UINT ackNo)
Definition: TCB.c:372
static PTCP_DEV_VAR GET_TCP_DEV_VAR(NETSIM_ID d)
Definition: TCP.h:167
UINT32 window_scale_get_cwnd(PNETSIM_SOCKET s)
Definition: WindowScale.c:50
void resend_segment_without_timeout(PNETSIM_SOCKET s, UINT seq)
Definition: TCP_Outgoing.c:79
#define TCP_DupThresh
Definition: TCP.h:51
@ TCPVariant_CUBIC
Definition: TCP.h:78
@ TCPVariant_OLDTAHOE
Definition: TCP.h:73
@ TCPVariant_RENO
Definition: TCP.h:75
@ TCPVariant_BIC
Definition: TCP.h:77
@ TCPVariant_TAHOE
Definition: TCP.h:74
@ TCPVariant_NEWRENO
Definition: TCP.h:76
PTCB tcb
Definition: TCP.h:132
NETSIM_ID localDeviceId
Definition: TCP.h:125
double beta
Definition: TCP.h:159
UINT16 MSS
Definition: TCP.h:148
UINT16 initSSThresh
Definition: TCP.h:147
UINT32 smooth_part
Definition: TCP.h:162
UINT32 max_increment
Definition: TCP.h:161
UINT32 low_window
Definition: TCP.h:160
UINT32 last_max_cwnd
Definition: Congestion.c:38
UINT32 last_time
Definition: Congestion.c:41
UINT32 last_cwnd
Definition: Congestion.c:40
UINT32 low_window
Definition: Congestion.c:31
double beta
Definition: Congestion.c:34
UINT32 epoch_start
Definition: Congestion.c:42
UINT32 loss_cwnd
Definition: Congestion.c:39
UINT32 max_increment
Definition: Congestion.c:32
UINT32 delayed_ack
Definition: Congestion.c:44
bool fast_convergence
Definition: Congestion.c:33
UINT32 cnt
Definition: Congestion.c:37
UINT32 cwndcnt
Definition: Congestion.c:46
UINT32 smooth_part
Definition: Congestion.c:35
UINT16 IW
Size of the sender's congestion window after the three-way handshake is completed.
Definition: Congestion.c:53
UINT16 RMSS
To store the size of the largest segment that the receiver is willing to accept.
Definition: Congestion.c:52
UINT16 ssthresh
To store slow start threshold value.
Definition: Congestion.c:55
UINT16 rwnd
To store the most recently advertised receiver window size value.
Definition: Congestion.c:57
double lastWinUpdateTime
Definition: Congestion.c:58
UINT16 SMSS
To store the size of the largest segment that the sender can transmit.
Definition: Congestion.c:51
UINT16 cwnd
To store Congestion window size value.
Definition: Congestion.c:56
void(* init_congestionalgo)(PNETSIM_SOCKET)
Definition: TCB.h:131
struct stru_tcp_Transmission_Control_Block::stru_tcb_send_seq_var SND
void(* rto_expired)(PNETSIM_SOCKET)
Definition: TCB.h:133
UINT32(* get_RCVWND)(PNETSIM_SOCKET)
Definition: TCB.h:137
struct stru_tcp_Transmission_Control_Block::stru_tcp_rcv Rcv
UINT16(* get_MSS)(PNETSIM_SOCKET)
Definition: TCB.h:134
struct stru_tcp_Transmission_Control_Block::stru_tcp_snd Snd
void(* set_MSS)(PNETSIM_SOCKET s, UINT16)
Definition: TCB.h:136
UINT16(* get_WND)(PNETSIM_SOCKET)
Definition: TCB.h:135
void(* ack_received)(PNETSIM_SOCKET)
Definition: TCB.h:132
struct stru_tcp_Transmission_Control_Block::stru_tcb_curr_seg_var SEG