Switch to 64-bit fragment ID, fragmenting in separate function

This commit is contained in:
Keith Winstein
2011-09-13 00:55:18 -04:00
parent 62daa19f28
commit a24443638b
6 changed files with 83 additions and 52 deletions
+20 -4
View File
@@ -11,13 +11,15 @@ using namespace std;
using namespace TransportBuffers;
namespace Network {
static const int HEADER_LEN = 66;
class Fragment
{
private:
static const size_t frag_header_len = 2 * sizeof( uint16_t );
static const size_t frag_header_len = sizeof( uint64_t ) + sizeof( uint16_t );
public:
uint16_t id;
uint64_t id;
uint16_t fragment_num;
bool final;
@@ -29,7 +31,7 @@ namespace Network {
: id( -1 ), fragment_num( -1 ), final( false ), initialized( false ), contents()
{}
Fragment( uint16_t s_id, uint16_t s_fragment_num, bool s_final, string s_contents )
Fragment( uint64_t s_id, uint16_t s_fragment_num, bool s_final, string s_contents )
: id( s_id ), fragment_num( s_fragment_num ), final( s_final ), initialized( true ),
contents( s_contents )
{}
@@ -45,7 +47,7 @@ namespace Network {
{
private:
vector<Fragment> fragments;
uint16_t current_id;
uint64_t current_id;
int fragments_arrived, fragments_total;
public:
@@ -53,6 +55,20 @@ namespace Network {
bool add_fragment( Fragment &inst );
Instruction get_assembly( void );
};
class Fragmenter
{
private:
uint64_t next_instruction_id;
Instruction last_instruction;
int last_MTU;
public:
Fragmenter() : next_instruction_id( 0 ), last_instruction(), last_MTU( -1 ) {}
vector<Fragment> make_fragments( Instruction &inst, int MTU );
uint64_t last_ack_sent( void ) { return last_instruction.ack_num(); }
};
}
#endif