dtn::FragmentManager Class Reference

The Fragment Manager maintains state for all of the fragmentary bundles, reconstructing whole bundles from partial bundles. More...

#include <FragmentManager.h>

List of all members.

Public Member Functions

 FragmentManager ()
 Constructor.
Bundlecreate_fragment (Bundle *bundle, BlockInfoVec *blocks, size_t offset, size_t length)
 Create a bundle fragment from another bundle.
Bundlecreate_fragment (Bundle *bundle, const LinkRef &link, const BlockInfoPointerList &blocks_to_copy, size_t offset, size_t length)
 Create a fragment to be sent out on a particular link.
void convert_to_fragment (Bundle *bundle, size_t length)
 Turn a bundle into a fragment.
FragmentStateproactively_fragment (Bundle *bundle, const LinkRef &link, size_t max_length)
 Given the given fragmentation threshold, determine whether the given bundle should be split into several smaller bundles.
FragmentStateget_fragment_state (Bundle *bundle)
void erase_fragment_state (FragmentState *fragment)
bool try_to_reactively_fragment (Bundle *bundle, BlockInfoVec *blocks, size_t bytes_sent)
 If only part of the given bundle was sent successfully, split it into two.
bool try_to_convert_to_fragment (Bundle *bundle)
 Convert a partially received bundle into a fragment.
void process_for_reassembly (Bundle *fragment)
 Given a newly arrived bundle fragment, append it to the table of fragments and see if it allows us to reassemble the bundle.
void delete_obsoleted_fragments (Bundle *fragment)
 Delete any fragments that are no longer needed given the incoming (non-fragment) bundle.
void delete_fragment (Bundle *fragment)
 Delete reassembly state for a bundle.

Protected Types

typedef oasys::StringHashMap
< FragmentState * > 
FragmentTable
 Check if the bundle has been completely reassembled.

Protected Member Functions

void get_hash_key (const Bundle *, std::string *key)
 Calculate a hash table key from a bundle.

Protected Attributes

FragmentTable fragment_table_

Detailed Description

The Fragment Manager maintains state for all of the fragmentary bundles, reconstructing whole bundles from partial bundles.

It also implements the routine for creating bundle fragments from larger bundles.

Definition at line 49 of file FragmentManager.h.


Member Typedef Documentation

typedef oasys::StringHashMap<FragmentState*> dtn::FragmentManager::FragmentTable [protected]

Check if the bundle has been completely reassembled.

Table of partial bundles

Definition at line 160 of file FragmentManager.h.


Constructor & Destructor Documentation

dtn::FragmentManager::FragmentManager (  ) 

Constructor.

Definition at line 35 of file FragmentManager.cc.


Member Function Documentation

void dtn::FragmentManager::convert_to_fragment ( Bundle bundle,
size_t  length 
)

Turn a bundle into a fragment.

Note this is used just for reactive fragmentation on a newly received partial bundle and therefore the offset is implicitly zero (unless the bundle was already a fragment).

Bundle * dtn::FragmentManager::create_fragment ( Bundle bundle,
const LinkRef link,
const BlockInfoPointerList blocks_to_copy,
size_t  offset,
size_t  length 
)
Bundle * dtn::FragmentManager::create_fragment ( Bundle bundle,
BlockInfoVec blocks,
size_t  offset,
size_t  length 
)

Create a bundle fragment from another bundle.

Parameters:
bundle the source bundle from which we create the fragment. Note: the bundle may itself be a fragment
offset the offset relative to this bundle (not the original) for the for the new fragment. note that if this bundle is already a fragment, the offset into the original bundle will be this bundle's frag_offset + offset
length the length of the fragment we want
Returns:
pointer to the newly created bundle

Definition at line 42 of file FragmentManager.cc.

References dtn::BundleProtocol::BLOCK_FLAG_REPLICATE, dtn::Bundle::copy_metadata(), dtn::Bundle::frag_offset(), dtn::Bundle::is_fragment(), dtn::BundlePayload::length(), dtn::Bundle::mutable_payload(), dtn::Bundle::mutable_recv_blocks(), dtn::Bundle::orig_length(), dtn::Bundle::payload(), dtn::BundleProtocol::PAYLOAD_BLOCK, dtn::BundleProtocol::PRIMARY_BLOCK, dtn::Bundle::set_do_not_fragment(), dtn::Bundle::set_frag_offset(), dtn::Bundle::set_is_fragment(), dtn::BundlePayload::set_length(), dtn::Bundle::set_orig_length(), and dtn::BundlePayload::write_data().

Referenced by proactively_fragment(), and try_to_reactively_fragment().

void dtn::FragmentManager::delete_fragment ( Bundle fragment  ) 
void dtn::FragmentManager::delete_obsoleted_fragments ( Bundle fragment  ) 
void dtn::FragmentManager::erase_fragment_state ( FragmentState fragment  ) 

Definition at line 315 of file FragmentManager.cc.

References dtn::FragmentState::bundle(), fragment_table_, and get_hash_key().

FragmentState * dtn::FragmentManager::get_fragment_state ( Bundle bundle  ) 

Definition at line 300 of file FragmentManager.cc.

void dtn::FragmentManager::get_hash_key ( const Bundle bundle,
std::string *  key 
) [protected]
FragmentState * dtn::FragmentManager::proactively_fragment ( Bundle bundle,
const LinkRef link,
size_t  max_length 
)

Given the given fragmentation threshold, determine whether the given bundle should be split into several smaller bundles.

If so, this returns true and generates a bunch of bundle received events for the individual fragments.

Return the number of fragments created or zero if none were created.

Definition at line 241 of file FragmentManager.cc.

References dtn::FragmentState::add_fragment(), ASSERT, dtn::BundleProtocol::BLOCK_FLAG_REPLICATE, count, create_fragment(), dtn::LinkBlockSet::find_blocks(), dtn::BlockInfo::flags(), fragment_table_, get_hash_key(), dtn::BundlePayload::length(), dtn::Bundle::payload(), dtn::BundleProtocol::PAYLOAD_BLOCK, dtn::BundleProtocol::PRIMARY_BLOCK, dtn::BlockInfo::type(), and dtn::Bundle::xmit_blocks().

void dtn::FragmentManager::process_for_reassembly ( Bundle fragment  ) 
bool dtn::FragmentManager::try_to_convert_to_fragment ( Bundle bundle  ) 
bool dtn::FragmentManager::try_to_reactively_fragment ( Bundle bundle,
BlockInfoVec blocks,
size_t  bytes_sent 
)

Member Data Documentation


The documentation for this class was generated from the following files:
Generated on Sun Nov 21 13:21:13 2010 for DTN Reference Implementation by  doxygen 1.6.3