Exemplo n.º 1
0
		void NodeHandshakeExtension::HandshakeEndpoint::query(const dtn::data::EID &origin)
		{
			{
				ibrcommon::MutexLock l(_blacklist_lock);
				// only query once each 60 seconds
				if (_blacklist[origin] > dtn::utils::Clock::getMonotonicTimestamp()) return;
				_blacklist[origin] = dtn::utils::Clock::getMonotonicTimestamp() + 60;
			}

			// create a new request for the summary vector of the neighbor
			NodeHandshake request(NodeHandshake::HANDSHAKE_REQUEST);

#ifdef IBRDTN_SUPPORT_COMPRESSION
			// request compressed answer
			request.addRequest(NodeHandshakeItem::REQUEST_COMPRESSED_ANSWER);
#endif

			// walk through all extensions to generate a request
			(*_callback).requestHandshake(origin, request);

			IBRCOMMON_LOGGER_DEBUG_TAG(NodeHandshakeExtension::TAG, 15) << "handshake query from " << origin.getString() << ": " << request.toString() << IBRCOMMON_LOGGER_ENDL;

			// create a new bundle with a zero timestamp (+age block)
			dtn::data::Bundle req(true);

			// set the source of the bundle
			req.source = getWorkerURI();

			// set the destination of the bundle
			req.set(dtn::data::PrimaryBlock::DESTINATION_IS_SINGLETON, true);
			req.destination = origin;

			// set destination application
			req.destination.setApplication("routing");

			// limit the lifetime to 60 seconds
			req.lifetime = 60;

			// set high priority
			req.set(dtn::data::PrimaryBlock::PRIORITY_BIT1, false);
			req.set(dtn::data::PrimaryBlock::PRIORITY_BIT2, true);

			dtn::data::PayloadBlock &p = req.push_back<PayloadBlock>();
			ibrcommon::BLOB::Reference ref = p.getBLOB();

			// serialize the request into the payload
			{
				ibrcommon::BLOB::iostream ios = ref.iostream();
				(*ios) << request;
			}

			// add a schl block
			dtn::data::ScopeControlHopLimitBlock &schl = req.push_front<dtn::data::ScopeControlHopLimitBlock>();
			schl.setLimit(1);

			// send the bundle
			transmit(req);
		}
Exemplo n.º 2
0
		void NodeHandshakeExtension::HandshakeEndpoint::query(const dtn::data::EID &origin)
		{
			{
				ibrcommon::MutexLock l(_blacklist_lock);
				// only query once each 60 seconds
				if (_blacklist[origin] > dtn::utils::Clock::getUnixTimestamp()) return;
				_blacklist[origin] = dtn::utils::Clock::getUnixTimestamp() + 60;
			}

			// create a new request for the summary vector of the neighbor
			NodeHandshake request(NodeHandshake::HANDSHAKE_REQUEST);

			// walk through all extensions to generate a request
			(*_callback).requestHandshake(origin, request);

			IBRCOMMON_LOGGER_DEBUG_TAG(NodeHandshakeExtension::TAG, 15) << "handshake query from " << origin.getString() << ": " << request.toString() << IBRCOMMON_LOGGER_ENDL;

			// create a new bundle
			dtn::data::Bundle req;

			// set the source of the bundle
			req.source = getWorkerURI();

			// set the destination of the bundle
			req.set(dtn::data::PrimaryBlock::DESTINATION_IS_SINGLETON, true);

			if (origin.isCompressable())
				req.destination = origin.add(origin.getDelimiter() + "50");
			else
				req.destination = origin.add(origin.getDelimiter() + "routing");

			// limit the lifetime to 60 seconds
			req.lifetime = 60;

			// set high priority
			req.set(dtn::data::PrimaryBlock::PRIORITY_BIT1, false);
			req.set(dtn::data::PrimaryBlock::PRIORITY_BIT2, true);

			dtn::data::PayloadBlock &p = req.push_back<PayloadBlock>();
			ibrcommon::BLOB::Reference ref = p.getBLOB();

			// serialize the request into the payload
			{
				ibrcommon::BLOB::iostream ios = ref.iostream();
				(*ios) << request;
			}

			// add a schl block
			dtn::data::ScopeControlHopLimitBlock &schl = req.push_front<dtn::data::ScopeControlHopLimitBlock>();
			schl.setLimit(1);

			// add an age block (to prevent expiring due to wrong clocks)
			req.push_front<dtn::data::AgeBlock>();

			// send the bundle
			transmit(req);
		}
