void DeliveryPredictabilityMap::update(const dtn::data::EID &host_b, const DeliveryPredictabilityMap &dpm, const float &p_encounter_first) { float p_ab = 0.0f; try { p_ab = get(host_b); } catch (const DeliveryPredictabilityMap::ValueNotFoundException&) { p_ab = p_encounter_first; } /** * Calculate transitive values */ for (predictmap::const_iterator it = dpm._predictmap.begin(); it != dpm._predictmap.end(); ++it) { const dtn::data::EID &host_c = it->first; const float &p_bc = it->second; // do not update values for the origin host if (host_b.sameHost(host_c)) continue; // do not process values with our own EID if (dtn::core::BundleCore::local.sameHost(host_c)) continue; predictmap::iterator dp_it; if ((dp_it = _predictmap.find(host_c)) != _predictmap.end()) { dp_it->second = std::max(dp_it->second, p_ab * p_bc * _beta); } else { _predictmap[host_c] = p_ab * p_bc * _beta; } } }
void PayloadIntegrityBlock::sign(dtn::data::Bundle &bundle, const SecurityKey &key, const dtn::data::EID& destination) { PayloadIntegrityBlock& pib = bundle.push_front<PayloadIntegrityBlock>(); pib.set(REPLICATE_IN_EVERY_FRAGMENT, true); // check if this is a fragment if (bundle.get(dtn::data::PrimaryBlock::FRAGMENT)) { dtn::data::PayloadBlock& plb = bundle.find<dtn::data::PayloadBlock>(); ibrcommon::BLOB::Reference blobref = plb.getBLOB(); ibrcommon::BLOB::iostream stream = blobref.iostream(); addFragmentRange(pib._ciphersuite_params, bundle.fragmentoffset, stream.size()); } // set the source and destination address of the new block if (!key.reference.sameHost(bundle.source)) pib.setSecuritySource( key.reference ); if (!destination.sameHost(bundle.destination)) pib.setSecurityDestination( destination ); pib.setResultSize(key); pib.setCiphersuiteId(SecurityBlock::PIB_RSA_SHA256); pib._ciphersuite_flags |= CONTAINS_SECURITY_RESULT; std::string sign = calcHash(bundle, key, pib); pib._security_result.set(SecurityBlock::integrity_signature, sign); }