Hello,
Now that my code has started to work in the memory-only mode of IBR-DTN
I went on to testing it with the disk-based storage, which I assume I
activated because I entered in some directories for the bundles to be
stored in, in the config file. IBR-DTN also acknowledged that it was using
simple storage. When I started it though, the program basically froze the
first time I tried to interact with a bundle, whereas it was fine in memory
only mode. The conditions that caused this were as follows:
1. I got a bundle from storage in the queuebundleevent, checked if it was
a bundle I put in though dtnsend, and forward it to an event handler in the
router.
2. I again check for some more bundle issues in the event handler, then
send the bundle forward again to another function that will basically split
up the bundle
3. In my function I attempt to create a DefaultSerializer using a blank
blob reference and stream the bundle into it.
The last step is where my function is failing. The output is giving me an
exception that says that the output stream went bad and 0 out of the 49000
bytes in my original bundle were read.
Any ideas as to why this is happening only in the simple storage and not
memory only? Below is a code segment that shows what i am doing. Thank
you.
Carson Dunbar
u_int32_t
NCRoutingExtension::generate_and_enqueue_encodings(dtn::data::Bundle
bundle, u_int32_t max_chunk_size)
{
// start with just the standard basis, i.e. fragmentation
// need to figure out the number of chunks that will be created
// still requiring the number of chunks to be a multiple of 8?
// let's try to not require it
//
dtn::core::BundleStorage &storage = (**this).getStorage();
u_int32_t num_chunks, chunk_size;
size_t orig_bundle_len = 0;
size_t block_len;
ibrcommon::BLOB::Reference ref = ibrcommon::BLOB::create();
dtn::data::DefaultSerializer serializer(*ref.iostream());
try {
// activate exceptions for this method
if (!ref.iostream()->good()) throw ibrcommon::IOException("stream went
bad");
serializer << (bundle);
// flush the stream
(*ref.iostream()) << std::flush;
} catch (const ibrcommon::Exception &ex) {
IBRCOMMON_LOGGER_DEBUG(10) << ex.what() << IBRCOMMON_LOGGER_ENDL;
throw;
}