Skip to content

Commit

Permalink
Fix several error
Browse files Browse the repository at this point in the history
  • Loading branch information
aarizaq authored and rhornig committed Jun 15, 2022
1 parent b7eb88b commit d27306a
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 87 deletions.
15 changes: 15 additions & 0 deletions scenarios/testcases/.qtenvrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[General]
last-configname=General
last-runnumber=0

[RunModeProfiles]
fast-max-animation-speed=nan
fast-max-playback-speed=1e+06
fast-min-animation-speed=nan
fast-min-playback-speed=1
fast-playback-speed=1000
run-max-animation-speed=nan
run-max-playback-speed=100
run-min-animation-speed=nan
run-min-playback-speed=0.01
run-playback-speed=1
31 changes: 20 additions & 11 deletions src/openflow/controllerApps/AbstractControllerApp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
#include "inet/networklayer/common/L3AddressResolver.h"
#include "inet/common/ModuleAccess.h"


simsignal_t AbstractControllerApp::PacketInSignalId = registerSignal("PacketIn");
simsignal_t AbstractControllerApp::PacketOutSignalId = registerSignal("PacketOut");
simsignal_t AbstractControllerApp::PacketFeatureRequestSignalId = registerSignal("PacketFeatureRequest");
simsignal_t AbstractControllerApp::PacketFeatureReplySignalId = registerSignal("PacketFeatureReply");
simsignal_t AbstractControllerApp::BootedSignalId = registerSignal("Booted");

Define_Module(AbstractControllerApp);

AbstractControllerApp::AbstractControllerApp()
Expand Down Expand Up @@ -46,21 +53,11 @@ void AbstractControllerApp::initialize(int stage){
//register signals
OperationalBase::initialize(stage);
if (stage == INITSTAGE_LOCAL) {
PacketInSignalId =registerSignal("PacketIn");
PacketOutSignalId =registerSignal("PacketOut");
PacketFeatureRequestSignalId = registerSignal("PacketFeatureRequest");
PacketFeatureReplySignalId = registerSignal("PacketFeatureReply");
BootedSignalId= registerSignal("Booted");
getParentModule()->subscribe("PacketIn",this);
getParentModule()->subscribe("PacketOut",this);
getParentModule()->subscribe("PacketFeatureRequest",this);
getParentModule()->subscribe("PacketFeatureReply",this);
getParentModule()->subscribe("Booted",this);
packetsFlooded=0;
packetsDropped=0;
numPacketOut=0;
numFlowMod=0;
controller= NULL;
}
else if (stage == INITSTAGE_APPLICATION_LAYER) {
auto myNode = getContainingNode(this);
Expand All @@ -87,11 +84,13 @@ void AbstractControllerApp::receiveSignal(cComponent *src, simsignal_t id, cObje
this->controller = cntrl;
controller->registerApp(this);
}

}
}

