Commit 9ad6cd8e authored by caminha's avatar caminha
Browse files

fix long times due to pit entries expirations

parent 2e881141
......@@ -45,7 +45,8 @@ namespace ndn
ConsumerArranger::setupPrivateDomains(const NodeContainer &consumers, const NodeContainer &activatedNodes)
{
AppHelper consumerHelper("ns3::ndn::SingleSubscriptionConsumer");
consumerHelper.SetAttribute("LifeTime", TimeValue(consumerStopTime-MilliSeconds(500)));
// consumerHelper.SetAttribute("LifeTime", TimeValue(consumerStopTime-MilliSeconds(500)));
consumerHelper.SetAttribute("LifeTime", TimeValue(Days(10)));
auto rng = CreateObject<UniformRandomVariable>();
setupRandomTransformationsAndParameters();
......@@ -79,7 +80,8 @@ namespace ndn
ConsumerArranger::setupDirectSubscriptions(const NodeContainer &consumers, const NodeContainer &producers)
{
AppHelper consumerHelper("ns3::ndn::SubscriptionConsumer");
consumerHelper.SetAttribute("LifeTime", TimeValue(consumerStopTime-MilliSeconds(500)));
// consumerHelper.SetAttribute("LifeTime", TimeValue(consumerStopTime - MilliSeconds(500)));
consumerHelper.SetAttribute("LifeTime", TimeValue(Days(10)));
auto rng = CreateObject<UniformRandomVariable>();
// setupRandomTransformationsAndParameters();
......
......@@ -129,7 +129,7 @@ main(int argc, char *argv[])
NS_LOG_DEBUG("Creating logical topology...");
shared_ptr<LogicalTopology> logicalTopology = logicalcreator->createLogicalTopology(physicalTopology->domainRouters);
NS_LOG_DEBUG("Creating producers topology...");
NS_LOG_DEBUG("Creating producers...");
physicalcreator->createProducers(physicalTopology, logicalTopology->leaves);
......@@ -168,13 +168,13 @@ main(int argc, char *argv[])
NS_LOG_DEBUG("Setting up traces...");
Time TraceConfigTime = Seconds(0.3);
Simulator::Schedule(TraceConfigTime, MakeEvent([& ]() {
std::map<uint32_t, std::map<uint32_t, uint32_t>> map_of_distances = ndn::GlobalRoutingHelper::CalculateRoutes();
TracesArranger::writeStreamDistancesFile(map_of_distances, appScenario, physicalTopology->consumers, logicalTopology);
Time TraceConfigTime = MilliSeconds(299);
std::map<uint32_t, std::map<uint32_t, uint32_t>> map_of_distances;
Simulator::Schedule(TraceConfigTime, MakeEvent([&]() mutable {
map_of_distances = ndn::GlobalRoutingHelper::CalculateRoutes();
}));
TracesArranger::setup(physicalTopology, TraceConfigTime, tSimulationTime);
TracesArranger::setup(physicalTopology, logicalTopology, TraceConfigTime, tSimulationTime, appScenario, map_of_distances);
Simulator::Stop(tSimulationTime);
......
......@@ -105,9 +105,12 @@ namespace ndn
}
void
TracesArranger::setup(shared_ptr<PhysicalTopology> physicalTopology,
Time TraceConfigTime, Time tSimulationTime)
TracesArranger::setup(shared_ptr<PhysicalTopology> physicalTopology, shared_ptr<LogicalTopology> logicalTopology,
Time TraceConfigTime, Time tSimulationTime, string appScenario,
std::map<uint32_t, std::map<uint32_t, uint32_t>>& map_of_distances)
{
// NS_LOG_UNCOND("TracesArranger::setup");
Simulator::Schedule(TraceConfigTime, &TracesArranger::printProgress, tSimulationTime, tSimulationTime/100.0);
// Simulator::Schedule(TraceConfigTime, &TracesArranger::printProgress, tSimulationTime, MilliSeconds(50));
......@@ -117,10 +120,17 @@ namespace ndn
Simulator::Schedule(TraceConfigTime, &ndn::CsTracer::InstallAll, "cs-trace.trace", reportTime);
}));
Time PrintStreamHitTime = tSimulationTime-MilliSeconds(1);
Simulator::Schedule(PrintStreamHitTime, &TracesArranger::writeStreamHitTrace, physicalTopology);
Simulator::Schedule(PrintStreamHitTime, &TracesArranger::writeConsumerMetricsFiles, physicalTopology);
Simulator::Schedule(PrintStreamHitTime, &TracesArranger::writeDataSpreadFile);
Simulator::Schedule(tSimulationTime - Seconds(3), MakeEvent([&]() {
// NS_LOG_UNCOND("TracesArranger::setup beginning of final simulation traces");
TracesArranger::writeStreamHitTrace(physicalTopology);
TracesArranger::writeConsumerMetricsFiles(physicalTopology);
TracesArranger::writeDataSpreadFile();
TracesArranger::writeStreamDistancesFile(map_of_distances, appScenario,
physicalTopology->consumers, logicalTopology);
// NS_LOG_UNCOND("TracesArranger::setup ending of final simulation traces");
}));
// NS_LOG_UNCOND("TracesArranger::setup end");
}
void
......@@ -149,10 +159,13 @@ namespace ndn
}
else
{
// NS_LOG_UNCOND("writeStreamDistancesFile Direct subscriptions");
Ptr<SubscriptionConsumer> app = DynamicCast<SubscriptionConsumer>((*consumer)->GetApplication(0));
// NS_LOG_UNCOND("Consumer " << (*consumer)->GetId() << " pickedPrefixes: " <<app->getPickedPrefixes().size());
for (auto pickedPrefix : app->getPickedPrefixes())
{
Name producerName = prefixes[pickedPrefix];
// NS_LOG_UNCOND(producerName);
uint32_t producerId = getNodeIdFromName(producerName);
uint32_t current_distance = maps_of_distances.at(cid).at(producerId);
streamsDistancesFile << consumer_name << '\t' << pickedPrefix << '\t' << current_distance << std::endl;
......@@ -166,9 +179,11 @@ namespace ndn
void
TracesArranger::writeDataSpreadFile ()
{
// NS_LOG_UNCOND("writeDataSpreadFile");
std::map<Name::Component, uint> spreadCounts;
for (auto node = NodeList::Begin(); node != NodeList::End(); node++)
{
// NS_LOG_UNCOND("Checking node " << Names::FindName(*node));
Ptr<L3Protocol> l3Protocol = (*node)->GetObject<L3Protocol>();
if (l3Protocol != nullptr)
{
......@@ -180,10 +195,12 @@ namespace ndn
{
if (!nfd::scope_prefix::LOCALHOST.isPrefixOf(csEntry->GetName()))
{
// NS_LOG_UNCOND("Checking entry " << csEntry->GetName());
auto component = csEntry->GetName().at(0);
if (nodesCountedComponents.find(component) != nodesCountedComponents.end())
continue;
// NS_LOG_UNCOND("Couting component " << component);
if(spreadCounts.find(component) != spreadCounts.end())
spreadCounts[component] += 1;
else
......@@ -195,6 +212,7 @@ namespace ndn
}
}
// NS_LOG_UNCOND("Actually writing file");
ofstream dataSpreadFile;
dataSpreadFile.open("data-spread.trace", ios::trunc);
BOOST_ASSERT_MSG(dataSpreadFile.is_open(), "Failed to open output file!!!");
......@@ -204,6 +222,7 @@ namespace ndn
dataSpreadFile << spreadCount.first << "\t" << spreadCount.second << std::endl;
dataSpreadFile.close();
// NS_LOG_UNCOND("writeDataSpreadFile End");
}
uint32_t
......
......@@ -32,8 +32,9 @@ namespace ndn
~TracesArranger () {};
static void
setup(shared_ptr<PhysicalTopology> physical_topology,
Time TraceConfigTime, Time tSimulationTime);
setup(shared_ptr<PhysicalTopology> physicalTopology, shared_ptr<LogicalTopology> logicalTopology,
Time TraceConfigTime, Time tSimulationTime, string appScenario,
std::map<uint32_t, std::map<uint32_t, uint32_t>>& map_of_distances);
static void
writeStreamDistancesFile (const std::map<uint32_t, std::map<uint32_t, uint32_t>>& maps_of_distances, const string& appScenario,
......
......@@ -163,6 +163,8 @@ SubscriptionConsumer::SendPacket()
avgDataDelay[*nameWithTransformation] = 0;
localPrefixNames[*nameWithTransformation] = 0;
}
BOOST_ASSERT(pickedPrefixes.size() == subscriptionCount);
// NS_LOG_UNCOND("Consumer " << GetNode()->GetId() << " pickedPrefixes: " << pickedPrefixes.size());
interestTransmission = time::steady_clock::now();
}
......
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