dtn::FragmentManager Class Reference

#include <FragmentManager.h>

Inheritance diagram for dtn::FragmentManager:

oasys::Logger List of all members.

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 66 of file FragmentManager.h.

Public Member Functions

 FragmentManager ()
 Constructor.
Bundlecreate_fragment (Bundle *bundle, size_t offset, size_t length)
 Create a bundle fragment from another bundle.
void convert_to_fragment (Bundle *bundle, size_t length)
 Turn a bundle into a fragment.
int proactively_fragment (Bundle *bundle, size_t max_length)
 Given the given fragmentation threshold, determine whether the given bundle should be split into several smaller bundles.
bool try_to_reactively_fragment (Bundle *bundle, size_t bytes_sent)
 If only part of the given bundle was sent successfully, create a new fragment for the unsent portion.
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.

Protected Types

typedef oasys::StringHashMap<
ReassemblyState * > 
ReassemblyTable
 Table of partial bundles.

Protected Member Functions

void get_hash_key (const Bundle *, std::string *key)
 Calculate a hash table key from a bundle.
bool check_completed (ReassemblyState *state)
 Check if the bundle has been completely reassembled.

Protected Attributes

ReassemblyTable reassembly_table_

Classes

struct  ReassemblyState
 Reassembly state structure. More...


Member Typedef Documentation

typedef oasys::StringHashMap<ReassemblyState*> dtn::FragmentManager::ReassemblyTable [protected]

Table of partial bundles.

Definition at line 151 of file FragmentManager.h.


Constructor & Destructor Documentation

dtn::FragmentManager::FragmentManager (  ) 

Constructor.

Definition at line 49 of file FragmentManager.cc.


Member Function Documentation

Bundle * dtn::FragmentManager::create_fragment ( Bundle bundle,
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 56 of file FragmentManager.cc.

References dtn::BundlePayload::close_file(), dtn::Bundle::copy_metadata(), dtn::Bundle::do_not_fragment_, dtn::Bundle::frag_offset_, dtn::Bundle::is_fragment_, dtn::BundlePayload::length(), dtn::Bundle::orig_length_, dtn::Bundle::payload_, dtn::BundlePayload::set_length(), and dtn::BundlePayload::write_data().

Referenced by proactively_fragment(), and try_to_reactively_fragment().

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).

Definition at line 94 of file FragmentManager.cc.

References ASSERT, dtn::Bundle::frag_offset_, dtn::Bundle::is_fragment_, dtn::BundlePayload::length(), dtn::Bundle::orig_length_, dtn::Bundle::payload_, and dtn::BundlePayload::truncate().

Referenced by dtn::BundleDaemon::handle_bundle_received().

int dtn::FragmentManager::proactively_fragment ( Bundle bundle,
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 236 of file FragmentManager.cc.

References ASSERT, dtn::BundlePayload::close_file(), count, create_fragment(), dtn::EVENTSRC_FRAGMENTATION, dtn::BundlePayload::length(), log_info, dtn::Bundle::payload_, and dtn::BundleDaemon::post().

bool dtn::FragmentManager::try_to_reactively_fragment ( Bundle bundle,
size_t  bytes_sent 
)

If only part of the given bundle was sent successfully, create a new fragment for the unsent portion.

Return true if a fragment was created

Definition at line 279 of file FragmentManager.cc.

References dtn::BundlePayload::close_file(), create_fragment(), dtn::EVENTSRC_FRAGMENTATION, dtn::BundlePayload::length(), log_debug, dtn::Bundle::payload_, and dtn::BundleDaemon::post_at_head().

Referenced by dtn::BundleDaemon::handle_bundle_transmitted().

void dtn::FragmentManager::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.

If it does, a ReassemblyCompletedEvent will be posted.

Definition at line 306 of file FragmentManager.cc.

References ASSERT, dtn::FragmentManager::ReassemblyState::bundle_, dtn::Bundle::bundleid_, check_completed(), dtn::Bundle::copy_metadata(), dtn::BundlePayload::DISK, dtn::Bundle::frag_offset_, dtn::FragmentManager::ReassemblyState::fragments_, get_hash_key(), dtn::BundleList::insert_sorted(), dtn::Bundle::is_fragment_, dtn::BundlePayload::length(), log_debug, oasys::Ref< _Type >::object(), dtn::Bundle::orig_length_, dtn::Bundle::payload_, dtn::BundleDaemon::post_at_head(), reassembly_table_, dtn::BundleList::size(), and dtn::BundleList::SORT_FRAG_OFFSET.

Referenced by dtn::BundleDaemon::deliver_to_registration().

void dtn::FragmentManager::get_hash_key ( const Bundle ,
std::string *  key 
) [protected]

Calculate a hash table key from a bundle.

Definition at line 114 of file FragmentManager.cc.

References dtn::EndpointID::c_str(), dtn::Bundle::creation_ts_, dtn::Bundle::dest_, dtn::BundleTimestamp::seconds_, dtn::BundleTimestamp::seqno_, and dtn::Bundle::source_.

Referenced by process_for_reassembly().

bool dtn::FragmentManager::check_completed ( ReassemblyState state  )  [protected]

Check if the bundle has been completely reassembled.

Definition at line 128 of file FragmentManager.cc.

References ASSERT, dtn::BundleList::begin(), dtn::FragmentManager::ReassemblyState::bundle_, dtn::BundleList::end(), dtn::Bundle::frag_offset_, dtn::FragmentManager::ReassemblyState::fragments_, dtn::Bundle::is_fragment_, ExamineDump::l, dtn::BundlePayload::length(), dtn::BundleList::lock(), log_debug, NOTREACHED, dtn::Bundle::orig_length_, dtn::Bundle::payload_, and dtn::BundleList::size().

Referenced by process_for_reassembly().


Member Data Documentation

ReassemblyTable dtn::FragmentManager::reassembly_table_ [protected]

Definition at line 152 of file FragmentManager.h.

Referenced by process_for_reassembly().


The documentation for this class was generated from the following files:
Generated on Fri Dec 22 14:48:03 2006 for DTN Reference Implementation by  doxygen 1.5.1