void AbstractControllerApp::floodPacket(Packet *packet_in_msg){

if (controller == nullptr)
throw cRuntimeError("Controller module is not initialized");
auto header_in = packet_in_msg->peekAtFront<OFP_Packet_In>();
EV << "floodPacket" << '\n';
packetsFlooded++;
Expand All @@ -101,6 +100,10 @@ void AbstractControllerApp::floodPacket(Packet *packet_in_msg){
}

void AbstractControllerApp::dropPacket(Packet *packet_in_msg){

if (controller == nullptr)
throw cRuntimeError("Controller module is not initialized");

auto header_in = packet_in_msg->peekAtFront<OFP_Packet_In>();
EV << "dropPacket" << '\n';
packetsDropped++;
Expand All @@ -113,6 +116,9 @@ void AbstractControllerApp::dropPacket(Packet *packet_in_msg){

void AbstractControllerApp::sendPacket(Packet *packet_in_msg, uint32_t outport){

if (controller == nullptr)
throw cRuntimeError("Controller module is not initialized");

auto header_in = packet_in_msg->peekAtFront<OFP_Packet_In>();

EV << "sendPacket" << '\n';
Expand All @@ -124,6 +130,9 @@ void AbstractControllerApp::sendPacket(Packet *packet_in_msg, uint32_t outport){
}

void AbstractControllerApp::sendFlowModMessage(ofp_flow_mod_command mod_com, const oxm_basic_match &match, uint32_t outport, TcpSocket * socket, int idleTimeOut =1 , int hardTimeOut=0){
if (controller == nullptr)
throw cRuntimeError("Controller module is not initialized");

EV << "sendFlowModMessage" << '\n';
numFlowMod++;
auto msgAux = createFlowMod(mod_com,match,outport,idleTimeOut,hardTimeOut);
Expand Down
24 changes: 12 additions & 12 deletions src/openflow/controllerApps/AbstractControllerApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ class AbstractControllerApp: public OperationalBase, public cListener {
virtual int getIndexFromId(int id);


simsignal_t PacketInSignalId;
simsignal_t PacketOutSignalId;
simsignal_t PacketFeatureRequestSignalId;
simsignal_t PacketFeatureReplySignalId;
simsignal_t BootedSignalId;

long packetsFlooded;
long packetsDropped;
long numPacketOut;
long numFlowMod;

OF_Controller * controller;
static simsignal_t PacketInSignalId;
static simsignal_t PacketOutSignalId;
static simsignal_t PacketFeatureRequestSignalId;
static simsignal_t PacketFeatureReplySignalId;
static simsignal_t BootedSignalId;

long packetsFlooded = 0;
long packetsDropped = 0;
long numPacketOut = 0;
long numFlowMod = 0;

OF_Controller * controller = nullptr;

virtual int numInitStages() const override { return NUM_INIT_STAGES; }
virtual void initialize(int stage) override;
Expand Down
36 changes: 23 additions & 13 deletions src/openflow/hyperflow/HF_ARPResponder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#define MSGKIND_ARPRESPONDERBOOTED 801

simsignal_t HF_ARPResponder::HyperFlowReFireSignalId = registerSignal("HyperFlowReFire");

Define_Module(HF_ARPResponder);

HF_ARPResponder::HF_ARPResponder(){
Expand All @@ -21,9 +23,7 @@ void HF_ARPResponder::initialize(int stage){

ARPResponder::initialize(stage);
if (stage == INITSTAGE_LOCAL) {
hfAgent = NULL;
//register signals
HyperFlowReFireSignalId =registerSignal("HyperFlowReFire");
getParentModule()->subscribe("HyperFlowReFire",this);
}
}
Expand All @@ -34,6 +34,9 @@ void HF_ARPResponder::handlePacketIn(Packet * pkt){

CommonHeaderFields headerFields = extractCommonHeaderFields(pkt);

if (controller == nullptr)
throw cRuntimeError("Controller module is not initialized");

//check if it is an arp packet
if(headerFields.eth_type == ETHERTYPE_ARP){

Expand All @@ -50,10 +53,11 @@ void HF_ARPResponder::handlePacketIn(Packet * pkt){
entry.srcController = controller->getFullPath();
entry.payload = wrapperArp;

if (hfAgent == nullptr)
throw cRuntimeError("HyperFlowAgent not synchronized, check if the agent is present in the network");
hfAgent->synchronizeDataChannelEntry(entry);
}


//check arp type
if(headerFields.arp_op == ARP_REQUEST){

Expand Down Expand Up @@ -146,28 +150,34 @@ void HF_ARPResponder::handlePacketIn(Packet * pkt){
floodPacket(pkt);
}
}


}

}


void HF_ARPResponder::receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details) {
//set hfagent link
ARPResponder::receiveSignal(src,id,obj,details);
Enter_Method("HF_ARPResponder::receiveSignal %s", cComponent::getSignalName(id));
if(hfAgent == NULL && controller != NULL){
bool HF_ARPResponder::searchHyperFlowAggent()
{
if (hfAgent)
return true;
if(hfAgent == nullptr && controller != nullptr){
auto appList = controller->getAppList();

for(auto iterApp=appList->begin();iterApp!=appList->end();++iterApp){
if(dynamic_cast<HyperFlowAgent *>(*iterApp) != NULL) {
HyperFlowAgent *hf = (HyperFlowAgent *) *iterApp;
hfAgent = hf;
return true;
break;
}
}
}
return false;
}


void HF_ARPResponder::receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details) {
//set hfagent link
ARPResponder::receiveSignal(src,id,obj,details);
Enter_Method("HF_ARPResponder::receiveSignal %s", cComponent::getSignalName(id));
if (!searchHyperFlowAggent())
throw cRuntimeError("HyperFlowAgent not synchronized, check if the agent is present in the network");

//check for hf messages to refire
if(id == HyperFlowReFireSignalId){
Expand Down
5 changes: 3 additions & 2 deletions src/openflow/hyperflow/HF_ARPResponder.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ class HF_ARPResponder: public ARPResponder {


protected:
virtual bool searchHyperFlowAggent();
virtual void receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details) override;
virtual void initialize(int stage) override;
//void handlePacketIn(OFP_Packet_In * packet_in_msg);
virtual void handlePacketIn(Packet*) override;

HyperFlowAgent * hfAgent;
simsignal_t HyperFlowReFireSignalId;
HyperFlowAgent * hfAgent = nullptr;
static simsignal_t HyperFlowReFireSignalId;
};


Expand Down
32 changes: 23 additions & 9 deletions src/openflow/hyperflow/HF_LLDPAgent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#define MSGKIND_TRIGGERLLDP 101
#define MSGKIND_LLDPAGENTBOOTED 201

simsignal_t HF_LLDPAgent::HyperFlowReFireSignalId = registerSignal("HyperFlowReFire");

Define_Module(HF_LLDPAgent);

HF_LLDPAgent::HF_LLDPAgent(){
Expand All @@ -19,9 +21,7 @@ HF_LLDPAgent::~HF_LLDPAgent(){
void HF_LLDPAgent::initialize(int stage){
LLDPAgent::initialize(stage);
if (stage == INITSTAGE_LOCAL) {
hfAgent = NULL;
//register signals
HyperFlowReFireSignalId =registerSignal("HyperFlowReFire");
getParentModule()->subscribe("HyperFlowReFire",this);
}
}
Expand Down Expand Up @@ -64,6 +64,9 @@ void HF_LLDPAgent::handlePacketIn(Packet *pktIn){
entry.srcController = controller->getFullPath();
entry.payload = wrapper;

if (hfAgent == nullptr)
throw cRuntimeError("HyperFlowAgent not synchronized");

hfAgent->synchronizeDataChannelEntry(entry);
pktIn->insertAtFront(frame);
pktIn->insertAtFront(packet_in_msg);
Expand Down Expand Up @@ -93,7 +96,9 @@ void HF_LLDPAgent::handlePacketIn(Packet *pktIn){
entry.trgSwitch = "";
entry.srcController = controller->getFullPath();
entry.payload = wrapper;

if (hfAgent == nullptr) {
throw cRuntimeError("HyperFlowAgent not synchronized, check if the agent is present in the network");
}
hfAgent->synchronizeDataChannelEntry(entry);
}
}
Expand All @@ -103,24 +108,33 @@ void HF_LLDPAgent::handlePacketIn(Packet *pktIn){

}

bool HF_LLDPAgent::searchHyperFlowAggent()
{
if (hfAgent)
return true;

void HF_LLDPAgent::receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details) {
//set hfagent link
LLDPAgent::receiveSignal(src,id,obj,details);
Enter_Method("HF_LLDPAgent::receiveSignal %s", cComponent::getSignalName(id));
if(hfAgent == NULL && controller != NULL){
if(hfAgent == nullptr && controller != nullptr){
auto appList = controller->getAppList();

for(auto iterApp=appList->begin();iterApp!=appList->end();++iterApp){
if(dynamic_cast<HyperFlowAgent *>(*iterApp) != NULL) {
HyperFlowAgent *hf = (HyperFlowAgent *) *iterApp;
hfAgent = hf;
return true;
break;
}
}
}
return false;
}


void HF_LLDPAgent::receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details) {
//set hfagent link
LLDPAgent::receiveSignal(src,id,obj,details);
Enter_Method("HF_LLDPAgent::receiveSignal %s", cComponent::getSignalName(id));

if (!searchHyperFlowAggent())
throw cRuntimeError("HyperFlowAgent not synchronized, check if the agent is present in the network");

//check for hf messages to refire
if(id == HyperFlowReFireSignalId){
Expand Down
5 changes: 3 additions & 2 deletions src/openflow/hyperflow/HF_LLDPAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ class HF_LLDPAgent:public LLDPAgent {
LLDPMibGraph * getMibGraph();

protected:
virtual bool searchHyperFlowAggent();
virtual void receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details) override;
virtual void initialize(int stage) override;
virtual void handlePacketIn(Packet *) override;
HyperFlowAgent * hfAgent;
simsignal_t HyperFlowReFireSignalId;
HyperFlowAgent * hfAgent = nullptr;
static simsignal_t HyperFlowReFireSignalId;
};


Expand Down
8 changes: 4 additions & 4 deletions src/openflow/hyperflow/HyperFlowAgent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#define MSGKIND_CHECKALIVEEVERY 703
#define MSGKIND_HFCONNECT 704

simsignal_t HyperFlowAgent::HyperFlowReFireSignalId = registerSignal("HyperFlowReFire");

Define_Module(HyperFlowAgent);

HyperFlowAgent::HyperFlowAgent(){
Expand Down Expand Up @@ -38,8 +40,6 @@ void HyperFlowAgent::initialize(int stage){
//socket.setDataTransferMode(TCP_TRANSFER_OBJECT);
//schedule connection setup

//register signals
HyperFlowReFireSignalId =registerSignal("HyperFlowReFire");
}
}

Expand Down Expand Up @@ -188,7 +188,7 @@ void HyperFlowAgent::handleSyncReply(HF_SyncReply * msg){
if(strcmp((*iterData).srcController.c_str(),controller->getFullPath().c_str())!=0){
HF_ReFire_Wrapper * rfWrapper = new HF_ReFire_Wrapper();
rfWrapper->setDataChannelEntry(*iterData);
emit(HyperFlowReFireSignalId,rfWrapper);
emit(HyperFlowReFireSignalId, rfWrapper);
delete rfWrapper;
}
}
Expand Down Expand Up @@ -216,9 +216,9 @@ void HyperFlowAgent::handleCheckAlive(){
}

void HyperFlowAgent::synchronizeDataChannelEntry(DataChannelEntry entry){
EV << "HyperFlowAgent::Sent Change" << endl;
Enter_Method_Silent();

EV_DEBUG << "HyperFlowAgent::Sent Change" << endl;
auto change = makeShared<HF_ChangeNotification>();
change->setChunkLength(B(sizeof(entry)));
change->setEntry(entry);
Expand Down
2 changes: 1 addition & 1 deletion src/openflow/hyperflow/HyperFlowAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class HyperFlowAgent:public AbstractTCPControllerApp {
std::list<std::string> knownControllers;
std::list<std::string> failedControllers;

simsignal_t HyperFlowReFireSignalId;
static simsignal_t HyperFlowReFireSignalId;

virtual void handleStartOperation(LifecycleOperation *operation) override;

Expand Down
1 change: 1 addition & 0 deletions src/openflow/openflow/protocol/openflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ struct ofp_port {
uint32_t curr_speed; /* Current port bitrate in kbps. */
uint32_t max_speed; /* Max port bitrate in kbps */
int interfaceId = -1;
cModule *mac = nullptr;
};

enum ofp_port_config {
Expand Down
Loading

0 comments on commit d27306a

Please sign in to comment.