Successfully synchronizes state. Here testing with 50% bidi packet loss.

This commit is contained in:
Keith Winstein
2011-08-09 22:36:22 -04:00
parent 188c44f5be
commit 66a64f0b22
6 changed files with 193 additions and 37 deletions
+15
View File
@@ -1,4 +1,5 @@
#include <endian.h>
#include <assert.h>
#include "networktransport.hpp"
@@ -17,7 +18,21 @@ string Instruction::tostring( void )
ret += network_order_string( old_num );
ret += network_order_string( new_num );
ret += network_order_string( ack_num );
ret += network_order_string( throwaway_num );
ret += diff;
return ret;
}
Instruction::Instruction( string &x )
: old_num( -1 ), new_num( -1 ), ack_num( -1 ), throwaway_num( -1 ), diff()
{
assert( x.size() >= 4 * sizeof( uint64_t ) );
uint64_t *data = (uint64_t *)x.data();
old_num = be64toh( data[ 0 ] );
new_num = be64toh( data[ 1 ] );
ack_num = be64toh( data[ 2 ] );
throwaway_num = be64toh( data[ 3 ] );
diff = string( x.begin() + 4 * sizeof( uint64_t ), x.end() );
}