Exemplo n.º 3
0
		void EchoWorker::callbackBundleReceived(const Bundle &b)
		{
			try {
				const PayloadBlock &payload = b.find<PayloadBlock>();

				// generate a echo
				Bundle echo;

				// make a copy of the payload block
				ibrcommon::BLOB::Reference ref = payload.getBLOB();
				echo.push_back(ref);

				// set destination and mark the bundle as singleton destination
				echo.destination = b.source;
				echo.set(dtn::data::PrimaryBlock::DESTINATION_IS_SINGLETON, true);

				// set the source of the bundle
				echo.source = getWorkerURI();

				// set the lifetime to the same value as the received bundle
				echo.lifetime = b.lifetime;

				// sign the reply if the echo-request was signed too
				if (b.get(dtn::data::PrimaryBlock::DTNSEC_STATUS_VERIFIED))
					echo.set(dtn::data::PrimaryBlock::DTNSEC_REQUEST_SIGN, true);

				// encrypt the reply if the echo-request was encrypt too
				if (b.get(dtn::data::PrimaryBlock::DTNSEC_STATUS_CONFIDENTIAL))
					echo.set(dtn::data::PrimaryBlock::DTNSEC_REQUEST_ENCRYPT, true);

				try {
					const dtn::data::TrackingBlock &tracking = b.find<dtn::data::TrackingBlock>();
					dtn::data::TrackingBlock &target = echo.push_back<dtn::data::TrackingBlock>();

					// copy tracking block
					target = tracking;
				} catch (const dtn::data::Bundle::NoSuchBlockFoundException&) { };

				IBRCOMMON_LOGGER_DEBUG_TAG("EchoWorker", 5) << "echo request received, replying!" << IBRCOMMON_LOGGER_ENDL;

				// send it
				transmit( echo );
			} catch (const dtn::data::Bundle::NoSuchBlockFoundException&) {

			}
		}
Exemplo n.º 4
0
		void NodeHandshakeExtension::HandshakeEndpoint::push(const NodeHandshakeItem::IDENTIFIER id)
		{
			// create a new notification
			NodeHandshake notification(NodeHandshake::HANDSHAKE_NOTIFICATION);
			notification.addRequest(id);

			IBRCOMMON_LOGGER_DEBUG_TAG(NodeHandshakeExtension::TAG, 15) << "handshake notification for type: " << id << IBRCOMMON_LOGGER_ENDL;

			// create a new bundle with a zero timestamp (+age block)
			dtn::data::Bundle req(true);

			// set the source of the bundle
			req.source = getWorkerURI();

			// set the destination of the bundle
			req.set(dtn::data::PrimaryBlock::DESTINATION_IS_SINGLETON, false);
			req.destination = BROADCAST_ENDPOINT;

			// limit the lifetime to 60 seconds
			req.lifetime = 60;

			// set high priority
			req.set(dtn::data::PrimaryBlock::PRIORITY_BIT1, false);
			req.set(dtn::data::PrimaryBlock::PRIORITY_BIT2, true);

			dtn::data::PayloadBlock &p = req.push_back<PayloadBlock>();
			ibrcommon::BLOB::Reference ref = p.getBLOB();

			// serialize the request into the payload
			{
				ibrcommon::BLOB::iostream ios = ref.iostream();
				(*ios) << notification;
			}

			// add a schl block
			dtn::data::ScopeControlHopLimitBlock &schl = req.push_front<dtn::data::ScopeControlHopLimitBlock>();
			schl.setLimit(1);

			// send the bundle
			transmit(req);
		}