Send ACKs when timestamp pending

This commit is contained in:
Keith Winstein
2011-08-10 02:05:49 -04:00
parent db2fa133cf
commit b2ea532f14
3 changed files with 10 additions and 7 deletions
+6 -4
View File
@@ -94,8 +94,8 @@ Connection::Connection() /* server */
next_seq( 0 ),
saved_timestamp( -1 ),
RTT_hit( false ),
SRTT( 1 ),
RTTVAR( .5 )
SRTT( 1000 ),
RTTVAR( 500 )
{
setup();
}
@@ -112,8 +112,8 @@ Connection::Connection( const char *key_str, const char *ip, int port ) /* clien
next_seq( 0 ),
saved_timestamp( -1 ),
RTT_hit( false ),
SRTT( 1 ),
RTTVAR( .5 )
SRTT( 1000 ),
RTTVAR( 500 )
{
setup();
@@ -204,6 +204,8 @@ string Connection::recv( void )
assert( now >= p.timestamp_reply );
const double R = now - p.timestamp_reply;
fprintf( stderr, "Saw delay of %f\r\n", R );
if ( !RTT_hit ) { /* first measurement */
SRTT = R;
RTTVAR = R / 2;
+1
View File
@@ -95,6 +95,7 @@ namespace Network {
bool get_attached( void ) { return attached; }
int timeout( void ) { return (int)lrint( ceil( SRTT + 4 * RTTVAR ) ); }
bool pending_timestamp( void ) { return ( saved_timestamp != uint64_t(-1) ); }
};
}
+3 -3
View File
@@ -78,7 +78,8 @@ void Transport<MyState, RemoteState>::send_to_receiver( void )
if ( assumed_receiver_state->state == target_receiver_state ) {
/* send empty ack */
if ( timestamp() - sent_states.back().timestamp < int64_t( ACK_INTERVAL ) ) {
if ( (!connection.pending_timestamp())
&& (timestamp() - sent_states.back().timestamp < int64_t( ACK_INTERVAL )) ) {
return;
}
@@ -147,7 +148,7 @@ void Transport<MyState, RemoteState>::send_to_receiver( void )
string s = inst.tostring();
try {
fprintf( stderr, "Sent instruction from %d => %d (terminal %d): %s\r\n", int(inst.old_num), int(inst.new_num), int(sent_states.back().num), inst.diff.c_str() );
fprintf( stderr, "Sent instruction (timeout %d) from %d => %d (terminal %d): %s\r\n", connection.timeout(), int(inst.old_num), int(inst.new_num), int(sent_states.back().num), inst.diff.c_str() );
connection.send( s );
} catch ( MTUException m ) {
continue;
@@ -200,7 +201,6 @@ void Transport<MyState, RemoteState>::recv( void )
Instruction inst( s );
process_acknowledgment_through( inst.ack_num );
// process_throwaway_until( inst.throwaway.num );
/* first, make sure we don't already have the new state */
for ( typename list< TimestampedState<RemoteState> >::iterator i = received_states.begin();