Lines Matching refs:net

60 sctp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net)
69 net->cwnd = min((net->mtu * 4), max((2 * net->mtu), SCTP_INITIAL_CWND));
77 net->cwnd = (net->mtu - sizeof(struct sctphdr)) * cwnd_in_mtu;
82 net->cwnd /= assoc->numnets;
83 if (net->cwnd < (net->mtu - sizeof(struct sctphdr))) {
84 net->cwnd = net->mtu - sizeof(struct sctphdr);
87 net->ssthresh = assoc->peers_rwnd;
89 SDT_PROBE(sctp, cwnd, net, init,
90 stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net,
91 0, net->cwnd);
95 sctp_log_cwnd(stcb, net, 0, SCTP_CWND_INITIALIZATION);
103 struct sctp_nets *net;
113 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
114 t_ssthresh += net->ssthresh;
115 t_cwnd += net->cwnd;
116 if (net->lastsa > 0) {
117 t_ucwnd_sbw += (uint64_t)net->cwnd / (uint64_t)net->lastsa;
127 * (net->fast_retran_loss_recovery == 0)))
129 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
133 if (net->net_ack > 0) {
141 int old_cwnd = net->cwnd;
146 net->ssthresh = (uint32_t)(((uint64_t)4 *
147 (uint64_t)net->mtu *
148 (uint64_t)net->ssthresh) /
155 srtt = net->lastsa;
161 net->ssthresh = (uint32_t) (((uint64_t)4 *
162 (uint64_t)net->mtu *
163 (uint64_t)net->cwnd) /
168 if ((net->cwnd > t_cwnd / 2) &&
169 (net->ssthresh < net->cwnd - t_cwnd / 2)) {
170 net->ssthresh = net->cwnd - t_cwnd / 2;
172 if (net->ssthresh < net->mtu) {
173 net->ssthresh = net->mtu;
176 net->ssthresh = net->cwnd / 2;
177 if (net->ssthresh < (net->mtu * 2)) {
178 net->ssthresh = 2 * net->mtu;
181 net->cwnd = net->ssthresh;
183 SDT_PROBE(sctp, cwnd, net, fr,
184 stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net,
185 old_cwnd, net->cwnd);
188 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd),
193 net->partial_bytes_acked = 0;
207 net->fast_retran_loss_recovery = 1;
211 net->fast_recovery_tsn = asoc->sending_seq - 1;
213 net->fast_recovery_tsn = lchk->rec.data.TSN_seq - 1;
217 stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_INDATA+SCTP_LOC_32 );
219 stcb->sctp_ep, stcb, net);
221 } else if (net->net_ack > 0) {
239 cc_bw_same(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw,
243 cc_bw_same(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nbw,
252 probepoint = (((uint64_t)net->cwnd) << 32);
254 if (net->rtt > net->cc_mod.rtcc.lbw_rtt + rtt_offset) {
263 SDT_PROBE(sctp, cwnd, net, rttvar,
265 ((net->cc_mod.rtcc.lbw << 32) | nbw),
266 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
267 net->flight_size,
270 if ((net->cc_mod.rtcc.steady_step) && (inst_ind != SCTP_INST_LOOSING)) {
271 if (net->cc_mod.rtcc.last_step_state == 5)
272 net->cc_mod.rtcc.step_cnt++;
274 net->cc_mod.rtcc.step_cnt = 1;
275 net->cc_mod.rtcc.last_step_state = 5;
276 if ((net->cc_mod.rtcc.step_cnt == net->cc_mod.rtcc.steady_step) ||
277 ((net->cc_mod.rtcc.step_cnt > net->cc_mod.rtcc.steady_step) &&
278 ((net->cc_mod.rtcc.step_cnt % net->cc_mod.rtcc.steady_step) == 0))) {
281 oth = net->cc_mod.rtcc.vol_reduce;
283 oth |= net->cc_mod.rtcc.step_cnt;
285 oth |= net->cc_mod.rtcc.last_step_state;
286 SDT_PROBE(sctp, cwnd, net, rttstep,
288 ((net->cc_mod.rtcc.lbw << 32) | nbw),
289 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
293 if (net->cwnd > (4 * net->mtu)) {
294 net->cwnd -= net->mtu;
295 net->cc_mod.rtcc.vol_reduce++;
297 net->cc_mod.rtcc.step_cnt = 0;
303 if (net->rtt < net->cc_mod.rtcc.lbw_rtt-rtt_offset) {
312 SDT_PROBE(sctp, cwnd, net, rttvar,
314 ((net->cc_mod.rtcc.lbw << 32) | nbw),
315 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
316 net->flight_size,
319 if (net->cc_mod.rtcc.steady_step) {
321 oth = net->cc_mod.rtcc.vol_reduce;
323 oth |= net->cc_mod.rtcc.step_cnt;
325 oth |= net->cc_mod.rtcc.last_step_state;
326 SDT_PROBE(sctp, cwnd, net, rttstep,
328 ((net->cc_mod.rtcc.lbw << 32) | nbw),
329 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
333 if ((net->cc_mod.rtcc.last_step_state == 5) &&
334 (net->cc_mod.rtcc.step_cnt > net->cc_mod.rtcc.steady_step)) {
336 net->cc_mod.rtcc.step_cnt = 0;
339 net->cc_mod.rtcc.last_step_state = 6;
340 net->cc_mod.rtcc.step_cnt = 0;
343 net->cc_mod.rtcc.lbw = nbw;
344 net->cc_mod.rtcc.lbw_rtt = net->rtt;
345 net->cc_mod.rtcc.cwnd_at_bw_set = net->cwnd;
357 probepoint |= ((7 << 16) | net->cc_mod.rtcc.ret_from_eq);
358 SDT_PROBE(sctp, cwnd, net, rttvar,
360 ((net->cc_mod.rtcc.lbw << 32) | nbw),
361 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
362 net->flight_size,
365 if ((net->cc_mod.rtcc.steady_step) && (inst_ind != SCTP_INST_LOOSING)) {
366 if (net->cc_mod.rtcc.last_step_state == 5)
367 net->cc_mod.rtcc.step_cnt++;
369 net->cc_mod.rtcc.step_cnt = 1;
370 net->cc_mod.rtcc.last_step_state = 5;
371 if ((net->cc_mod.rtcc.step_cnt == net->cc_mod.rtcc.steady_step) ||
372 ((net->cc_mod.rtcc.step_cnt > net->cc_mod.rtcc.steady_step) &&
373 ((net->cc_mod.rtcc.step_cnt % net->cc_mod.rtcc.steady_step) == 0))) {
375 if (net->cwnd > (4 * net->mtu)) {
376 net->cwnd -= net->mtu;
377 net->cc_mod.rtcc.vol_reduce++;
380 net->cc_mod.rtcc.step_cnt = 0;
389 return ((int)net->cc_mod.rtcc.ret_from_eq);
394 cc_bw_decrease(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw, uint64_t rtt_offset,
398 cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nbw, uint64_t rtt_offset,
408 probepoint = (((uint64_t)net->cwnd) << 32);
410 if (net->rtt > net->cc_mod.rtcc.lbw_rtt+rtt_offset) {
413 if ((net->cwnd > net->cc_mod.rtcc.cwnd_at_bw_set) &&
419 SDT_PROBE(sctp, cwnd, net, rttvar,
421 ((net->cc_mod.rtcc.lbw << 32) | nbw),
422 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
423 net->flight_size,
426 if (net->cc_mod.rtcc.ret_from_eq) {
428 net->ssthresh = net->cwnd-1;
429 net->partial_bytes_acked = 0;
436 SDT_PROBE(sctp, cwnd, net, rttvar,
438 ((net->cc_mod.rtcc.lbw << 32) | nbw),
439 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
440 net->flight_size,
444 if (net->cc_mod.rtcc.steady_step) {
446 oth = net->cc_mod.rtcc.vol_reduce;
448 oth |= net->cc_mod.rtcc.step_cnt;
450 oth |= net->cc_mod.rtcc.last_step_state;
451 SDT_PROBE(sctp, cwnd, net, rttstep,
453 ((net->cc_mod.rtcc.lbw << 32) | nbw),
454 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
461 if ((net->cc_mod.rtcc.vol_reduce) &&
463 net->cwnd += net->mtu;
464 net->cc_mod.rtcc.vol_reduce--;
466 net->cc_mod.rtcc.last_step_state = 2;
467 net->cc_mod.rtcc.step_cnt = 0;
470 } else if (net->rtt < net->cc_mod.rtcc.lbw_rtt-rtt_offset) {
475 SDT_PROBE(sctp, cwnd, net, rttvar,
477 ((net->cc_mod.rtcc.lbw << 32) | nbw),
478 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
479 net->flight_size,
482 if (net->cc_mod.rtcc.steady_step) {
484 oth = net->cc_mod.rtcc.vol_reduce;
486 oth |= net->cc_mod.rtcc.step_cnt;
488 oth |= net->cc_mod.rtcc.last_step_state;
489 SDT_PROBE(sctp, cwnd, net, rttstep,
491 ((net->cc_mod.rtcc.lbw << 32) | nbw),
492 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
496 if ((net->cc_mod.rtcc.vol_reduce) &&
498 net->cwnd += net->mtu;
499 net->cc_mod.rtcc.vol_reduce--;
501 net->cc_mod.rtcc.last_step_state = 3;
502 net->cc_mod.rtcc.step_cnt = 0;
510 SDT_PROBE(sctp, cwnd, net, rttvar,
512 ((net->cc_mod.rtcc.lbw << 32) | nbw),
513 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
514 net->flight_size,
517 if (net->cc_mod.rtcc.steady_step) {
519 oth = net->cc_mod.rtcc.vol_reduce;
521 oth |= net->cc_mod.rtcc.step_cnt;
523 oth |= net->cc_mod.rtcc.last_step_state;
524 SDT_PROBE(sctp, cwnd, net, rttstep,
526 ((net->cc_mod.rtcc.lbw << 32) | nbw),
527 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
531 if ((net->cc_mod.rtcc.vol_reduce) &&
533 net->cwnd += net->mtu;
534 net->cc_mod.rtcc.vol_reduce--;
536 net->cc_mod.rtcc.last_step_state = 4;
537 net->cc_mod.rtcc.step_cnt = 0;
540 net->cc_mod.rtcc.lbw = nbw;
541 net->cc_mod.rtcc.lbw_rtt = net->rtt;
542 net->cc_mod.rtcc.cwnd_at_bw_set = net->cwnd;
552 cc_bw_increase(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw, uint64_t vtag)
555 cc_bw_increase(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nbw)
570 probepoint = (((uint64_t)net->cwnd) << 32);
571 SDT_PROBE(sctp, cwnd, net, rttvar,
573 ((net->cc_mod.rtcc.lbw << 32) | nbw),
574 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
575 net->flight_size,
578 if (net->cc_mod.rtcc.steady_step) {
580 oth = net->cc_mod.rtcc.vol_reduce;
582 oth |= net->cc_mod.rtcc.step_cnt;
584 oth |= net->cc_mod.rtcc.last_step_state;
585 SDT_PROBE(sctp, cwnd, net, rttstep,
587 ((net->cc_mod.rtcc.lbw << 32) | nbw),
588 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
592 net->cc_mod.rtcc.last_step_state = 0;
593 net->cc_mod.rtcc.step_cnt = 0;
594 net->cc_mod.rtcc.vol_reduce = 0;
596 net->cc_mod.rtcc.lbw = nbw;
597 net->cc_mod.rtcc.lbw_rtt = net->rtt;
598 net->cc_mod.rtcc.cwnd_at_bw_set = net->cwnd;
606 cc_bw_limit(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw)
658 probepoint = (((uint64_t)net->cwnd) << 32);
659 rtt = net->rtt;
661 if (net->cc_mod.rtcc.rtt_set_this_sack) {
662 net->cc_mod.rtcc.rtt_set_this_sack = 0;
663 bytes_for_this_rtt = net->cc_mod.rtcc.bw_bytes - net->cc_mod.rtcc.bw_bytes_at_last_rttc;
664 net->cc_mod.rtcc.bw_bytes_at_last_rttc = net->cc_mod.rtcc.bw_bytes;
665 if (net->rtt) {
666 div = net->rtt / 1000;
680 inst_ind = net->cc_mod.rtcc.last_inst_ind;
682 inst_bw = bytes_for_this_rtt / (uint64_t)(net->rtt);
688 inst_ind = net->cc_mod.rtcc.last_inst_ind;
696 SDT_PROBE(sctp, cwnd, net, rttvar,
699 ((net->cc_mod.rtcc.lbw_rtt << 32) | rtt),
700 net->flight_size,
705 inst_ind = net->cc_mod.rtcc.last_inst_ind;
707 bw_offset = net->cc_mod.rtcc.lbw >> bw_shift;
708 if (nbw > net->cc_mod.rtcc.lbw + bw_offset) {
710 ret = cc_bw_increase(stcb, net, nbw, vtag);
712 ret = cc_bw_increase(stcb, net, nbw);
716 rtt_offset = net->cc_mod.rtcc.lbw_rtt >> SCTP_BASE_SYSCTL(sctp_rttvar_rtt);
717 if (nbw < net->cc_mod.rtcc.lbw - bw_offset) {
719 ret = cc_bw_decrease(stcb, net, nbw, rtt_offset, vtag, inst_ind);
721 ret = cc_bw_decrease(stcb, net, nbw, rtt_offset, inst_ind);
730 ret = cc_bw_same(stcb, net, nbw, rtt_offset, vtag, inst_ind);
732 ret = cc_bw_same(stcb, net, nbw, rtt_offset, inst_ind);
735 net->cc_mod.rtcc.last_inst_ind = inst_ind;
744 struct sctp_nets *net;
765 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
766 t_ssthresh += net->ssthresh;
767 t_cwnd += net->cwnd;
769 srtt = net->lastsa;
773 t_ucwnd_sbw += (uint64_t)net->cwnd / (uint64_t)srtt;
774 t_path_mptcp += (((uint64_t)net->cwnd) << SHIFT_MPTCP_MULTI_Z) /
775 (((uint64_t)net->mtu) * (uint64_t)srtt);
776 tmp = (((uint64_t)net->cwnd) << SHIFT_MPTCP_MULTI_N) /
777 ((uint64_t)net->mtu * (uint64_t)(srtt * srtt));
798 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
804 if (net->fast_retran_loss_recovery && net->new_pseudo_cumack) {
805 if (SCTP_TSN_GE(asoc->last_acked_seq, net->fast_recovery_tsn) ||
806 SCTP_TSN_GE(net->pseudo_cumack,net->fast_recovery_tsn)) {
807 net->will_exit_fast_recovery = 1;
812 if (net->net_ack == 0) {
814 sctp_log_cwnd(stcb, net, 0, SCTP_CWND_LOG_FROM_SACK);
822 if (sctp_cmt_on_off > 0 && net->fast_retran_loss_recovery && net->will_exit_fast_recovery == 0) {
841 if (use_rtcc && (net->cc_mod.rtcc.tls_needs_set > 0)) {
850 if ((net->cc_mod.rtcc.new_tot_time/1000) > 0) {
851 nbw = net->cc_mod.rtcc.bw_bytes/(net->cc_mod.rtcc.new_tot_time/1000);
853 nbw = net->cc_mod.rtcc.bw_bytes;
855 if (net->cc_mod.rtcc.lbw) {
856 if (cc_bw_limit(stcb, net, nbw)) {
864 probepoint = (((uint64_t)net->cwnd) << 32);
866 vtag = (net->rtt << 32) |
870 SDT_PROBE(sctp, cwnd, net, rttvar,
873 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
874 net->flight_size,
877 net->cc_mod.rtcc.lbw = nbw;
878 net->cc_mod.rtcc.lbw_rtt = net->rtt;
879 if (net->cc_mod.rtcc.rtt_set_this_sack) {
880 net->cc_mod.rtcc.rtt_set_this_sack = 0;
881 net->cc_mod.rtcc.bw_bytes_at_last_rttc = net->cc_mod.rtcc.bw_bytes;
890 ((asoc->sctp_cmt_on_off > 0) && net->new_pseudo_cumack)) {
892 if (net->cwnd <= net->ssthresh) {
894 if (net->flight_size + net->net_ack >= net->cwnd) {
898 old_cwnd = net->cwnd;
902 limit = (uint32_t)(((uint64_t)net->mtu *
904 (uint64_t)net->ssthresh) /
906 incr = (uint32_t)(((uint64_t)net->net_ack *
907 (uint64_t)net->ssthresh) /
918 srtt = net->lastsa;
922 limit = (uint32_t)(((uint64_t)net->mtu *
924 (uint64_t)net->cwnd) /
927 incr = (uint32_t)(((uint64_t)net->net_ack *
928 (uint64_t)net->cwnd) /
939 limit = (uint32_t)(((uint64_t)net->mtu *
943 incr = (uint32_t)(((uint64_t)net->net_ack *
949 if (incr > net->net_ack) {
950 incr = net->net_ack;
952 if (incr > net->mtu) {
953 incr = net->mtu;
957 incr = net->net_ack;
958 if (incr > net->mtu * SCTP_BASE_SYSCTL(sctp_L2_abc_variable)) {
959 incr = net->mtu * SCTP_BASE_SYSCTL(sctp_L2_abc_variable);
963 net->cwnd += incr;
965 sctp_log_cwnd(stcb, net, incr,
969 SDT_PROBE(sctp, cwnd, net, ack,
972 net,
973 old_cwnd, net->cwnd);
977 sctp_log_cwnd(stcb, net, net->net_ack,
986 net->partial_bytes_acked += net->net_ack;
988 if ((net->flight_size + net->net_ack >= net->cwnd) &&
989 (net->partial_bytes_acked >= net->cwnd)) {
990 net->partial_bytes_acked -= net->cwnd;
992 old_cwnd = net->cwnd;
996 incr = (uint32_t)(((uint64_t)net->mtu *
997 (uint64_t)net->ssthresh) /
1005 srtt = net->lastsa;
1009 incr = (uint32_t)((uint64_t)net->mtu *
1010 (uint64_t)net->cwnd /
1020 (uint64_t) net->cwnd) >>
1022 if (incr > net->mtu) {
1023 incr = net->mtu;
1027 incr = net->mtu;
1030 net->cwnd += incr;
1032 SDT_PROBE(sctp, cwnd, net, ack,
1035 net,
1036 old_cwnd, net->cwnd);
1039 sctp_log_cwnd(stcb, net, net->mtu,
1044 sctp_log_cwnd(stcb, net, net->net_ack,
1051 sctp_log_cwnd(stcb, net, net->mtu,
1060 sctp_cwnd_update_exit_pf_common(struct sctp_tcb *stcb, struct sctp_nets *net)
1063 sctp_cwnd_update_exit_pf_common(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net)
1069 old_cwnd = net->cwnd;
1071 net->cwnd = net->mtu;
1073 SDT_PROBE(sctp, cwnd, net, ack,
1074 stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net,
1075 old_cwnd, net->cwnd);
1078 (void *)net, net->cwnd);
1083 sctp_cwnd_update_after_timeout(struct sctp_tcb *stcb, struct sctp_nets *net)
1085 int old_cwnd = net->cwnd;
1114 net->ssthresh = (uint32_t)(((uint64_t)4 *
1115 (uint64_t)net->mtu *
1116 (uint64_t)net->ssthresh) /
1121 srtt = net->lastsa;
1128 net->ssthresh = (uint32_t)((uint64_t)t_cwnd - cc_delta);
1130 net->ssthresh = net->mtu;
1133 if ((net->cwnd > t_cwnd / 2) &&
1134 (net->ssthresh < net->cwnd - t_cwnd / 2)) {
1135 net->ssthresh = net->cwnd - t_cwnd / 2;
1137 if (net->ssthresh < net->mtu) {
1138 net->ssthresh = net->mtu;
1141 net->ssthresh = max(net->cwnd / 2, 4 * net->mtu);
1143 net->cwnd = net->mtu;
1144 net->partial_bytes_acked = 0;
1146 SDT_PROBE(sctp, cwnd, net, to,
1149 net,
1150 old_cwnd, net->cwnd);
1153 sctp_log_cwnd(stcb, net, net->cwnd - old_cwnd, SCTP_CWND_LOG_FROM_RTX);
1158 sctp_cwnd_update_after_ecn_echo_common(struct sctp_tcb *stcb, struct sctp_nets *net,
1161 int old_cwnd = net->cwnd;
1162 if ((use_rtcc) && (net->lan_type == SCTP_LAN_LOCAL) && (net->cc_mod.rtcc.use_dccc_ecn)) {
1168 if (net->ecn_prev_cwnd < net->cwnd) {
1170 net->cwnd = net->ecn_prev_cwnd - (net->mtu * num_pkt_lost);
1173 net->cwnd /= 2;
1176 net->ssthresh = net->cwnd - (num_pkt_lost * net->mtu);
1178 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT);
1182 net->ssthresh -= (net->mtu * num_pkt_lost);
1183 net->cwnd -= (net->mtu * num_pkt_lost);
1185 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT);
1193 net->ssthresh = net->cwnd / 2;
1194 if (net->ssthresh < net->mtu) {
1195 net->ssthresh = net->mtu;
1197 net->RTO <<= 1;
1199 net->cwnd = net->ssthresh;
1201 SDT_PROBE(sctp, cwnd, net, ecn,
1204 net,
1205 old_cwnd, net->cwnd);
1208 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT);
1217 struct sctp_nets *net, struct sctp_pktdrop_chunk *cp,
1223 int old_cwnd = net->cwnd;
1226 rtt = net->rtt / 1000;
1235 if (*on_queue < net->flight_size)
1236 *on_queue = net->flight_size;
1256 net->partial_bytes_acked = 0;
1265 net->cwnd = net->prev_cwnd;
1268 seg_inflight = net->flight_size / net->mtu;
1269 seg_onqueue = *on_queue / net->mtu;
1273 if (net->cwnd > net->flight_size) {
1281 diff_adj = net->cwnd - net->flight_size;
1292 net->cwnd -= my_portion;
1295 if (net->cwnd <= net->mtu) {
1296 net->cwnd = net->mtu;
1299 net->ssthresh = net->cwnd - 1;
1307 (stcb->asoc.max_burst * net->mtu < incr)) {
1308 incr = stcb->asoc.max_burst * net->mtu;
1310 net->cwnd += incr;
1312 if (net->cwnd > bw_avail) {
1314 net->cwnd = bw_avail;
1316 if (net->cwnd < net->mtu) {
1318 net->cwnd = net->mtu;
1321 if (net->cwnd - old_cwnd != 0) {
1324 SDT_PROBE(sctp, cwnd, net, pd,
1327 net,
1328 old_cwnd, net->cwnd);
1331 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd),
1339 struct sctp_nets *net, int burst_limit)
1341 int old_cwnd = net->cwnd;
1343 if (net->ssthresh < net->cwnd)
1344 net->ssthresh = net->cwnd;
1346 net->cwnd = (net->flight_size + (burst_limit * net->mtu));
1348 SDT_PROBE(sctp, cwnd, net, bl,
1351 net,
1352 old_cwnd, net->cwnd);
1355 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_BRST);
1370 sctp_cwnd_update_after_ecn_echo(struct sctp_tcb *stcb, struct sctp_nets *net,
1374 sctp_cwnd_update_after_ecn_echo_common(stcb, net, in_window, num_pkt_lost, 0);
1383 sctp_cwnd_update_rtcc_after_ecn_echo(struct sctp_tcb *stcb, struct sctp_nets *net,
1386 sctp_cwnd_update_after_ecn_echo_common(stcb, net, in_window, num_pkt_lost, 1);
1391 void sctp_cwnd_update_rtcc_tsn_acknowledged(struct sctp_nets *net,
1394 net->cc_mod.rtcc.bw_bytes += tp1->send_size;
1399 struct sctp_nets *net)
1401 if (net->cc_mod.rtcc.tls_needs_set > 0) {
1405 timevalsub(&ltls, &net->cc_mod.rtcc.tls);
1406 net->cc_mod.rtcc.new_tot_time = (ltls.tv_sec * 1000000) + ltls.tv_usec;
1412 struct sctp_nets *net)
1418 if (net->cc_mod.rtcc.lbw) {
1421 vtag = (net->rtt << 32) | (((uint32_t)(stcb->sctp_ep->sctp_lport)) << 16) |
1423 probepoint = (((uint64_t)net->cwnd) << 32);
1426 SDT_PROBE(sctp, cwnd, net, rttvar,
1428 ((net->cc_mod.rtcc.lbw << 32) | 0),
1429 ((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
1430 net->flight_size,
1433 net->cc_mod.rtcc.lbw_rtt = 0;
1434 net->cc_mod.rtcc.cwnd_at_bw_set = 0;
1435 net->cc_mod.rtcc.lbw = 0;
1436 net->cc_mod.rtcc.bw_bytes_at_last_rttc = 0;
1437 net->cc_mod.rtcc.vol_reduce = 0;
1438 net->cc_mod.rtcc.bw_tot_time = 0;
1439 net->cc_mod.rtcc.bw_bytes = 0;
1440 net->cc_mod.rtcc.tls_needs_set = 0;
1441 if (net->cc_mod.rtcc.steady_step) {
1442 net->cc_mod.rtcc.vol_reduce = 0;
1443 net->cc_mod.rtcc.step_cnt = 0;
1444 net->cc_mod.rtcc.last_step_state = 0;
1446 if (net->cc_mod.rtcc.ret_from_eq) {
1453 cwnd = min((net->mtu * 4), max((2 * net->mtu), SCTP_INITIAL_CWND));
1461 cwnd = (net->mtu - sizeof(struct sctphdr)) * cwnd_in_mtu;
1463 if (net->cwnd > cwnd) {
1465 net->cwnd = cwnd;
1473 struct sctp_nets *net)
1479 sctp_set_initial_cc_param(stcb, net);
1482 probepoint = (((uint64_t)net->cwnd) << 32);
1484 vtag = (net->rtt << 32) |
1487 SDT_PROBE(sctp, cwnd, net, rttvar,
1494 net->cc_mod.rtcc.lbw_rtt = 0;
1495 net->cc_mod.rtcc.cwnd_at_bw_set = 0;
1496 net->cc_mod.rtcc.vol_reduce = 0;
1497 net->cc_mod.rtcc.lbw = 0;
1498 net->cc_mod.rtcc.vol_reduce = 0;
1499 net->cc_mod.rtcc.bw_bytes_at_last_rttc = 0;
1500 net->cc_mod.rtcc.bw_tot_time = 0;
1501 net->cc_mod.rtcc.bw_bytes = 0;
1502 net->cc_mod.rtcc.tls_needs_set = 0;
1503 net->cc_mod.rtcc.ret_from_eq = SCTP_BASE_SYSCTL(sctp_rttvar_eqret);
1504 net->cc_mod.rtcc.steady_step = SCTP_BASE_SYSCTL(sctp_steady_step);
1505 net->cc_mod.rtcc.use_dccc_ecn = SCTP_BASE_SYSCTL(sctp_use_dccc_ecn);
1506 net->cc_mod.rtcc.step_cnt = 0;
1507 net->cc_mod.rtcc.last_step_state = 0;
1516 struct sctp_nets *net;
1524 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
1525 net->cc_mod.rtcc.ret_from_eq = cc_opt->aid_value.assoc_value;
1532 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
1533 net->cc_mod.rtcc.use_dccc_ecn = cc_opt->aid_value.assoc_value;
1536 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
1537 net->cc_mod.rtcc.steady_step = cc_opt->aid_value.assoc_value;
1545 net = TAILQ_FIRST(&stcb->asoc.nets);
1546 if (net == NULL) {
1549 cc_opt->aid_value.assoc_value = net->cc_mod.rtcc.ret_from_eq;
1551 net = TAILQ_FIRST(&stcb->asoc.nets);
1552 if (net == NULL) {
1555 cc_opt->aid_value.assoc_value = net->cc_mod.rtcc.use_dccc_ecn;
1557 net = TAILQ_FIRST(&stcb->asoc.nets);
1558 if (net == NULL) {
1561 cc_opt->aid_value.assoc_value = net->cc_mod.rtcc.steady_step;
1571 struct sctp_nets *net)
1573 if (net->cc_mod.rtcc.tls_needs_set == 0) {
1574 SCTP_GETPTIME_TIMEVAL(&net->cc_mod.rtcc.tls);
1575 net->cc_mod.rtcc.tls_needs_set = 2;
1590 struct sctp_nets *net,
1593 net->cc_mod.rtcc.rtt_set_this_sack = 1;
1683 sctp_hs_cwnd_increase(struct sctp_tcb *stcb, struct sctp_nets *net)
1687 cur_val = net->cwnd >> 10;
1692 if (net->net_ack > net->mtu) {
1693 net->cwnd += net->mtu;
1695 sctp_log_cwnd(stcb, net, net->mtu, SCTP_CWND_LOG_FROM_SS);
1698 net->cwnd += net->net_ack;
1700 sctp_log_cwnd(stcb, net, net->net_ack, SCTP_CWND_LOG_FROM_SS);
1704 for (i = net->last_hs_used; i < SCTP_HS_TABLE_SIZE; i++) {
1710 net->last_hs_used = indx;
1712 net->cwnd += incr;
1714 sctp_log_cwnd(stcb, net, incr, SCTP_CWND_LOG_FROM_SS);
1720 sctp_hs_cwnd_decrease(struct sctp_tcb *stcb, struct sctp_nets *net)
1723 int old_cwnd = net->cwnd;
1725 cur_val = net->cwnd >> 10;
1728 net->ssthresh = net->cwnd / 2;
1729 if (net->ssthresh < (net->mtu * 2)) {
1730 net->ssthresh = 2 * net->mtu;
1732 net->cwnd = net->ssthresh;
1735 net->ssthresh = net->cwnd - (int)((net->cwnd / 100) *
1736 sctp_cwnd_adjust[net->last_hs_used].drop_percent);
1737 net->cwnd = net->ssthresh;
1739 indx = net->last_hs_used;
1740 cur_val = net->cwnd >> 10;
1744 net->last_hs_used = 0;
1751 net->last_hs_used = indx;
1755 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_FR);
1763 struct sctp_nets *net;
1766 * (net->fast_retran_loss_recovery == 0)))
1768 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
1772 if (net->net_ack > 0) {
1781 sctp_hs_cwnd_decrease(stcb, net);
1785 net->partial_bytes_acked = 0;
1799 net->fast_retran_loss_recovery = 1;
1803 net->fast_recovery_tsn = asoc->sending_seq - 1;
1805 net->fast_recovery_tsn = lchk->rec.data.TSN_seq - 1;
1809 stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_INDATA+SCTP_LOC_32);
1811 stcb->sctp_ep, stcb, net);
1813 } else if (net->net_ack > 0) {
1828 struct sctp_nets *net;
1832 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
1838 if (net->fast_retran_loss_recovery && net->new_pseudo_cumack) {
1839 if (SCTP_TSN_GE(asoc->last_acked_seq, net->fast_recovery_tsn) ||
1840 SCTP_TSN_GE(net->pseudo_cumack,net->fast_recovery_tsn)) {
1841 net->will_exit_fast_recovery = 1;
1846 if (net->net_ack == 0) {
1848 sctp_log_cwnd(stcb, net, 0, SCTP_CWND_LOG_FROM_SACK);
1856 if (sctp_cmt_on_off > 0 && net->fast_retran_loss_recovery && net->will_exit_fast_recovery == 0) {
1877 ((asoc->sctp_cmt_on_off > 0) && net->new_pseudo_cumack)) {
1879 if (net->cwnd <= net->ssthresh) {
1881 if (net->flight_size + net->net_ack >= net->cwnd) {
1883 sctp_hs_cwnd_increase(stcb, net);
1887 sctp_log_cwnd(stcb, net, net->net_ack,
1893 net->partial_bytes_acked += net->net_ack;
1894 if ((net->flight_size + net->net_ack >= net->cwnd) &&
1895 (net->partial_bytes_acked >= net->cwnd)) {
1896 net->partial_bytes_acked -= net->cwnd;
1897 net->cwnd += net->mtu;
1899 sctp_log_cwnd(stcb, net, net->mtu,
1904 sctp_log_cwnd(stcb, net, net->net_ack,
1911 sctp_log_cwnd(stcb, net, net->mtu,
1924 * http://www.hamilton.ie/net/htcp3.pdf
1961 htcp_cwnd_undo(struct sctp_tcb *stcb, struct sctp_nets *net)
1963 net->cc_mod.htcp_ca.last_cong = net->cc_mod.htcp_ca.undo_last_cong;
1964 net->cc_mod.htcp_ca.maxRTT = net->cc_mod.htcp_ca.undo_maxRTT;
1965 net->cc_mod.htcp_ca.old_maxB = net->cc_mod.htcp_ca.undo_old_maxB;
1966 return (max(net->cwnd, ((net->ssthresh/net->mtu<<7)/net->cc_mod.htcp_ca.beta)*net->mtu));
1972 measure_rtt(struct sctp_nets *net)
1974 uint32_t srtt = net->lastsa>>SCTP_RTT_SHIFT;
1977 if (net->cc_mod.htcp_ca.minRTT > srtt || !net->cc_mod.htcp_ca.minRTT)
1978 net->cc_mod.htcp_ca.minRTT = srtt;
1981 if (net->fast_retran_ip == 0 && net->ssthresh < 0xFFFF && htcp_ccount(&net->cc_mod.htcp_ca) > 3) {
1982 if (net->cc_mod.htcp_ca.maxRTT < net->cc_mod.htcp_ca.minRTT)
1983 net->cc_mod.htcp_ca.maxRTT = net->cc_mod.htcp_ca.minRTT;
1984 if (net->cc_mod.htcp_ca.maxRTT < srtt && srtt <= net->cc_mod.htcp_ca.maxRTT+MSEC_TO_TICKS(20))
1985 net->cc_mod.htcp_ca.maxRTT = srtt;
1990 measure_achieved_throughput(struct sctp_nets *net)
1994 if (net->fast_retran_ip == 0)
1995 net->cc_mod.htcp_ca.bytes_acked = net->net_ack;
2002 if (net->fast_retran_ip == 1) {
2003 net->cc_mod.htcp_ca.bytecount = 0;
2004 net->cc_mod.htcp_ca.lasttime = now;
2008 net->cc_mod.htcp_ca.bytecount += net->net_ack;
2009 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)) &&
2010 (now - net->cc_mod.htcp_ca.lasttime >= net->cc_mod.htcp_ca.minRTT) &&
2011 (net->cc_mod.htcp_ca.minRTT > 0)) {
2012 uint32_t cur_Bi = net->cc_mod.htcp_ca.bytecount/net->mtu*hz/(now - net->cc_mod.htcp_ca.lasttime);
2014 if (htcp_ccount(&net->cc_mod.htcp_ca) <= 3) {
2016 net->cc_mod.htcp_ca.minB = net->cc_mod.htcp_ca.maxB = net->cc_mod.htcp_ca.Bi = cur_Bi;
2018 net->cc_mod.htcp_ca.Bi = (3*net->cc_mod.htcp_ca.Bi + cur_Bi)/4;
2019 if (net->cc_mod.htcp_ca.Bi > net->cc_mod.htcp_ca.maxB)
2020 net->cc_mod.htcp_ca.maxB = net->cc_mod.htcp_ca.Bi;
2021 if (net->cc_mod.htcp_ca.minB > net->cc_mod.htcp_ca.maxB)
2022 net->cc_mod.htcp_ca.minB = net->cc_mod.htcp_ca.maxB;
2024 net->cc_mod.htcp_ca.bytecount = 0;
2025 net->cc_mod.htcp_ca.lasttime = now;
2090 htcp_param_update(struct sctp_nets *net)
2092 uint32_t minRTT = net->cc_mod.htcp_ca.minRTT;
2093 uint32_t maxRTT = net->cc_mod.htcp_ca.maxRTT;
2095 htcp_beta_update(&net->cc_mod.htcp_ca, minRTT, maxRTT);
2096 htcp_alpha_update(&net->cc_mod.htcp_ca);
2100 net->cc_mod.htcp_ca.maxRTT = minRTT + ((maxRTT-minRTT)*95)/100;
2104 htcp_recalc_ssthresh(struct sctp_nets *net)
2106 htcp_param_update(net);
2107 return (max(((net->cwnd/net->mtu * net->cc_mod.htcp_ca.beta) >> 7)*net->mtu, 2U*net->mtu));
2111 htcp_cong_avoid(struct sctp_tcb *stcb, struct sctp_nets *net)
2118 if (net->cwnd <= net->ssthresh) {
2120 if (net->flight_size + net->net_ack >= net->cwnd) {
2121 if (net->net_ack > (net->mtu * SCTP_BASE_SYSCTL(sctp_L2_abc_variable))) {
2122 net->cwnd += (net->mtu * SCTP_BASE_SYSCTL(sctp_L2_abc_variable));
2124 sctp_log_cwnd(stcb, net, net->mtu,
2129 net->cwnd += net->net_ack;
2131 sctp_log_cwnd(stcb, net, net->net_ack,
2138 sctp_log_cwnd(stcb, net, net->net_ack,
2143 measure_rtt(net);
2146 * In theory this is net->cwnd += alpha / net->cwnd
2149 if (((net->partial_bytes_acked/net->mtu * net->cc_mod.htcp_ca.alpha) >> 7)*net->mtu >= net->cwnd) {
2152 * if (net->snd_cwnd < net->snd_cwnd_clamp) - Nope (RRS).
2154 net->cwnd += net->mtu;
2155 net->partial_bytes_acked = 0;
2156 htcp_alpha_update(&net->cc_mod.htcp_ca);
2158 sctp_log_cwnd(stcb, net, net->mtu,
2162 net->partial_bytes_acked += net->net_ack;
2164 sctp_log_cwnd(stcb, net, net->net_ack,
2169 net->cc_mod.htcp_ca.bytes_acked = net->mtu;
2176 htcp_min_cwnd(struct sctp_tcb *stcb, struct sctp_nets *net)
2178 return (net->ssthresh);
2183 htcp_init(struct sctp_nets *net)
2185 memset(&net->cc_mod.htcp_ca, 0, sizeof(struct htcp));
2186 net->cc_mod.htcp_ca.alpha = ALPHA_BASE;
2187 net->cc_mod.htcp_ca.beta = BETA_MIN;
2188 net->cc_mod.htcp_ca.bytes_acked = net->mtu;
2189 net->cc_mod.htcp_ca.last_cong = sctp_get_tick_count();
2193 sctp_htcp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net)
2199 net->cwnd = min((net->mtu * 4), max((2 * net->mtu), SCTP_INITIAL_CWND));
2200 net->ssthresh = stcb->asoc.peers_rwnd;
2201 htcp_init(net);
2204 sctp_log_cwnd(stcb, net, 0, SCTP_CWND_INITIALIZATION);
2213 struct sctp_nets *net;
2218 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
2224 if (net->fast_retran_loss_recovery && net->new_pseudo_cumack) {
2225 if (SCTP_TSN_GE(asoc->last_acked_seq, net->fast_recovery_tsn) ||
2226 SCTP_TSN_GE(net->pseudo_cumack,net->fast_recovery_tsn)) {
2227 net->will_exit_fast_recovery = 1;
2232 if (net->net_ack == 0) {
2234 sctp_log_cwnd(stcb, net, 0, SCTP_CWND_LOG_FROM_SACK);
2242 if (sctp_cmt_on_off > 0 && net->fast_retran_loss_recovery && net->will_exit_fast_recovery == 0) {
2263 ((asoc->sctp_cmt_on_off > 0) && net->new_pseudo_cumack)) {
2264 htcp_cong_avoid(stcb, net);
2265 measure_achieved_throughput(net);
2268 sctp_log_cwnd(stcb, net, net->mtu,
2279 struct sctp_nets *net;
2282 * (net->fast_retran_loss_recovery == 0)))
2284 TAILQ_FOREACH(net, &asoc->nets, sctp_next) {
2288 if (net->net_ack > 0) {
2296 int old_cwnd = net->cwnd;
2299 htcp_reset(&net->cc_mod.htcp_ca);
2300 net->ssthresh = htcp_recalc_ssthresh(net);
2301 net->cwnd = net->ssthresh;
2303 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd),
2308 net->partial_bytes_acked = 0;
2322 net->fast_retran_loss_recovery = 1;
2326 net->fast_recovery_tsn = asoc->sending_seq - 1;
2328 net->fast_recovery_tsn = lchk->rec.data.TSN_seq - 1;
2332 stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_INDATA+SCTP_LOC_32);
2334 stcb->sctp_ep, stcb, net);
2336 } else if (net->net_ack > 0) {
2348 struct sctp_nets *net)
2350 int old_cwnd = net->cwnd;
2353 htcp_reset(&net->cc_mod.htcp_ca);
2354 net->ssthresh = htcp_recalc_ssthresh(net);
2355 net->cwnd = net->mtu;
2356 net->partial_bytes_acked = 0;
2358 sctp_log_cwnd(stcb, net, net->cwnd - old_cwnd, SCTP_CWND_LOG_FROM_RTX);
2364 struct sctp_nets *net, int in_window, int num_pkt_lost SCTP_UNUSED)
2367 old_cwnd = net->cwnd;
2371 htcp_reset(&net->cc_mod.htcp_ca);
2373 net->ssthresh = htcp_recalc_ssthresh(net);
2374 if (net->ssthresh < net->mtu) {
2375 net->ssthresh = net->mtu;
2377 net->RTO <<= 1;
2379 net->cwnd = net->ssthresh;
2381 sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT);