TransportReassembly.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef OPENDDS_DCPS_TRANSPORTREASSEMBLY
00009 #define OPENDDS_DCPS_TRANSPORTREASSEMBLY
00010 
00011 #include "dds/DCPS/dcps_export.h"
00012 #include "dds/DCPS/Definitions.h"
00013 #include "ReceivedDataSample.h"
00014 #include "dds/DCPS/PoolAllocator.h"
00015 
00016 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00017 
00018 namespace OpenDDS {
00019 namespace DCPS {
00020 
00021 class OpenDDS_Dcps_Export TransportReassembly {
00022 public:
00023 
00024   /// Called by TransportReceiveStrategy if the fragmentation header flag
00025   /// is set.  Returns true/false to indicate if data should be delivered to
00026   /// the datalink.  The 'data' argument may be modified by this method.
00027   bool reassemble(const SequenceNumber& transportSeq, bool firstFrag,
00028                   ReceivedDataSample& data);
00029 
00030   bool reassemble(const SequenceRange& seqRange, ReceivedDataSample& data);
00031 
00032   /// Called by TransportReceiveStrategy to indicate that we can
00033   /// stop tracking partially-reassembled messages when we know the
00034   /// remaining fragments are not expected to arrive.
00035   void data_unavailable(const SequenceRange& transportSeqDropped);
00036 
00037   void data_unavailable(const SequenceNumber& dataSampleSeq,
00038                         const RepoId& pub_id);
00039 
00040   /// Returns true if this object is storing fragments for the given
00041   /// DataSampleHeader sequence number from the given publication.
00042   bool has_frags(const SequenceNumber& seq, const RepoId& pub_id) const;
00043 
00044   /// Populates bitmap for missing fragment sequence numbers and set numBits
00045   /// for the given message sequence and publisher ID.
00046   /// @returns the base fragment sequence number for bit zero in the bitmap
00047   CORBA::ULong get_gaps(const SequenceNumber& msg_seq, const RepoId& pub_id,
00048                         CORBA::Long bitmap[], CORBA::ULong length,
00049                         CORBA::ULong& numBits) const;
00050 
00051 private:
00052 
00053   bool reassemble_i(const SequenceRange& seqRange, bool firstFrag,
00054                     ReceivedDataSample& data);
00055 
00056   // A FragKey represents the identifier for an original (pre-fragmentation)
00057   // message.  Since DataSampleHeader sequence numbers are distinct for each
00058   // "publication" (DataWriter), the partially-received messages need to be
00059   // stored in a structure that's keyed off of both the PublicationId and the
00060   // SequenceNumber.
00061   struct FragKey {
00062     FragKey(const PublicationId& pubId, const SequenceNumber& dataSampleSeq);
00063 
00064     bool operator<(const FragKey& rhs) const
00065     {
00066       if (compare_(this->publication_, rhs.publication_)) return true;
00067       if (compare_(rhs.publication_, this->publication_)) return false;
00068       return this->data_sample_seq_ < rhs.data_sample_seq_;
00069     }
00070 
00071     static GUID_tKeyLessThan compare_;
00072     PublicationId publication_;
00073     SequenceNumber data_sample_seq_;
00074   };
00075 
00076   // A FragRange represents a chunk of a partially-reassembled message.
00077   // The transport_seq_ range is the range of transport sequence numbers
00078   // that were used to send the given chunk of data.
00079   struct FragRange {
00080     FragRange(const SequenceRange& seqRange,
00081               const ReceivedDataSample& data);
00082 
00083     SequenceRange transport_seq_;
00084     ReceivedDataSample rec_ds_;
00085   };
00086 
00087   // Each element of the FragMap "fragments_" represents one sent message
00088   // (one DataSampleHeader before fragmentation).  The list must have at
00089   // least one value in it.  If a FragRange in the list has a sample_ with
00090   // a null ACE_Message_Block*, it's one that was data_unavailable().
00091   typedef OPENDDS_MAP(FragKey, OPENDDS_LIST(FragRange) ) FragMap;
00092   FragMap fragments_;
00093 
00094   OPENDDS_SET(FragKey) have_first_;
00095 
00096   static bool insert(OPENDDS_LIST(FragRange)& flist,
00097                      const SequenceRange& seqRange,
00098                      ReceivedDataSample& data);
00099 };
00100 
00101 }
00102 }
00103 
00104 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00105 
00106 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1