@@ -170,6 +170,22 @@ void Connection::offer(size_t& packets)
170170
171171 // write until we either cant send more (window closes or no more in queue),
172172 // or we're out of packets.
173+
174+ static bool congested=false ;
175+ if (!can_send ())
176+ {
177+ if (sendq_remaining () > 0 )
178+ {
179+ printf (" Window_blocked %d data %zu empty packets sw=%ld fs=%ld WND=%d\n " ,sendq_remaining (),packets,(int64_t )send_window (), (int64_t )flight_size (),cb.SND .WND );
180+ congested=true ;
181+ }
182+ }
183+ if (can_send () && congested)
184+ {
185+ printf (" Window released congestion removed %zu packets\n " ,packets);
186+ congested=false ;
187+ }
188+
173189 while (can_send () and packets)
174190 {
175191 auto packet = create_outgoing_packet ();
@@ -397,49 +413,44 @@ bool Connection::handle_ack(const Packet_view& in)
397413 } // < dup ack
398414
399415 // new ack
400- else if (LIKELY (in.ack () >= cb.SND .UNA ))
401- {
402- if (is_win_update (in, true_win))
403- {
404- cb.SND .WND = true_win;
405- cb.SND .WL1 = in.seq ();
406- cb.SND .WL2 = in.ack ();
407- // printf("<Connection::handle_ack> Window update (%u)\n", cb.SND.WND);
408- }
409- // pred_flags = htonl((in.tcp_header_length() << 26) | 0x10 | cb.SND.WND >> cb.SND.wind_shift);
410-
411- // [RFC 6582] p. 8
412- prev_highest_ack_ = cb.SND .UNA ;
413- highest_ack_ = in.ack ();
414416
415- if (cb.SND .TS_OK )
416- {
417- const auto * ts = in.ts_option ();
418- if (ts != nullptr ) // TODO: not sure the packet is valid if TS missing
419- last_acked_ts_ = ts->ecr ;
420- }
417+ if (is_win_update (in, true_win))
418+ {
419+ cb.SND .WND = true_win;
420+ cb.SND .WL1 = in.seq ();
421+ cb.SND .WL2 = in.ack ();
422+ // printf("<Connection::handle_ack> Window update (%u)\n", cb.SND.WND);
423+ }
424+ // pred_flags = htonl((in.tcp_header_length() << 26) | 0x10 | cb.SND.WND >> cb.SND.wind_shift);
421425
422- cb.SND .UNA = in.ack ();
426+ // [RFC 6582] p. 8
427+ prev_highest_ack_ = cb.SND .UNA ;
428+ highest_ack_ = in.ack ();
423429
424- rtx_ack (in.ack ());
430+ if (cb.SND .TS_OK )
431+ {
432+ const auto * ts = in.ts_option ();
433+ if (ts != nullptr ) // TODO: not sure the packet is valid if TS missing
434+ last_acked_ts_ = ts->ecr ;
435+ }
425436
426- take_rtt_measure (in );
437+ cb. SND . UNA = in. ack ( );
427438
428- // do either congctrl or fastrecov according to New Reno
429- (not fast_recovery_)
430- ? congestion_control (in) : fast_recovery (in);
439+ rtx_ack (in.ack ());
431440
432- dup_acks_ = 0 ;
441+ take_rtt_measure (in) ;
433442
434- if (in.has_tcp_data () or in.isset (FIN))
435- return true ;
443+ // do either congctrl or fastrecov according to New Reno
444+ (not fast_recovery_)
445+ ? congestion_control (in) : fast_recovery (in);
436446
437- } // < new ack
447+ dup_acks_ = 0 ;
438448
439- // ACK outside
440- else {
449+ if (in.has_tcp_data () or in.isset (FIN))
441450 return true ;
442- }
451+
452+ // < new ack
453+ // Nothing to process
443454 return false ;
444455}
445456
0 commit comments