Commit acd41ad0 authored by caminha's avatar caminha
Browse files

clean up

parent c2baa9c2
......@@ -171,7 +171,6 @@ main(int argc, char *argv[])
Simulator::Stop(tSimulationTime);
Simulator::Run();
NS_LOG_UNCOND("RETURN");
return 0;
}
......
......@@ -224,10 +224,11 @@ namespace ns3
if (poolName.empty ())
return; //Pool not found, maybe routing error
if (isThisAlreadyBeingAnswered (interest) != completelyNew)
auto isAlreadyAnswered = isThisAlreadyBeingAnswered (interest);
if (isAlreadyAnswered != completelyNew && isAlreadyAnswered != sameNameAtIncompatibleIntervals)
{
//Submissions to the same flow only need the PIT entries
NS_LOG_INFO("Interest already being answered");
NS_LOG_INFO("Existing consumer streams equal or compatible with new stream");
consumerStreamsReused++;
return;
}
......@@ -270,28 +271,44 @@ namespace ns3
InterSystemIntermediator::isThisAlreadyBeingAnswered (shared_ptr<const Interest> interest) const
{
StreamSimilaritiesReturn ret = completelyNew;
NS_LOG_DEBUG("existingConsumerStreams count: " << existingConsumerStreams.size());
NS_LOG_DEBUG("Interest name: " << interest->getName());
NS_LOG_DEBUG("Interest subinterval: " << interest->getSubscriptionInterval().count() << "ms");
for (const auto &record : existingConsumerStreams)
{
NS_LOG_DEBUG("Record name: " << record->name);
if (record->name == interest->getName ())
{
NS_LOG_DEBUG("Record subinterval: " << record->subInterval.GetMilliSeconds() << "ms");
if (record->subInterval.GetMilliSeconds () == interest->getSubscriptionInterval ().count ())
ret = sameNameAtSameInterval;
{
NS_LOG_DEBUG("sameNameAtSameInterval");
ret = sameNameAtSameInterval;
}
const int64_t existingOne = record->subInterval.GetMilliSeconds ();
const int64_t newOne = interest->getSubscriptionInterval ().count ();
if (newOne > existingOne && newOne % existingOne == 0)
ret = sameNameAtDifferentInterval;
{
NS_LOG_DEBUG("sameNameAtCompatibleIntervals");
ret = sameNameAtCompatibleIntervals;
}
else
{
NS_LOG_DEBUG("sameNameAtIncompatibleIntervals");
ret = sameNameAtIncompatibleIntervals;
}
if (ret != completelyNew)
if (ret != completelyNew && ret != sameNameAtIncompatibleIntervals)
{
Time interestTimeout = Simulator::Now () + MilliSeconds (interest->getInterestLifetime ().count ());
if (interestTimeout > record->subTimeout)
record->subTimeout = interestTimeout; //FIXME Needs to send new interests to producers
record->subTimeout = interestTimeout; //FIXME Needs to send new interests to producers of different interest lifetime
return ret;
}
}
}
return completelyNew;
return ret;
}
bool
......@@ -368,38 +385,38 @@ namespace ns3
NS_LOG_DEBUG("Desired subinterval: " << newConsumerStream->subInterval.GetMilliSeconds() << "ms");
NS_LOG_DEBUG("Searching in " << existingProducerStreams[dataSource].size() << " existing producer streams to that source");
const nas::TransformationChain &consTransf = newConsumerStream->params.getTransformations ();
const nas::ParamValuesOfChain &consParams = newConsumerStream->params.getTransformationsParams();
NS_LOG_DEBUG("Desired consumer Transformations: " << boost::join(consTransf, " "));
// const nas::TransformationChain &consTransf = newConsumerStream->params.getTransformations ();
// const nas::ParamValuesOfChain &consParams = newConsumerStream->params.getTransformationsParams();
// NS_LOG_DEBUG("Desired consumer Transformations: " << boost::join(consTransf, " "));
for (shared_ptr<SubscriptionRecord> producerSubscription : existingProducerStreams[dataSource])
{
const nas::TransformationChain &prodTransf = producerSubscription->params.getTransformations ();
const nas::ParamValuesOfChain &prodParams = producerSubscription->params.getTransformationsParams();
NS_LOG_DEBUG("Producer Transformations: " << boost::join(prodTransf, " "));
const auto firstDifferent = std::mismatch (consTransf.begin (), consTransf.end (),
prodTransf.begin (), prodTransf.end ());
const bool haveSameParams = std::all_of(consTransf.begin(), firstDifferent.first,
[&] (const auto& transformation)
{
const auto& prodTparams = prodParams.at(transformation);
const auto& consTparams = consParams.at(transformation);
return std::equal(prodTparams.begin(), prodTparams.end(), consTparams.begin());
});
if (prodTransf.empty() || (haveSameParams && firstDifferent.second == consTransf.end() && firstDifferent.first != consTransf.begin ()))
{
NS_LOG_DEBUG("This producer stream is a sub-sequence of the desired sequence");
const int64_t newSubInterval = newConsumerStream->subInterval.GetMilliSeconds(),
oldSubInterval = producerSubscription->subInterval.GetMilliSeconds();
NS_LOG_DEBUG("Producer subinterval: " << oldSubInterval << "ms");
if ((subscriptionVerification == EqualIntervalEquivalence && newSubInterval == oldSubInterval) ||
(subscriptionVerification == MultipleIntervalEquivalence && (newSubInterval % oldSubInterval == 0)))
return producerSubscription;
}
// const nas::TransformationChain &prodTransf = producerSubscription->params.getTransformations ();
// const nas::ParamValuesOfChain &prodParams = producerSubscription->params.getTransformationsParams();
// NS_LOG_DEBUG("Producer Transformations: " << boost::join(prodTransf, " "));
//
// const auto firstDifferent = std::mismatch (consTransf.begin (), consTransf.end (),
// prodTransf.begin (), prodTransf.end ());
//
// const bool haveSameParams = std::all_of(consTransf.begin(), firstDifferent.first,
// [&] (const auto& transformation)
// {
// const auto& prodTparams = prodParams.at(transformation);
// const auto& consTparams = consParams.at(transformation);
// return std::equal(prodTparams.begin(), prodTparams.end(), consTparams.begin());
// });
//
// if (prodTransf.empty() || (haveSameParams && firstDifferent.second == consTransf.end() && firstDifferent.first != consTransf.begin ()))
// {
// NS_LOG_DEBUG("This producer stream is a sub-sequence of the desired sequence");
const int64_t newSubInterval = newConsumerStream->subInterval.GetMilliSeconds(),
oldSubInterval = producerSubscription->subInterval.GetMilliSeconds();
NS_LOG_DEBUG("Producer subinterval: " << oldSubInterval << "ms");
if ((subscriptionVerification == EqualIntervalEquivalence && newSubInterval == oldSubInterval) ||
(subscriptionVerification == MultipleIntervalEquivalence && (newSubInterval % oldSubInterval == 0)))
return producerSubscription;
// }
}
return nullptr;
}
......@@ -414,7 +431,6 @@ namespace ns3
interest->setSubscription (subInterval);
interest->setInterestLifetime (lifetime);
NS_LOG_DEBUG(interest->getName ());
return interest;
}
......
......@@ -170,7 +170,7 @@ namespace ns3
Name m_prefix;
Ptr<UniformRandomVariable> m_rand;
enum StreamSimilaritiesReturn { completelyNew, sameNameAtSameInterval, sameNameAtDifferentInterval };
enum StreamSimilaritiesReturn { completelyNew, sameNameAtSameInterval, sameNameAtCompatibleIntervals, sameNameAtIncompatibleIntervals };
StreamSimilaritiesReturn
isThisAlreadyBeingAnswered(shared_ptr<const Interest> interest) const;
......
......@@ -27,6 +27,7 @@
#include "ns3/uinteger.h"
#include "ns3/integer.h"
#include "ns3/double.h"
#include "ns3/names.h"
#include <string>
#include <algorithm>
......@@ -192,10 +193,16 @@ SingleSubscriptionConsumer::StopApplication()
if (hasReceivedFirstdata)
{
const Time operationTime = Simulator::Now() - startTime;
// NS_LOG_UNCOND("Operation Time: " << operationTime.GetMinutes());
const uint validSubCount = subscriptionCount - toBeReceived.size();
this->validSubCountPerc = (100.0 * validSubCount)/subscriptionCount;
const unsigned long expectedreceivedDatas = validSubCount * (operationTime / m_subscriptionInterval);// - acceptableLoss;
interestSatisfactionRatio = 100.0 * receivedDatas / expectedreceivedDatas;
const unsigned long expectedReceivedDatas = validSubCount * std::floor(operationTime / m_subscriptionInterval);// - acceptableLoss;
interestSatisfactionRatio = 100.0 * receivedDatas / expectedReceivedDatas;
// NS_LOG_UNCOND("interestSatisfactionRatio: "<< interestSatisfactionRatio << " | diff: " << std::abs(((long)receivedDatas) - ((long)expectedreceivedDatas))); // @suppress("Ambiguous problem")
//interestSatisfactionRatio = std::min(interestSatisfactionRatio.Get(), 100.0);
avgDataDelay /= receivedDatas;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment