Commit 304309e8 authored by caminha's avatar caminha
Browse files

avg as the single random domains transformation and new streams on traces

parent 4fb9dc94
......@@ -22,23 +22,22 @@ namespace ndn
// randomTransformationCount(0), randomTransformationParamCount(0)
// {}
ConsumerArranger::ConsumerArranger (Time consumerStopTime, uint subscriptionIntervalCount,
uint randomTransformationCount, uint randomTransformationParamCount):
consumerStopTime(consumerStopTime), subscriptionIntervalCount(subscriptionIntervalCount),
randomTransformationCount(randomTransformationCount), randomTransformationParamCount(randomTransformationParamCount)
ConsumerArranger::ConsumerArranger (Time consumerStopTime, uint subscriptionIntervalCount):
consumerStopTime(consumerStopTime), subscriptionIntervalCount(subscriptionIntervalCount)
{}
void
ConsumerArranger::setupRandomTransformationsAndParameters()
{
SingleSubscriptionConsumer::randomTransformations transformation_parameters_options;
for (uint i=0; i<randomTransformationCount; i++)
{
string transformation = "T" + to_string(i), param = "p";
transformation_parameters_options[transformation][param].resize(randomTransformationParamCount);
for (uint j=0; j<randomTransformationParamCount; j++)
transformation_parameters_options[transformation][param][j] = to_string(j);
}
transformation_parameters_options["avg"]["every"] = {"1000"};
// for (uint i=0; i<randomTransformationCount; i++)
// {
// string transformation = "T" + to_string(i), param = "p";
// transformation_parameters_options[transformation][param].resize(randomTransformationParamCount);
// for (uint j=0; j<randomTransformationParamCount; j++)
// transformation_parameters_options[transformation][param][j] = to_string(j);
// }
ndn::SingleSubscriptionConsumer::setRandomTransformations(transformation_parameters_options);
}
......@@ -53,7 +52,8 @@ namespace ndn
// Setting up applications
for (uint c=0; c<consumers.GetN(); c++)
{
Time subInterval = Minutes(std::pow(2, rng->GetInteger(0, subscriptionIntervalCount-1)));
uint rsic = rng->GetInteger(0, subscriptionIntervalCount-1);
Time subInterval = Minutes(std::pow(2, rsic));
consumerHelper.SetAttribute("SubscriptionInterval", TimeValue(subInterval));
Ptr<Node> iid = activatedNodes.Get(rng->GetInteger(0, activatedNodes.GetN()-1));
......@@ -61,7 +61,7 @@ namespace ndn
consumerHelper.SetAttribute("Prefix", StringValue(intermediateName));
Ptr<Application> app = consumerHelper.Install(consumers.Get(c)).Get(0);
Time starttime = MilliSeconds(rng->GetInteger(310, 350));
Time starttime = MilliSeconds(rng->GetInteger(300+20*rsic, 320+20*rsic-1));
app->SetStartTime(starttime);
app->SetStopTime(consumerStopTime);
......
......@@ -21,8 +21,7 @@ namespace ns3
{
public:
// ConsumerArranger();
ConsumerArranger (Time consumerStopTime, uint subscriptionIntervalCount,
uint randomTransformationCount, uint randomTransformationParamCount);
ConsumerArranger (Time consumerStopTime, uint subscriptionIntervalCount);
virtual
~ConsumerArranger () {};
......@@ -42,29 +41,29 @@ namespace ns3
this->consumerStopTime = consumerStopTime;
}
uint
getRandomTransformationCount () const
{
return randomTransformationCount;
}
void
setRandomTransformationCount (uint randomTransformationCount)
{
this->randomTransformationCount = randomTransformationCount;
}
uint
getRandomTransformationParamCount () const
{
return randomTransformationParamCount;
}
void
setRandomTransformationParamCount (uint randomTransformationParamCount)
{
this->randomTransformationParamCount = randomTransformationParamCount;
}
// uint
// getRandomTransformationCount () const
// {
// return randomTransformationCount;
// }
//
// void
// setRandomTransformationCount (uint randomTransformationCount)
// {
// this->randomTransformationCount = randomTransformationCount;
// }
//
// uint
// getRandomTransformationParamCount () const
// {
// return randomTransformationParamCount;
// }
//
// void
// setRandomTransformationParamCount (uint randomTransformationParamCount)
// {
// this->randomTransformationParamCount = randomTransformationParamCount;
// }
uint
getSubscriptionIntervalCount () const
......@@ -80,9 +79,9 @@ namespace ns3
protected:
Time consumerStopTime;
uint subscriptionIntervalCount,
randomTransformationCount,
randomTransformationParamCount;
uint subscriptionIntervalCount;
// randomTransformationCount,
// randomTransformationParamCount;
private:
void setupRandomTransformationsAndParameters();
......
......@@ -45,11 +45,11 @@ main(int argc, char *argv[])
uint nSystems = 20,
nExtraEdges = 10,
nConsumers = 40,
nMaxProducersPerSystem = 15,
nMaxProducersPerSystem = 20,
nMaxBranching = 5,
simulationTime = 120,
randomTransformationCount = 3,
randomTransformationParamCount = 3,
// randomTransformationCount = 3,
// randomTransformationParamCount = 3,
subscriptionIntervalCount = 4;
double percSystemActivation = 0.9;
std::string appScenario = "RandomTrees",
......@@ -64,8 +64,8 @@ main(int argc, char *argv[])
cmd.AddValue("nMaxBranching", "Max number of children per node in the logical topology", nMaxBranching);
cmd.AddValue("percSystemActivation", "Percentage of systems to be part of the logical topology (between 0 and 1)", percSystemActivation);
cmd.AddValue("simTime", "Time that the simulation will run (in minutes)", simulationTime);
cmd.AddValue("randomTransformationCount", "Number of transformation to consider", randomTransformationCount);
cmd.AddValue("randomTransformationParamCount", "Number of values for the transformations considered", randomTransformationParamCount);
// cmd.AddValue("randomTransformationCount", "Number of transformation to consider", randomTransformationCount);
// cmd.AddValue("randomTransformationParamCount", "Number of values for the transformations considered", randomTransformationParamCount);
cmd.AddValue("subscriptionIntervalCount", "Number of possible values used by consumers for subscription intervals, generated as 1s, 2s, 4s,...", subscriptionIntervalCount);
cmd.AddValue("appScenario", "Scenario of applications to be used (RandomTrees or DirectSubscriptions)", appScenario);
cmd.AddValue("subEquivalenceType", "Type of equivalence checking done by the mediators (none/equal/multiplier)", subEquivalence);
......@@ -97,8 +97,8 @@ main(int argc, char *argv[])
outputFile << "percSystemActivation\t" << percSystemActivation << std::endl;
outputFile << "tSimulationTime\t" << tSimulationTime << std::endl;
outputFile << "subscriptionIntervalCount\t" << subscriptionIntervalCount << std::endl;
outputFile << "randomTransformationParamCount\t" << randomTransformationParamCount << std::endl;
outputFile << "randomTransformationCount\t" << randomTransformationCount << std::endl;
// outputFile << "randomTransformationParamCount\t" << randomTransformationParamCount << std::endl;
// outputFile << "randomTransformationCount\t" << randomTransformationCount << std::endl;
outputFile << "subEquivalenceType\t" << subEquivalence << std::endl;
outputFile << "seed\t" << RngSeedManager::GetSeed() << std::endl;
outputFile.close();
......@@ -107,7 +107,7 @@ main(int argc, char *argv[])
// Topology creators and parameters //////////////////////////////////////////////////////////////////////
Ptr<UniformRandomVariable> producerRng =
CreateObjectWithAttributes<UniformRandomVariable>("Min", DoubleValue(1),
CreateObjectWithAttributes<UniformRandomVariable>("Min", DoubleValue(nMaxProducersPerSystem/2),
"Max", DoubleValue(nMaxProducersPerSystem));
Ptr<PhysicalTopologyCreator> physicalcreator =
CreateObjectWithAttributes<PhysicalTopologyCreator>(
......@@ -123,9 +123,13 @@ main(int argc, char *argv[])
"branchCountRNG", PointerValue(branchingRng));
NS_LOG_DEBUG("Creating physical topology...");
shared_ptr<PhysicalTopology> physicalTopology = physicalcreator->create_physical_topology();
NS_LOG_DEBUG("Creating logical topology...");
shared_ptr<LogicalTopology> logicalTopology = logicalcreator->createLogicalTopology(physicalTopology->domainRouters);
NS_LOG_DEBUG("Creating producers topology...");
physicalcreator->createProducers(physicalTopology, logicalTopology->leaves);
......@@ -142,9 +146,8 @@ main(int argc, char *argv[])
ConsumerArranger consumerArranger(consumerStopTime, subscriptionIntervalCount,
randomTransformationCount, randomTransformationParamCount);
NS_LOG_DEBUG("Setting up consumers...");
ConsumerArranger consumerArranger(consumerStopTime, subscriptionIntervalCount);
if (appScenario.compare("RandomTrees") == 0)
consumerArranger.setupPrivateDomains(physicalTopology->consumers, logicalTopology->activatedNodes);
else
......@@ -156,12 +159,15 @@ main(int argc, char *argv[])
GlobalRoutingHelper routingHelper;
routingHelper.InstallAll();
NS_LOG_DEBUG("Setting up streams...");
StreamArranger streamArranger(subEquivalence, producerStopTime, make_shared<GlobalRoutingHelper>(routingHelper));
if (appScenario.compare("RandomTrees") == 0)
streamArranger.setupRandomTrees(physicalTopology, logicalTopology, intermediatorStopTime);
else
streamArranger.setupDirectSubscriptions(physicalTopology);
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();
......@@ -171,8 +177,8 @@ main(int argc, char *argv[])
TracesArranger::setup(physicalTopology, TraceConfigTime, tSimulationTime);
Simulator::Stop(tSimulationTime);
NS_LOG_DEBUG("Starting...");
Simulator::Run();
Simulator::Destroy();
return 0;
......
......@@ -89,8 +89,10 @@ namespace ndn
std::string dataSourceName = "/system"+childNodeId+"/dataset";
nas::NasInterestTransformationAndParameters sourceParams;
sourceParams.addTransformation("PT" + childNodeId);
sourceParams.addTransformationParam("PT" + childNodeId, "p", "1");
sourceParams.addTransformation("avg");
sourceParams.addTransformationParam("avg", "every", "1000");
// sourceParams.addTransformation("PT" + childNodeId);
// sourceParams.addTransformationParam("PT" + childNodeId, "p", "1");
DynamicCast<ndn::InterDomainIntermediator>(app)->addDataSource("/dataset", dataSourceName, sourceParams);
}
......
......@@ -38,6 +38,7 @@ namespace ndn
Ptr<InterDomainIntermediator> mediatorApp = DynamicCast<InterDomainIntermediator>(intermediateNode->GetApplication(0));
outputFile << name << "\tOutStream\t" << mediatorApp->getProducerStreamReused() << std::endl;
outputFile << name << "\tInStream\t" << mediatorApp->getConsumerStreamReused() << std::endl;
outputFile << name << "\tNewStreams\t" << mediatorApp->getStreamsCreated() << std::endl;
outputFile << name << "\tBoth\t" << mediatorApp->getProducerStreamReused() + mediatorApp->getConsumerStreamReused() << std::endl;
}
}
......
......@@ -59,6 +59,10 @@ namespace ns3
.AddTraceSource ("ConsumerStreamsReused",
"Number of consumer streams detected as already existing or equivalent to existing ones",
MakeTraceSourceAccessor (&InterDomainIntermediator::consumerStreamsReused),
"ns3::TracedValueCallback::Int32")
.AddTraceSource ("StreamsCreated",
"Number of streams created in order to answer interests",
MakeTraceSourceAccessor (&InterDomainIntermediator::streamsCreated),
"ns3::TracedValueCallback::Int32");
return tid;
}
......@@ -235,6 +239,7 @@ namespace ns3
return;
}
streamsCreated++;
NS_LOG_INFO("New consumer stream");
shared_ptr<SubscriptionRecord> newConsumerStream = std::make_shared<SubscriptionRecord> ();
newConsumerStream->hasParams = nas::NasInterestTransformationAndParameters::hasParameters (*interest);
......
......@@ -89,6 +89,11 @@ namespace ns3
std::string
getSubEquivalenceChecking() const;
inline uint32_t
getStreamsCreated() const
{
return streamsCreated.Get();
}
// virtual void
// OnData(shared_ptr<const Data> data);
......@@ -222,7 +227,8 @@ namespace ns3
std::map<DataSource, std::list<shared_ptr<SubscriptionRecord>>> existingProducerStreams;
std::list<shared_ptr<SubscriptionRecord>> existingConsumerStreams;
TracedValue<int32_t> producerStreamsReused = 0,
consumerStreamsReused = 0;
consumerStreamsReused = 0,
streamsCreated = 0;
enum subEquivalence {
noEquivalence,
......
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