Hi,
I am new to NS3. I want to implement a custom controller by inheriting NS3 provided ns3::ofi::Controller.
I tried to make a new class called MyController in a directory inside scratch directory ("scratch/testdir/mycontroller.h" & "scratch/testdir/mycontroller.cc"), then I put some lines of code like this:
#ifndef MYCONTROLLER_H
#define MYCONTROLLER_H
#include "ns3/core-module.h"
#include "ns3/openflow-module.h"
class MyController : public ns3::ofi::Controller
{
public:
MyController();
void testMethod();
static TypeId GetTypeId (void);
void ReceiveFromSwitch (Ptr<OpenFlowSwitchNetDevice> swtch, ofpbuf* buffer);
};
#endif // MYCONTROLLER_H
When I tried to run using QtCreator, it gives me error: "TypeId has not been declared" and "Ptr has not been detected".
I'm not sure, but it seems that they are basic error messages related with data types. Yet, I don't have any idea about how to correct them.
I have tried to copy, paste, rename and run the openflow-switch.cc example in the same directory and it doesn't give any error messages about Ptr, though there are many times Ptr is used there. I guess it is because openflow-switch.cc is not a class, but I have read in this group that it is okay to put class in scratch subdirectory as long as we have only 1 main file. So in my case, why Ptr has not been declared? I really don't understand.. :(
Could anybody please explain me how to inherit ns3::ofi::Controller correctly?