Lines Matching refs:net

61 sctp_enforce_cwnd_limit(struct sctp_association *assoc, struct sctp_nets *net)
64 (net->cwnd > assoc->max_cwnd) &&
65 (net->cwnd > (net->mtu - sizeof(struct sctphdr)))) {
66 net->cwnd = assoc->max_cwnd;
67 if (net->cwnd < (net->mtu - sizeof(struct sctphdr))) {
68 net->cwnd = net->mtu - sizeof(struct sctphdr);
74 sctp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net)
83 net->cwnd = min((net->mtu * 4), max((2 * net->mtu), SCTP_INITIAL_CWND));
91 net->cwnd = (net->mtu - sizeof(struct sctphdr)) * cwnd_in_mtu;
96 net->cwnd /= assoc->numnets;
97 if (net->cwnd < (net->mtu - sizeof(struct sctphdr))) {
98 net->cwnd = net->mtu - sizeof(struct sctphdr);
101 sctp_enforce_cwnd_limit(assoc, net);
102 net->ssthresh = assoc->peers_rwnd;
103 SDT_PROBE5(sctp, cwnd, net, init,
104 stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net,
105 0, net->cwnd);
108 sctp_log_cwnd(stcb, net, 0, SCTP_CWND_INITIALIZATION);
116 struct sctp_nets *net;
126 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
127 t_ssthresh += net->ssthresh;
128 t_cwnd += net->cwnd;
129 if (net->lastsa > 0) {
130 t_ucwnd_sbw += (uint64_t)net->cwnd / (uint64_t)net->lastsa;
140 * (net->fast_retran_loss_recovery == 0)))
142 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
146 if (net->net_ack > 0) {
154 int old_cwnd = net->cwnd;
159 net->ssthresh = (uint32_t)(((uint64_t)4 *
160 (uint64_t)net->mtu *
161 (uint64_t)net->ssthresh) /
167 srtt = net->lastsa;
179 net->ssthresh = (uint32_t)(((uint64_t)4 *
180 (uint64_t)net->mtu *
181 (uint64_t)net->cwnd) /
186 if ((net->cwnd > t_cwnd / 2) &&
187 (net->ssthresh < net->cwnd - t_cwnd / 2)) {
188 net->ssthresh = net->cwnd - t_cwnd / 2;
190 if (net->ssthresh < net->mtu) {
191 net->ssthresh = net->mtu;
194 net->ssthresh = net->cwnd / 2;
195 if (net->ssthresh < (net->mtu * 2)) {
196 net->ssthresh = 2 * net->mtu;
199 net->cwnd = net->ssthresh;
200 sctp_enforce_cwnd_limit(asoc, net);
201 SDT_PROBE5(sctp, cwnd, net, fr,
202 stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net,
203 old_cwnd, net->cwnd);
205 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd),
210 net->partial_bytes_acked = 0;
224 net->fast_retran_loss_recovery = 1;
228 net->fast_recovery_tsn = asoc->sending_seq - 1;
230 net->fast_recovery_tsn = lchk->rec.data.tsn - 1;
234 stcb->sctp_ep, stcb, net,
237 stcb->sctp_ep, stcb, net);
239 } else if (net->net_ack > 0) {
255 cc_bw_same(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw,
260 probepoint = (((uint64_t)net->cwnd) << 32);
261 if (net->rtt > net->cc_mod.rtcc.lbw_rtt + rtt_offset) {
268 SDT_PROBE5(sctp, cwnd, net, rttvar,
270 ((net->cc_mod.rtcc.lbw << 32) | nbw),
271 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
272 net->flight_size,
274 if ((net->cc_mod.rtcc.steady_step) && (inst_ind != SCTP_INST_LOOSING)) {
275 if (net->cc_mod.rtcc.last_step_state == 5)
276 net->cc_mod.rtcc.step_cnt++;
278 net->cc_mod.rtcc.step_cnt = 1;
279 net->cc_mod.rtcc.last_step_state = 5;
280 if ((net->cc_mod.rtcc.step_cnt == net->cc_mod.rtcc.steady_step) ||
281 ((net->cc_mod.rtcc.step_cnt > net->cc_mod.rtcc.steady_step) &&
282 ((net->cc_mod.rtcc.step_cnt % net->cc_mod.rtcc.steady_step) == 0))) {
284 oth = net->cc_mod.rtcc.vol_reduce;
286 oth |= net->cc_mod.rtcc.step_cnt;
288 oth |= net->cc_mod.rtcc.last_step_state;
289 SDT_PROBE5(sctp, cwnd, net, rttstep,
291 ((net->cc_mod.rtcc.lbw << 32) | nbw),
292 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
295 if (net->cwnd > (4 * net->mtu)) {
296 net->cwnd -= net->mtu;
297 net->cc_mod.rtcc.vol_reduce++;
299 net->cc_mod.rtcc.step_cnt = 0;
305 if (net->rtt < net->cc_mod.rtcc.lbw_rtt - rtt_offset) {
313 SDT_PROBE5(sctp, cwnd, net, rttvar,
315 ((net->cc_mod.rtcc.lbw << 32) | nbw),
316 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
317 net->flight_size,
319 if (net->cc_mod.rtcc.steady_step) {
320 oth = net->cc_mod.rtcc.vol_reduce;
322 oth |= net->cc_mod.rtcc.step_cnt;
324 oth |= net->cc_mod.rtcc.last_step_state;
325 SDT_PROBE5(sctp, cwnd, net, rttstep,
327 ((net->cc_mod.rtcc.lbw << 32) | nbw),
328 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
331 if ((net->cc_mod.rtcc.last_step_state == 5) &&
332 (net->cc_mod.rtcc.step_cnt > net->cc_mod.rtcc.steady_step)) {
334 net->cc_mod.rtcc.step_cnt = 0;
337 net->cc_mod.rtcc.last_step_state = 6;
338 net->cc_mod.rtcc.step_cnt = 0;
341 net->cc_mod.rtcc.lbw = nbw;
342 net->cc_mod.rtcc.lbw_rtt = net->rtt;
343 net->cc_mod.rtcc.cwnd_at_bw_set = net->cwnd;
355 probepoint |= ((7 << 16) | net->cc_mod.rtcc.ret_from_eq);
356 SDT_PROBE5(sctp, cwnd, net, rttvar,
358 ((net->cc_mod.rtcc.lbw << 32) | nbw),
359 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
360 net->flight_size,
362 if ((net->cc_mod.rtcc.steady_step) && (inst_ind != SCTP_INST_LOOSING)) {
363 if (net->cc_mod.rtcc.last_step_state == 5)
364 net->cc_mod.rtcc.step_cnt++;
366 net->cc_mod.rtcc.step_cnt = 1;
367 net->cc_mod.rtcc.last_step_state = 5;
368 if ((net->cc_mod.rtcc.step_cnt == net->cc_mod.rtcc.steady_step) ||
369 ((net->cc_mod.rtcc.step_cnt > net->cc_mod.rtcc.steady_step) &&
370 ((net->cc_mod.rtcc.step_cnt % net->cc_mod.rtcc.steady_step) == 0))) {
372 if (net->cwnd > (4 * net->mtu)) {
373 net->cwnd -= net->mtu;
374 net->cc_mod.rtcc.vol_reduce++;
377 net->cc_mod.rtcc.step_cnt = 0;
386 return ((int)net->cc_mod.rtcc.ret_from_eq);
390 cc_bw_decrease(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw, uint64_t rtt_offset,
396 probepoint = (((uint64_t)net->cwnd) << 32);
397 if (net->rtt > net->cc_mod.rtcc.lbw_rtt + rtt_offset) {
400 if ((net->cwnd > net->cc_mod.rtcc.cwnd_at_bw_set) &&
405 SDT_PROBE5(sctp, cwnd, net, rttvar,
407 ((net->cc_mod.rtcc.lbw << 32) | nbw),
408 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
409 net->flight_size,
411 if (net->cc_mod.rtcc.ret_from_eq) {
416 net->ssthresh = net->cwnd - 1;
417 net->partial_bytes_acked = 0;
423 SDT_PROBE5(sctp, cwnd, net, rttvar,
425 ((net->cc_mod.rtcc.lbw << 32) | nbw),
426 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
427 net->flight_size,
430 if (net->cc_mod.rtcc.steady_step) {
431 oth = net->cc_mod.rtcc.vol_reduce;
433 oth |= net->cc_mod.rtcc.step_cnt;
435 oth |= net->cc_mod.rtcc.last_step_state;
436 SDT_PROBE5(sctp, cwnd, net, rttstep,
438 ((net->cc_mod.rtcc.lbw << 32) | nbw),
439 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
446 if ((net->cc_mod.rtcc.vol_reduce) &&
448 net->cwnd += net->mtu;
449 sctp_enforce_cwnd_limit(&stcb->asoc, net);
450 net->cc_mod.rtcc.vol_reduce--;
452 net->cc_mod.rtcc.last_step_state = 2;
453 net->cc_mod.rtcc.step_cnt = 0;
456 } else if (net->rtt < net->cc_mod.rtcc.lbw_rtt - rtt_offset) {
460 SDT_PROBE5(sctp, cwnd, net, rttvar,
462 ((net->cc_mod.rtcc.lbw << 32) | nbw),
463 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
464 net->flight_size,
466 if (net->cc_mod.rtcc.steady_step) {
467 oth = net->cc_mod.rtcc.vol_reduce;
469 oth |= net->cc_mod.rtcc.step_cnt;
471 oth |= net->cc_mod.rtcc.last_step_state;
472 SDT_PROBE5(sctp, cwnd, net, rttstep,
474 ((net->cc_mod.rtcc.lbw << 32) | nbw),
475 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
478 if ((net->cc_mod.rtcc.vol_reduce) &&
480 net->cwnd += net->mtu;
481 sctp_enforce_cwnd_limit(&stcb->asoc, net);
482 net->cc_mod.rtcc.vol_reduce--;
484 net->cc_mod.rtcc.last_step_state = 3;
485 net->cc_mod.rtcc.step_cnt = 0;
492 SDT_PROBE5(sctp, cwnd, net, rttvar,
494 ((net->cc_mod.rtcc.lbw << 32) | nbw),
495 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
496 net->flight_size,
498 if (net->cc_mod.rtcc.steady_step) {
499 oth = net->cc_mod.rtcc.vol_reduce;
501 oth |= net->cc_mod.rtcc.step_cnt;
503 oth |= net->cc_mod.rtcc.last_step_state;
504 SDT_PROBE5(sctp, cwnd, net, rttstep,
506 ((net->cc_mod.rtcc.lbw << 32) | nbw),
507 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
510 if ((net->cc_mod.rtcc.vol_reduce) &&
512 net->cwnd += net->mtu;
513 sctp_enforce_cwnd_limit(&stcb->asoc, net);
514 net->cc_mod.rtcc.vol_reduce--;
516 net->cc_mod.rtcc.last_step_state = 4;
517 net->cc_mod.rtcc.step_cnt = 0;
520 net->cc_mod.rtcc.lbw = nbw;
521 net->cc_mod.rtcc.lbw_rtt = net->rtt;
522 net->cc_mod.rtcc.cwnd_at_bw_set = net->cwnd;
531 cc_bw_increase(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw, uint64_t vtag)
541 probepoint = (((uint64_t)net->cwnd) << 32);
542 SDT_PROBE5(sctp, cwnd, net, rttvar,
544 ((net->cc_mod.rtcc.lbw << 32) | nbw),
545 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
546 net->flight_size,
548 if (net->cc_mod.rtcc.steady_step) {
549 oth = net->cc_mod.rtcc.vol_reduce;
551 oth |= net->cc_mod.rtcc.step_cnt;
553 oth |= net->cc_mod.rtcc.last_step_state;
554 SDT_PROBE5(sctp, cwnd, net, rttstep,
556 ((net->cc_mod.rtcc.lbw << 32) | nbw),
557 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
560 net->cc_mod.rtcc.last_step_state = 0;
561 net->cc_mod.rtcc.step_cnt = 0;
562 net->cc_mod.rtcc.vol_reduce = 0;
564 net->cc_mod.rtcc.lbw = nbw;
565 net->cc_mod.rtcc.lbw_rtt = net->rtt;
566 net->cc_mod.rtcc.cwnd_at_bw_set = net->cwnd;
574 cc_bw_limit(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw)
624 probepoint = (((uint64_t)net->cwnd) << 32);
625 rtt = net->rtt;
626 if (net->cc_mod.rtcc.rtt_set_this_sack) {
627 net->cc_mod.rtcc.rtt_set_this_sack = 0;
628 bytes_for_this_rtt = net->cc_mod.rtcc.bw_bytes - net->cc_mod.rtcc.bw_bytes_at_last_rttc;
629 net->cc_mod.rtcc.bw_bytes_at_last_rttc = net->cc_mod.rtcc.bw_bytes;
630 if (net->rtt) {
631 div = net->rtt / 1000;
643 inst_ind = net->cc_mod.rtcc.last_inst_ind;
644 inst_bw = bytes_for_this_rtt / (uint64_t)(net->rtt);
649 inst_ind = net->cc_mod.rtcc.last_inst_ind;
654 SDT_PROBE5(sctp, cwnd, net, rttvar,
657 ((net->cc_mod.rtcc.lbw_rtt << 32) | rtt),
658 net->flight_size,
662 inst_ind = net->cc_mod.rtcc.last_inst_ind;
664 bw_offset = net->cc_mod.rtcc.lbw >> bw_shift;
665 if (nbw > net->cc_mod.rtcc.lbw + bw_offset) {
666 ret = cc_bw_increase(stcb, net, nbw, vtag);
669 rtt_offset = net->cc_mod.rtcc.lbw_rtt >> SCTP_BASE_SYSCTL(sctp_rttvar_rtt);
670 if (nbw < net->cc_mod.rtcc.lbw - bw_offset) {
671 ret = cc_bw_decrease(stcb, net, nbw, rtt_offset, vtag, inst_ind);
678 ret = cc_bw_same(stcb, net, nbw, rtt_offset, vtag, inst_ind);
680 net->cc_mod.rtcc.last_inst_ind = inst_ind;
689 struct sctp_nets *net;
707 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
708 t_ssthresh += net->ssthresh;
710 srtt = net->lastsa;
714 t_ucwnd_sbw += (uint64_t)net->cwnd / (uint64_t)srtt;
715 t_path_mptcp += (((uint64_t)net->cwnd) << SHIFT_MPTCP_MULTI_Z) /
716 (((uint64_t)net->mtu) * (uint64_t)srtt);
717 tmp = (((uint64_t)net->cwnd) << SHIFT_MPTCP_MULTI_N) /
718 ((uint64_t)net->mtu * (uint64_t)(srtt * srtt));
739 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
744 if (net->fast_retran_loss_recovery && net->new_pseudo_cumack) {
745 if (SCTP_TSN_GE(asoc->last_acked_seq, net->fast_recovery_tsn) ||
746 SCTP_TSN_GE(net->pseudo_cumack, net->fast_recovery_tsn)) {
747 net->will_exit_fast_recovery = 1;
752 if (net->net_ack == 0) {
754 sctp_log_cwnd(stcb, net, 0, SCTP_CWND_LOG_FROM_SACK);
763 * if (sctp_cmt_on_off > 0 && net->fast_retran_loss_recovery
764 * && net->will_exit_fast_recovery == 0) { @@@ Do something
782 if (use_rtcc && (net->cc_mod.rtcc.tls_needs_set > 0)) {
792 if ((net->cc_mod.rtcc.new_tot_time / 1000) > 0) {
793 nbw = net->cc_mod.rtcc.bw_bytes / (net->cc_mod.rtcc.new_tot_time / 1000);
795 nbw = net->cc_mod.rtcc.bw_bytes;
797 if (net->cc_mod.rtcc.lbw) {
798 if (cc_bw_limit(stcb, net, nbw)) {
805 probepoint = (((uint64_t)net->cwnd) << 32);
807 vtag = (net->rtt << 32) |
811 SDT_PROBE5(sctp, cwnd, net, rttvar,
814 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
815 net->flight_size,
817 net->cc_mod.rtcc.lbw = nbw;
818 net->cc_mod.rtcc.lbw_rtt = net->rtt;
819 if (net->cc_mod.rtcc.rtt_set_this_sack) {
820 net->cc_mod.rtcc.rtt_set_this_sack = 0;
821 net->cc_mod.rtcc.bw_bytes_at_last_rttc = net->cc_mod.rtcc.bw_bytes;
830 ((asoc->sctp_cmt_on_off > 0) && net->new_pseudo_cumack)) {
832 if (net->cwnd <= net->ssthresh) {
834 if (net->flight_size + net->net_ack >= net->cwnd) {
837 old_cwnd = net->cwnd;
840 limit = (uint32_t)(((uint64_t)net->mtu *
842 (uint64_t)net->ssthresh) /
844 incr = (uint32_t)(((uint64_t)net->net_ack *
845 (uint64_t)net->ssthresh) /
859 srtt = net->lastsa;
863 limit = (uint32_t)(((uint64_t)net->mtu *
865 (uint64_t)net->cwnd) /
868 incr = (uint32_t)(((uint64_t)net->net_ack *
869 (uint64_t)net->cwnd) /
880 limit = (uint32_t)(((uint64_t)net->mtu *
884 incr = (uint32_t)(((uint64_t)net->net_ack *
890 if (incr > net->net_ack) {
891 incr = net->net_ack;
893 if (incr > net->mtu) {
894 incr = net->mtu;
898 incr = net->net_ack;
899 if (incr > net->mtu * SCTP_BASE_SYSCTL(sctp_L2_abc_variable)) {
900 incr = net->mtu * SCTP_BASE_SYSCTL(sctp_L2_abc_variable);
904 net->cwnd += incr;
905 sctp_enforce_cwnd_limit(asoc, net);
907 sctp_log_cwnd(stcb, net, incr,
910 SDT_PROBE5(sctp, cwnd, net, ack,
913 net,
914 old_cwnd, net->cwnd);
917 sctp_log_cwnd(stcb, net, net->net_ack,
926 net->partial_bytes_acked += net->net_ack;
928 if ((net->flight_size + net->net_ack >= net->cwnd) &&
929 (net->partial_bytes_acked >= net->cwnd)) {
930 net->partial_bytes_acked -= net->cwnd;
931 old_cwnd = net->cwnd;
934 incr = (uint32_t)(((uint64_t)net->mtu *
935 (uint64_t)net->ssthresh) /
946 srtt = net->lastsa;
950 incr = (uint32_t)((uint64_t)net->mtu *
951 (uint64_t)net->cwnd /
961 (uint64_t)net->cwnd) >>
963 if (incr > net->mtu) {
964 incr = net->mtu;
968 incr = net->mtu;
971 net->cwnd += incr;
972 sctp_enforce_cwnd_limit(asoc, net);
973 SDT_PROBE5(sctp, cwnd, net, ack,
976 net,
977 old_cwnd, net->cwnd);
979 sctp_log_cwnd(stcb, net, net->mtu,
984 sctp_log_cwnd(stcb, net, net->net_ack,
991 sctp_log_cwnd(stcb, net, net->mtu,
999 sctp_cwnd_update_exit_pf_common(struct sctp_tcb *stcb, struct sctp_nets *net)
1003 old_cwnd = net->cwnd;
1004 net->cwnd = net->mtu;
1005 SDT_PROBE5(sctp, cwnd, net, ack,
1006 stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net,
1007 old_cwnd, net->cwnd);
1009 (void *)net, net->cwnd);
1013 sctp_cwnd_update_after_timeout(struct sctp_tcb *stcb, struct sctp_nets *net)
1015 int old_cwnd = net->cwnd;
1044 net->ssthresh = (uint32_t)(((uint64_t)4 *
1045 (uint64_t)net->mtu *
1046 (uint64_t)net->ssthresh) /
1051 srtt = net->lastsa;
1058 net->ssthresh = (uint32_t)((uint64_t)t_cwnd - cc_delta);
1060 net->ssthresh = net->mtu;
1063 if ((net->cwnd > t_cwnd / 2) &&
1064 (net->ssthresh < net->cwnd - t_cwnd / 2)) {
1065 net->ssthresh = net->cwnd - t_cwnd / 2;
1067 if (net->ssthresh < net->mtu) {
1068 net->ssthresh = net->mtu;
1071 net->ssthresh = max(net->cwnd / 2, 4 * net->mtu);
1073 net->cwnd = net->mtu;
1074 net->partial_bytes_acked = 0;
1075 SDT_PROBE5(sctp, cwnd, net, to,
1078 net,
1079 old_cwnd, net->cwnd);
1081 sctp_log_cwnd(stcb, net, net->cwnd - old_cwnd, SCTP_CWND_LOG_FROM_RTX);
1086 sctp_cwnd_update_after_ecn_echo_common(struct sctp_tcb *stcb, struct sctp_nets *net,
1089 int old_cwnd = net->cwnd;
1091 if ((use_rtcc) && (net->lan_type == SCTP_LAN_LOCAL) && (net->cc_mod.rtcc.use_dccc_ecn)) {
1098 if (net->ecn_prev_cwnd < net->cwnd) {
1100 net->cwnd = net->ecn_prev_cwnd - (net->mtu * num_pkt_lost);
1103 net->cwnd /= 2;
1106 net->ssthresh = net->cwnd - (num_pkt_lost * net->mtu);
1108 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT);
1115 net->ssthresh -= (net->mtu * num_pkt_lost);
1116 net->cwnd -= (net->mtu * num_pkt_lost);
1118 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT);
1125 net->ssthresh = net->cwnd / 2;
1126 if (net->ssthresh < net->mtu) {
1127 net->ssthresh = net->mtu;
1132 net->RTO <<= 1;
1134 net->cwnd = net->ssthresh;
1135 SDT_PROBE5(sctp, cwnd, net, ecn,
1138 net,
1139 old_cwnd, net->cwnd);
1141 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT);
1150 struct sctp_nets *net, struct sctp_pktdrop_chunk *cp,
1155 int old_cwnd = net->cwnd;
1165 if (*on_queue < net->flight_size) {
1166 *on_queue = net->flight_size;
1169 bw_avail = (uint32_t)(((uint64_t)(*bottle_bw) * net->rtt) / (uint64_t)1000000);
1188 net->partial_bytes_acked = 0;
1196 net->cwnd = net->prev_cwnd;
1199 seg_inflight = net->flight_size / net->mtu;
1200 seg_onqueue = *on_queue / net->mtu;
1204 if (net->cwnd > net->flight_size) {
1212 diff_adj = net->cwnd - net->flight_size;
1223 net->cwnd -= my_portion;
1226 if (net->cwnd <= net->mtu) {
1227 net->cwnd = net->mtu;
1230 net->ssthresh = net->cwnd - 1;
1238 (stcb->asoc.max_burst * net->mtu < incr)) {
1239 incr = stcb->asoc.max_burst * net->mtu;
1241 net->cwnd += incr;
1243 if (net->cwnd > bw_avail) {
1245 net->cwnd = bw_avail;
1247 if (net->cwnd < net->mtu) {
1249 net->cwnd = net->mtu;
1251 sctp_enforce_cwnd_limit(&stcb->asoc, net);
1252 if (net->cwnd - old_cwnd != 0) {
1254 SDT_PROBE5(sctp, cwnd, net, pd,
1257 net,
1258 old_cwnd, net->cwnd);
1260 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd),
1268 struct sctp_nets *net, int burst_limit)
1270 int old_cwnd = net->cwnd;
1272 if (net->ssthresh < net->cwnd)
1273 net->ssthresh = net->cwnd;
1275 net->cwnd = (net->flight_size + (burst_limit * net->mtu));
1276 sctp_enforce_cwnd_limit(&stcb->asoc, net);
1277 SDT_PROBE5(sctp, cwnd, net, bl,
1280 net,
1281 old_cwnd, net->cwnd);
1283 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_BRST);
1298 sctp_cwnd_update_after_ecn_echo(struct sctp_tcb *stcb, struct sctp_nets *net,
1302 sctp_cwnd_update_after_ecn_echo_common(stcb, net, in_window, num_pkt_lost, 0);
1311 sctp_cwnd_update_rtcc_after_ecn_echo(struct sctp_tcb *stcb, struct sctp_nets *net,
1314 sctp_cwnd_update_after_ecn_echo_common(stcb, net, in_window, num_pkt_lost, 1);
1318 sctp_cwnd_update_rtcc_tsn_acknowledged(struct sctp_nets *net,
1321 net->cc_mod.rtcc.bw_bytes += tp1->send_size;
1326 struct sctp_nets *net)
1328 if (net->cc_mod.rtcc.tls_needs_set > 0) {
1333 timevalsub(&ltls, &net->cc_mod.rtcc.tls);
1334 net->cc_mod.rtcc.new_tot_time = (ltls.tv_sec * 1000000) + ltls.tv_usec;
1340 struct sctp_nets *net)
1344 if (net->cc_mod.rtcc.lbw) {
1346 vtag = (net->rtt << 32) | (((uint32_t)(stcb->sctp_ep->sctp_lport)) << 16) |
1348 probepoint = (((uint64_t)net->cwnd) << 32);
1351 SDT_PROBE5(sctp, cwnd, net, rttvar,
1353 ((net->cc_mod.rtcc.lbw << 32) | 0),
1354 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
1355 net->flight_size,
1357 net->cc_mod.rtcc.lbw_rtt = 0;
1358 net->cc_mod.rtcc.cwnd_at_bw_set = 0;
1359 net->cc_mod.rtcc.lbw = 0;
1360 net->cc_mod.rtcc.bw_bytes_at_last_rttc = 0;
1361 net->cc_mod.rtcc.vol_reduce = 0;
1362 net->cc_mod.rtcc.bw_tot_time = 0;
1363 net->cc_mod.rtcc.bw_bytes = 0;
1364 net->cc_mod.rtcc.tls_needs_set = 0;
1365 if (net->cc_mod.rtcc.steady_step) {
1366 net->cc_mod.rtcc.vol_reduce = 0;
1367 net->cc_mod.rtcc.step_cnt = 0;
1368 net->cc_mod.rtcc.last_step_state = 0;
1370 if (net->cc_mod.rtcc.ret_from_eq) {
1380 cwnd = min((net->mtu * 4), max((2 * net->mtu), SCTP_INITIAL_CWND));
1388 cwnd = (net->mtu - sizeof(struct sctphdr)) * cwnd_in_mtu;
1390 if (net->cwnd > cwnd) {
1395 net->cwnd = cwnd;
1403 struct sctp_nets *net)
1407 sctp_set_initial_cc_param(stcb, net);
1409 probepoint = (((uint64_t)net->cwnd) << 32);
1411 vtag = (net->rtt << 32) |
1414 SDT_PROBE5(sctp, cwnd, net, rttvar,
1420 net->cc_mod.rtcc.lbw_rtt = 0;
1421 net->cc_mod.rtcc.cwnd_at_bw_set = 0;
1422 net->cc_mod.rtcc.vol_reduce = 0;
1423 net->cc_mod.rtcc.lbw = 0;
1424 net->cc_mod.rtcc.vol_reduce = 0;
1425 net->cc_mod.rtcc.bw_bytes_at_last_rttc = 0;
1426 net->cc_mod.rtcc.bw_tot_time = 0;
1427 net->cc_mod.rtcc.bw_bytes = 0;
1428 net->cc_mod.rtcc.tls_needs_set = 0;
1429 net->cc_mod.rtcc.ret_from_eq = SCTP_BASE_SYSCTL(sctp_rttvar_eqret);
1430 net->cc_mod.rtcc.steady_step = SCTP_BASE_SYSCTL(sctp_steady_step);
1431 net->cc_mod.rtcc.use_dccc_ecn = SCTP_BASE_SYSCTL(sctp_use_dccc_ecn);
1432 net->cc_mod.rtcc.step_cnt = 0;
1433 net->cc_mod.rtcc.last_step_state = 0;
1440 struct sctp_nets *net;
1449 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
1450 net->cc_mod.rtcc.ret_from_eq = cc_opt->aid_value.assoc_value;
1457 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
1458 net->cc_mod.rtcc.use_dccc_ecn = cc_opt->aid_value.assoc_value;
1461 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
1462 net->cc_mod.rtcc.steady_step = cc_opt->aid_value.assoc_value;
1470 net = TAILQ_FIRST(&stcb->asoc.nets);
1471 if (net == NULL) {
1474 cc_opt->aid_value.assoc_value = net->cc_mod.rtcc.ret_from_eq;
1476 net = TAILQ_FIRST(&stcb->asoc.nets);
1477 if (net == NULL) {
1480 cc_opt->aid_value.assoc_value = net->cc_mod.rtcc.use_dccc_ecn;
1482 net = TAILQ_FIRST(&stcb->asoc.nets);
1483 if (net == NULL) {
1486 cc_opt->aid_value.assoc_value = net->cc_mod.rtcc.steady_step;
1496 struct sctp_nets *net)
1498 if (net->cc_mod.rtcc.tls_needs_set == 0) {
1499 SCTP_GETPTIME_TIMEVAL(&net->cc_mod.rtcc.tls);
1500 net->cc_mod.rtcc.tls_needs_set = 2;
1515 struct sctp_nets *net,
1518 net->cc_mod.rtcc.rtt_set_this_sack = 1;
1608 sctp_hs_cwnd_increase(struct sctp_tcb *stcb, struct sctp_nets *net)
1611 int old_cwnd = net->cwnd;
1613 cur_val = net->cwnd >> 10;
1618 if (net->net_ack > net->mtu) {
1619 net->cwnd += net->mtu;
1621 net->cwnd += net->net_ack;
1624 for (i = net->last_hs_used; i < SCTP_HS_TABLE_SIZE; i++) {
1630 net->last_hs_used = indx;
1632 net->cwnd += incr;
1634 sctp_enforce_cwnd_limit(&stcb->asoc, net);
1636 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SS);
1641 sctp_hs_cwnd_decrease(struct sctp_tcb *stcb, struct sctp_nets *net)
1644 int old_cwnd = net->cwnd;
1646 cur_val = net->cwnd >> 10;
1649 net->ssthresh = net->cwnd / 2;
1650 if (net->ssthresh < (net->mtu * 2)) {
1651 net->ssthresh = 2 * net->mtu;
1653 net->cwnd = net->ssthresh;
1656 net->ssthresh = net->cwnd - (int)((net->cwnd / 100) *
1657 (int32_t)sctp_cwnd_adjust[net->last_hs_used].drop_percent);
1658 net->cwnd = net->ssthresh;
1660 indx = net->last_hs_used;
1661 cur_val = net->cwnd >> 10;
1665 net->last_hs_used = 0;
1672 net->last_hs_used = indx;
1675 sctp_enforce_cwnd_limit(&stcb->asoc, net);
1677 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_FR);
1685 struct sctp_nets *net;
1689 * (net->fast_retran_loss_recovery == 0)))
1691 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
1695 if (net->net_ack > 0) {
1704 sctp_hs_cwnd_decrease(stcb, net);
1708 net->partial_bytes_acked = 0;
1722 net->fast_retran_loss_recovery = 1;
1726 net->fast_recovery_tsn = asoc->sending_seq - 1;
1728 net->fast_recovery_tsn = lchk->rec.data.tsn - 1;
1732 stcb->sctp_ep, stcb, net,
1735 stcb->sctp_ep, stcb, net);
1737 } else if (net->net_ack > 0) {
1752 struct sctp_nets *net;
1757 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
1762 if (net->fast_retran_loss_recovery && net->new_pseudo_cumack) {
1763 if (SCTP_TSN_GE(asoc->last_acked_seq, net->fast_recovery_tsn) ||
1764 SCTP_TSN_GE(net->pseudo_cumack, net->fast_recovery_tsn)) {
1765 net->will_exit_fast_recovery = 1;
1770 if (net->net_ack == 0) {
1772 sctp_log_cwnd(stcb, net, 0, SCTP_CWND_LOG_FROM_SACK);
1781 * if (sctp_cmt_on_off > 0 && net->fast_retran_loss_recovery
1782 * && net->will_exit_fast_recovery == 0) { @@@ Do something
1802 ((asoc->sctp_cmt_on_off > 0) && net->new_pseudo_cumack)) {
1804 if (net->cwnd <= net->ssthresh) {
1806 if (net->flight_size + net->net_ack >= net->cwnd) {
1807 sctp_hs_cwnd_increase(stcb, net);
1810 sctp_log_cwnd(stcb, net, net->net_ack,
1816 net->partial_bytes_acked += net->net_ack;
1817 if ((net->flight_size + net->net_ack >= net->cwnd) &&
1818 (net->partial_bytes_acked >= net->cwnd)) {
1819 net->partial_bytes_acked -= net->cwnd;
1820 net->cwnd += net->mtu;
1821 sctp_enforce_cwnd_limit(asoc, net);
1823 sctp_log_cwnd(stcb, net, net->mtu,
1828 sctp_log_cwnd(stcb, net, net->net_ack,
1835 sctp_log_cwnd(stcb, net, net->mtu,
1847 * http://www.hamilton.ie/net/htcp3.pdf
1883 htcp_cwnd_undo(struct sctp_tcb *stcb, struct sctp_nets *net)
1885 net->cc_mod.htcp_ca.last_cong = net->cc_mod.htcp_ca.undo_last_cong;
1886 net->cc_mod.htcp_ca.maxRTT = net->cc_mod.htcp_ca.undo_maxRTT;
1887 net->cc_mod.htcp_ca.old_maxB = net->cc_mod.htcp_ca.undo_old_maxB;
1888 return (max(net->cwnd, ((net->ssthresh / net->mtu << 7) / net->cc_mod.htcp_ca.beta) * net->mtu));
1894 measure_rtt(struct sctp_nets *net)
1896 uint32_t srtt = net->lastsa >> SCTP_RTT_SHIFT;
1899 if (net->cc_mod.htcp_ca.minRTT > srtt || !net->cc_mod.htcp_ca.minRTT)
1900 net->cc_mod.htcp_ca.minRTT = srtt;
1903 if (net->fast_retran_ip == 0 && net->ssthresh < 0xFFFF && htcp_ccount(&net->cc_mod.htcp_ca) > 3) {
1904 if (net->cc_mod.htcp_ca.maxRTT < net->cc_mod.htcp_ca.minRTT)
1905 net->cc_mod.htcp_ca.maxRTT = net->cc_mod.htcp_ca.minRTT;
1906 if (net->cc_mod.htcp_ca.maxRTT < srtt && srtt <= net->cc_mod.htcp_ca.maxRTT + sctp_msecs_to_ticks(20))
1907 net->cc_mod.htcp_ca.maxRTT = srtt;
1912 measure_achieved_throughput(struct sctp_nets *net)
1916 if (net->fast_retran_ip == 0)
1917 net->cc_mod.htcp_ca.bytes_acked = net->net_ack;
1924 if (net->fast_retran_ip == 1) {
1925 net->cc_mod.htcp_ca.bytecount = 0;
1926 net->cc_mod.htcp_ca.lasttime = now;
1930 net->cc_mod.htcp_ca.bytecount += net->net_ack;
1931 if ((net->cc_mod.htcp_ca.bytecount >= net->cwnd - (((net->cc_mod.htcp_ca.alpha >> 7) ? (net->cc_mod.htcp_ca.alpha >> 7) : 1) * net->mtu)) &&
1932 (now - net->cc_mod.htcp_ca.lasttime >= net->cc_mod.htcp_ca.minRTT) &&
1933 (net->cc_mod.htcp_ca.minRTT > 0)) {
1934 uint32_t cur_Bi = net->cc_mod.htcp_ca.bytecount / net->mtu * hz / (now - net->cc_mod.htcp_ca.lasttime);
1936 if (htcp_ccount(&net->cc_mod.htcp_ca) <= 3) {
1938 net->cc_mod.htcp_ca.minB = net->cc_mod.htcp_ca.maxB = net->cc_mod.htcp_ca.Bi = cur_Bi;
1940 net->cc_mod.htcp_ca.Bi = (3 * net->cc_mod.htcp_ca.Bi + cur_Bi) / 4;
1941 if (net->cc_mod.htcp_ca.Bi > net->cc_mod.htcp_ca.maxB)
1942 net->cc_mod.htcp_ca.maxB = net->cc_mod.htcp_ca.Bi;
1943 if (net->cc_mod.htcp_ca.minB > net->cc_mod.htcp_ca.maxB)
1944 net->cc_mod.htcp_ca.minB = net->cc_mod.htcp_ca.maxB;
1946 net->cc_mod.htcp_ca.bytecount = 0;
1947 net->cc_mod.htcp_ca.lasttime = now;
2015 htcp_param_update(struct sctp_nets *net)
2017 uint32_t minRTT = net->cc_mod.htcp_ca.minRTT;
2018 uint32_t maxRTT = net->cc_mod.htcp_ca.maxRTT;
2020 htcp_beta_update(&net->cc_mod.htcp_ca, minRTT, maxRTT);
2021 htcp_alpha_update(&net->cc_mod.htcp_ca);
2028 net->cc_mod.htcp_ca.maxRTT = minRTT + ((maxRTT - minRTT) * 95) / 100;
2032 htcp_recalc_ssthresh(struct sctp_nets *net)
2034 htcp_param_update(net);
2035 return (max(((net->cwnd / net->mtu * net->cc_mod.htcp_ca.beta) >> 7) * net->mtu, 2U * net->mtu));
2039 htcp_cong_avoid(struct sctp_tcb *stcb, struct sctp_nets *net)
2046 if (net->cwnd <= net->ssthresh) {
2048 if (net->flight_size + net->net_ack >= net->cwnd) {
2049 if (net->net_ack > (net->mtu * SCTP_BASE_SYSCTL(sctp_L2_abc_variable))) {
2050 net->cwnd += (net->mtu * SCTP_BASE_SYSCTL(sctp_L2_abc_variable));
2052 sctp_log_cwnd(stcb, net, net->mtu,
2057 net->cwnd += net->net_ack;
2059 sctp_log_cwnd(stcb, net, net->net_ack,
2063 sctp_enforce_cwnd_limit(&stcb->asoc, net);
2066 sctp_log_cwnd(stcb, net, net->net_ack,
2071 measure_rtt(net);
2075 * net->cwnd += alpha / net->cwnd
2078 if (((net->partial_bytes_acked / net->mtu * net->cc_mod.htcp_ca.alpha) >> 7) * net->mtu >= net->cwnd) {
2081 * if (net->snd_cwnd < net->snd_cwnd_clamp) - Nope (RRS).
2083 net->cwnd += net->mtu;
2084 net->partial_bytes_acked = 0;
2085 sctp_enforce_cwnd_limit(&stcb->asoc, net);
2086 htcp_alpha_update(&net->cc_mod.htcp_ca);
2088 sctp_log_cwnd(stcb, net, net->mtu,
2092 net->partial_bytes_acked += net->net_ack;
2094 sctp_log_cwnd(stcb, net, net->net_ack,
2099 net->cc_mod.htcp_ca.bytes_acked = net->mtu;
2106 htcp_min_cwnd(struct sctp_tcb *stcb, struct sctp_nets *net)
2108 return (net->ssthresh);
2113 htcp_init(struct sctp_nets *net)
2115 memset(&net->cc_mod.htcp_ca, 0, sizeof(struct htcp));
2116 net->cc_mod.htcp_ca.alpha = ALPHA_BASE;
2117 net->cc_mod.htcp_ca.beta = BETA_MIN;
2118 net->cc_mod.htcp_ca.bytes_acked = net->mtu;
2119 net->cc_mod.htcp_ca.last_cong = sctp_get_tick_count();
2123 sctp_htcp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net)
2129 net->cwnd = min((net->mtu * 4), max((2 * net->mtu), SCTP_INITIAL_CWND));
2130 net->ssthresh = stcb->asoc.peers_rwnd;
2131 sctp_enforce_cwnd_limit(&stcb->asoc, net);
2132 htcp_init(net);
2135 sctp_log_cwnd(stcb, net, 0, SCTP_CWND_INITIALIZATION);
2144 struct sctp_nets *net;
2149 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
2154 if (net->fast_retran_loss_recovery && net->new_pseudo_cumack) {
2155 if (SCTP_TSN_GE(asoc->last_acked_seq, net->fast_recovery_tsn) ||
2156 SCTP_TSN_GE(net->pseudo_cumack, net->fast_recovery_tsn)) {
2157 net->will_exit_fast_recovery = 1;
2162 if (net->net_ack == 0) {
2164 sctp_log_cwnd(stcb, net, 0, SCTP_CWND_LOG_FROM_SACK);
2173 * if (sctp_cmt_on_off > 0 && net->fast_retran_loss_recovery
2174 * && net->will_exit_fast_recovery == 0) { @@@ Do something
2194 ((asoc->sctp_cmt_on_off > 0) && net->new_pseudo_cumack)) {
2195 htcp_cong_avoid(stcb, net);
2196 measure_achieved_throughput(net);
2199 sctp_log_cwnd(stcb, net, net->mtu,
2210 struct sctp_nets *net;
2214 * (net->fast_retran_loss_recovery == 0)))
2216 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
2220 if (net->net_ack > 0) {
2228 int old_cwnd = net->cwnd;
2231 htcp_reset(&net->cc_mod.htcp_ca);
2232 net->ssthresh = htcp_recalc_ssthresh(net);
2233 net->cwnd = net->ssthresh;
2234 sctp_enforce_cwnd_limit(asoc, net);
2236 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd),
2241 net->partial_bytes_acked = 0;
2255 net->fast_retran_loss_recovery = 1;
2259 net->fast_recovery_tsn = asoc->sending_seq - 1;
2261 net->fast_recovery_tsn = lchk->rec.data.tsn - 1;
2265 stcb->sctp_ep, stcb, net,
2268 stcb->sctp_ep, stcb, net);
2270 } else if (net->net_ack > 0) {
2282 struct sctp_nets *net)
2284 int old_cwnd = net->cwnd;
2287 htcp_reset(&net->cc_mod.htcp_ca);
2288 net->ssthresh = htcp_recalc_ssthresh(net);
2289 net->cwnd = net->mtu;
2290 net->partial_bytes_acked = 0;
2292 sctp_log_cwnd(stcb, net, net->cwnd - old_cwnd, SCTP_CWND_LOG_FROM_RTX);
2298 struct sctp_nets *net, int in_window, int num_pkt_lost SCTP_UNUSED)
2302 old_cwnd = net->cwnd;
2306 htcp_reset(&net->cc_mod.htcp_ca);
2308 net->ssthresh = htcp_recalc_ssthresh(net);
2309 if (net->ssthresh < net->mtu) {
2310 net->ssthresh = net->mtu;
2312 net->RTO <<= 1;
2314 net->cwnd = net->ssthresh;
2315 sctp_enforce_cwnd_limit(&stcb->asoc, net);
2317 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT);