Question: How to create a new RapidNet NDlog application with provenance capability?
Answer: RapidNet allows you to write NDlog applications with provenance support with little extra effort. Essentially, the exact same NDlog application needs to be compiled with the --provenance (or -p) flag when compiling using the rapidnet compiler: rapidnet/compiler/compile. This translates the input NDlog rules into provenance enabled rules (in NDlog itself) and then compiles them into C++. Note that currently provenance cannot be enabled for SeNDlog applications.
Let us try to clone the mincost-prov application to see the process of creating a new provenance enabled application.
materialize(link,infinity,infinity,keys(1,2)). materialize(path,infinity,infinity,keys(1,2,3:int32)). materialize(bestPath,infinity,infinity,keys(1,2)). r1 path(@X,Y,C) :- link(@X,Y,C). r2 path(@Z,Y,C) :- link(@X,Z,C1), bestPath(@X,Y,C2), C:=C1+C2, Z!=Y. r3 bestPath(@X,Y,a_MIN<C>) :- path(@X,Y,C).
#include "ns3/core-module.h" #include "ns3/simulator-module.h" #include "ns3/node-module.h" #include "ns3/rapidnet-module.h" #include "ns3/values-module.h" #include "ns3/helper-module.h" #include "ns3/myproto-module.h" #include <time.h> #define link(src, next, cost) \ tuple (Myproto::LINK, \ attr ("link_attr1", Ipv4Value, src), \ attr ("link_attr2", Ipv4Value, next), \ attr ("link_attr3", Int32Value, cost)) #define insertlink(from, to, cost) \ app(from)->Insert (link (addr (from), addr (to), cost)); \ app(to)->Insert (link (addr (to), addr (from), cost)); #define deletelink(from, to, cost) \ app(from)->Delete (link (addr (from), addr (to), cost)); \ app(to)->Delete (link (addr (to), addr (from), cost)); using namespace std; using namespace ns3; using namespace ns3::rapidnet; using namespace ns3::rapidnet::myproto; ApplicationContainer apps; void UpdateLinks1 () { insertlink (1, 2, 3); insertlink (2, 3, 2); insertlink (1, 3, 5); } void Print () { PrintRelation (apps, Myproto::BESTPATH); PrintRelation (apps, Myproto::PROV); PrintRelation (apps, Myproto::RULEEXEC); } int main (int argc, char *argv[]) { LogComponentEnable("Myproto", LOG_LEVEL_INFO); LogComponentEnable("RapidNetApplicationBase", LOG_LEVEL_INFO); apps = InitRapidNetApps (3, Create<MyprotoHelper> ()); SetMaxJitter (apps, 0.001); apps.Start (Seconds (0.0)); apps.Stop (Seconds (5.0)); schedule (2.0, UpdateLinks1); schedule (5.0, Print); Simulator::Run (); Simulator::Destroy (); return 0; }
obj = bld.create_ns3_program('myproto-test') obj.source = 'myproto-test.cc'