Send ACKs when timestamp pending
This commit is contained in:
+6
-4
@@ -94,8 +94,8 @@ Connection::Connection() /* server */
|
|||||||
next_seq( 0 ),
|
next_seq( 0 ),
|
||||||
saved_timestamp( -1 ),
|
saved_timestamp( -1 ),
|
||||||
RTT_hit( false ),
|
RTT_hit( false ),
|
||||||
SRTT( 1 ),
|
SRTT( 1000 ),
|
||||||
RTTVAR( .5 )
|
RTTVAR( 500 )
|
||||||
{
|
{
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
@@ -112,8 +112,8 @@ Connection::Connection( const char *key_str, const char *ip, int port ) /* clien
|
|||||||
next_seq( 0 ),
|
next_seq( 0 ),
|
||||||
saved_timestamp( -1 ),
|
saved_timestamp( -1 ),
|
||||||
RTT_hit( false ),
|
RTT_hit( false ),
|
||||||
SRTT( 1 ),
|
SRTT( 1000 ),
|
||||||
RTTVAR( .5 )
|
RTTVAR( 500 )
|
||||||
{
|
{
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
@@ -204,6 +204,8 @@ string Connection::recv( void )
|
|||||||
assert( now >= p.timestamp_reply );
|
assert( now >= p.timestamp_reply );
|
||||||
const double R = 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 */
|
if ( !RTT_hit ) { /* first measurement */
|
||||||
SRTT = R;
|
SRTT = R;
|
||||||
RTTVAR = R / 2;
|
RTTVAR = R / 2;
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ namespace Network {
|
|||||||
bool get_attached( void ) { return attached; }
|
bool get_attached( void ) { return attached; }
|
||||||
|
|
||||||
int timeout( void ) { return (int)lrint( ceil( SRTT + 4 * RTTVAR ) ); }
|
int timeout( void ) { return (int)lrint( ceil( SRTT + 4 * RTTVAR ) ); }
|
||||||
|
bool pending_timestamp( void ) { return ( saved_timestamp != uint64_t(-1) ); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,8 @@ void Transport<MyState, RemoteState>::send_to_receiver( void )
|
|||||||
|
|
||||||
if ( assumed_receiver_state->state == target_receiver_state ) {
|
if ( assumed_receiver_state->state == target_receiver_state ) {
|
||||||
/* send empty ack */
|
/* 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ void Transport<MyState, RemoteState>::send_to_receiver( void )
|
|||||||
string s = inst.tostring();
|
string s = inst.tostring();
|
||||||
|
|
||||||
try {
|
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 );
|
connection.send( s );
|
||||||
} catch ( MTUException m ) {
|
} catch ( MTUException m ) {
|
||||||
continue;
|
continue;
|
||||||
@@ -200,7 +201,6 @@ void Transport<MyState, RemoteState>::recv( void )
|
|||||||
Instruction inst( s );
|
Instruction inst( s );
|
||||||
|
|
||||||
process_acknowledgment_through( inst.ack_num );
|
process_acknowledgment_through( inst.ack_num );
|
||||||
// process_throwaway_until( inst.throwaway.num );
|
|
||||||
|
|
||||||
/* first, make sure we don't already have the new state */
|
/* first, make sure we don't already have the new state */
|
||||||
for ( typename list< TimestampedState<RemoteState> >::iterator i = received_states.begin();
|
for ( typename list< TimestampedState<RemoteState> >::iterator i = received_states.begin();
|
||||||
|
|||||||
Reference in New Issue
Block a user