Skip to content

Commit d27306a

Browse files
aarizaqrhornig
authored andcommitted
Fix several error
1 parent b7eb88b commit d27306a

12 files changed

Lines changed: 156 additions & 87 deletions

File tree

scenarios/testcases/.qtenvrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[General]
2+
last-configname=General
3+
last-runnumber=0
4+
5+
[RunModeProfiles]
6+
fast-max-animation-speed=nan
7+
fast-max-playback-speed=1e+06
8+
fast-min-animation-speed=nan
9+
fast-min-playback-speed=1
10+
fast-playback-speed=1000
11+
run-max-animation-speed=nan
12+
run-max-playback-speed=100
13+
run-min-animation-speed=nan
14+
run-min-playback-speed=0.01
15+
run-playback-speed=1

src/openflow/controllerApps/AbstractControllerApp.cc

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
#include "inet/networklayer/common/L3AddressResolver.h"
99
#include "inet/common/ModuleAccess.h"
1010

11+
12+
simsignal_t AbstractControllerApp::PacketInSignalId = registerSignal("PacketIn");
13+
simsignal_t AbstractControllerApp::PacketOutSignalId = registerSignal("PacketOut");
14+
simsignal_t AbstractControllerApp::PacketFeatureRequestSignalId = registerSignal("PacketFeatureRequest");
15+
simsignal_t AbstractControllerApp::PacketFeatureReplySignalId = registerSignal("PacketFeatureReply");
16+
simsignal_t AbstractControllerApp::BootedSignalId = registerSignal("Booted");
17+
1118
Define_Module(AbstractControllerApp);
1219

1320
AbstractControllerApp::AbstractControllerApp()
@@ -46,21 +53,11 @@ void AbstractControllerApp::initialize(int stage){
4653
//register signals
4754
OperationalBase::initialize(stage);
4855
if (stage == INITSTAGE_LOCAL) {
49-
PacketInSignalId =registerSignal("PacketIn");
50-
PacketOutSignalId =registerSignal("PacketOut");
51-
PacketFeatureRequestSignalId = registerSignal("PacketFeatureRequest");
52-
PacketFeatureReplySignalId = registerSignal("PacketFeatureReply");
53-
BootedSignalId= registerSignal("Booted");
5456
getParentModule()->subscribe("PacketIn",this);
5557
getParentModule()->subscribe("PacketOut",this);
5658
getParentModule()->subscribe("PacketFeatureRequest",this);
5759
getParentModule()->subscribe("PacketFeatureReply",this);
5860
getParentModule()->subscribe("Booted",this);
59-
packetsFlooded=0;
60-
packetsDropped=0;
61-
numPacketOut=0;
62-
numFlowMod=0;
63-
controller= NULL;
6461
}
6562
else if (stage == INITSTAGE_APPLICATION_LAYER) {
6663
auto myNode = getContainingNode(this);
@@ -87,11 +84,13 @@ void AbstractControllerApp::receiveSignal(cComponent *src, simsignal_t id, cObje
8784
this->controller = cntrl;
8885
controller->registerApp(this);
8986
}
90-
9187
}
9288
}
9389

9490
void AbstractControllerApp::floodPacket(Packet *packet_in_msg){
91+
92+
if (controller == nullptr)
93+
throw cRuntimeError("Controller module is not initialized");
9594
auto header_in = packet_in_msg->peekAtFront<OFP_Packet_In>();
9695
EV << "floodPacket" << '\n';
9796
packetsFlooded++;
@@ -101,6 +100,10 @@ void AbstractControllerApp::floodPacket(Packet *packet_in_msg){
101100
}
102101

103102
void AbstractControllerApp::dropPacket(Packet *packet_in_msg){
103+
104+
if (controller == nullptr)
105+
throw cRuntimeError("Controller module is not initialized");
106+
104107
auto header_in = packet_in_msg->peekAtFront<OFP_Packet_In>();
105108
EV << "dropPacket" << '\n';
106109
packetsDropped++;
@@ -113,6 +116,9 @@ void AbstractControllerApp::dropPacket(Packet *packet_in_msg){
113116

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

119+
if (controller == nullptr)
120+
throw cRuntimeError("Controller module is not initialized");
121+
116122
auto header_in = packet_in_msg->peekAtFront<OFP_Packet_In>();
117123

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

126132
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){
133+
if (controller == nullptr)
134+
throw cRuntimeError("Controller module is not initialized");
135+
127136
EV << "sendFlowModMessage" << '\n';
128137
numFlowMod++;
129138
auto msgAux = createFlowMod(mod_com,match,outport,idleTimeOut,hardTimeOut);

src/openflow/controllerApps/AbstractControllerApp.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ class AbstractControllerApp: public OperationalBase, public cListener {
3939
virtual int getIndexFromId(int id);
4040

4141

42-
simsignal_t PacketInSignalId;
43-
simsignal_t PacketOutSignalId;
44-
simsignal_t PacketFeatureRequestSignalId;
45-
simsignal_t PacketFeatureReplySignalId;
46-
simsignal_t BootedSignalId;
47-
48-
long packetsFlooded;
49-
long packetsDropped;
50-
long numPacketOut;
51-
long numFlowMod;
52-
53-
OF_Controller * controller;
42+
static simsignal_t PacketInSignalId;
43+
static simsignal_t PacketOutSignalId;
44+
static simsignal_t PacketFeatureRequestSignalId;
45+
static simsignal_t PacketFeatureReplySignalId;
46+
static simsignal_t BootedSignalId;
47+
48+
long packetsFlooded = 0;
49+
long packetsDropped = 0;
50+
long numPacketOut = 0;
51+
long numFlowMod = 0;
52+
53+
OF_Controller * controller = nullptr;
5454

5555
virtual int numInitStages() const override { return NUM_INIT_STAGES; }
5656
virtual void initialize(int stage) override;

src/openflow/hyperflow/HF_ARPResponder.cc

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#define MSGKIND_ARPRESPONDERBOOTED 801
99

10+
simsignal_t HF_ARPResponder::HyperFlowReFireSignalId = registerSignal("HyperFlowReFire");
11+
1012
Define_Module(HF_ARPResponder);
1113

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

2224
ARPResponder::initialize(stage);
2325
if (stage == INITSTAGE_LOCAL) {
24-
hfAgent = NULL;
2526
//register signals
26-
HyperFlowReFireSignalId =registerSignal("HyperFlowReFire");
2727
getParentModule()->subscribe("HyperFlowReFire",this);
2828
}
2929
}
@@ -34,6 +34,9 @@ void HF_ARPResponder::handlePacketIn(Packet * pkt){
3434

3535
CommonHeaderFields headerFields = extractCommonHeaderFields(pkt);
3636

37+
if (controller == nullptr)
38+
throw cRuntimeError("Controller module is not initialized");
39+
3740
//check if it is an arp packet
3841
if(headerFields.eth_type == ETHERTYPE_ARP){
3942

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

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

56-
5761
//check arp type
5862
if(headerFields.arp_op == ARP_REQUEST){
5963

@@ -146,28 +150,34 @@ void HF_ARPResponder::handlePacketIn(Packet * pkt){
146150
floodPacket(pkt);
147151
}
148152
}
149-
150-
151153
}
152-
153154
}
154155

155-
156-
void HF_ARPResponder::receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details) {
157-
//set hfagent link
158-
ARPResponder::receiveSignal(src,id,obj,details);
159-
Enter_Method("HF_ARPResponder::receiveSignal %s", cComponent::getSignalName(id));
160-
if(hfAgent == NULL && controller != NULL){
156+
bool HF_ARPResponder::searchHyperFlowAggent()
157+
{
158+
if (hfAgent)
159+
return true;
160+
if(hfAgent == nullptr && controller != nullptr){
161161
auto appList = controller->getAppList();
162-
163162
for(auto iterApp=appList->begin();iterApp!=appList->end();++iterApp){
164163
if(dynamic_cast<HyperFlowAgent *>(*iterApp) != NULL) {
165164
HyperFlowAgent *hf = (HyperFlowAgent *) *iterApp;
166165
hfAgent = hf;
166+
return true;
167167
break;
168168
}
169169
}
170170
}
171+
return false;
172+
}
173+
174+
175+
void HF_ARPResponder::receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details) {
176+
//set hfagent link
177+
ARPResponder::receiveSignal(src,id,obj,details);
178+
Enter_Method("HF_ARPResponder::receiveSignal %s", cComponent::getSignalName(id));
179+
if (!searchHyperFlowAggent())
180+
throw cRuntimeError("HyperFlowAgent not synchronized, check if the agent is present in the network");
171181

172182
//check for hf messages to refire
173183
if(id == HyperFlowReFireSignalId){

src/openflow/hyperflow/HF_ARPResponder.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ class HF_ARPResponder: public ARPResponder {
2424

2525

2626
protected:
27+
virtual bool searchHyperFlowAggent();
2728
virtual void receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details) override;
2829
virtual void initialize(int stage) override;
2930
//void handlePacketIn(OFP_Packet_In * packet_in_msg);
3031
virtual void handlePacketIn(Packet*) override;
3132

32-
HyperFlowAgent * hfAgent;
33-
simsignal_t HyperFlowReFireSignalId;
33+
HyperFlowAgent * hfAgent = nullptr;
34+
static simsignal_t HyperFlowReFireSignalId;
3435
};
3536

3637

src/openflow/hyperflow/HF_LLDPAgent.cc

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#define MSGKIND_TRIGGERLLDP 101
77
#define MSGKIND_LLDPAGENTBOOTED 201
88

9+
simsignal_t HF_LLDPAgent::HyperFlowReFireSignalId = registerSignal("HyperFlowReFire");
10+
911
Define_Module(HF_LLDPAgent);
1012

1113
HF_LLDPAgent::HF_LLDPAgent(){
@@ -19,9 +21,7 @@ HF_LLDPAgent::~HF_LLDPAgent(){
1921
void HF_LLDPAgent::initialize(int stage){
2022
LLDPAgent::initialize(stage);
2123
if (stage == INITSTAGE_LOCAL) {
22-
hfAgent = NULL;
2324
//register signals
24-
HyperFlowReFireSignalId =registerSignal("HyperFlowReFire");
2525
getParentModule()->subscribe("HyperFlowReFire",this);
2626
}
2727
}
@@ -64,6 +64,9 @@ void HF_LLDPAgent::handlePacketIn(Packet *pktIn){
6464
entry.srcController = controller->getFullPath();
6565
entry.payload = wrapper;
6666

67+
if (hfAgent == nullptr)
68+
throw cRuntimeError("HyperFlowAgent not synchronized");
69+
6770
hfAgent->synchronizeDataChannelEntry(entry);
6871
pktIn->insertAtFront(frame);
6972
pktIn->insertAtFront(packet_in_msg);
@@ -93,7 +96,9 @@ void HF_LLDPAgent::handlePacketIn(Packet *pktIn){
9396
entry.trgSwitch = "";
9497
entry.srcController = controller->getFullPath();
9598
entry.payload = wrapper;
96-
99+
if (hfAgent == nullptr) {
100+
throw cRuntimeError("HyperFlowAgent not synchronized, check if the agent is present in the network");
101+
}
97102
hfAgent->synchronizeDataChannelEntry(entry);
98103
}
99104
}
@@ -103,24 +108,33 @@ void HF_LLDPAgent::handlePacketIn(Packet *pktIn){
103108

104109
}
105110

111+
bool HF_LLDPAgent::searchHyperFlowAggent()
112+
{
113+
if (hfAgent)
114+
return true;
106115

107-
void HF_LLDPAgent::receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details) {
108-
//set hfagent link
109-
LLDPAgent::receiveSignal(src,id,obj,details);
110-
Enter_Method("HF_LLDPAgent::receiveSignal %s", cComponent::getSignalName(id));
111-
if(hfAgent == NULL && controller != NULL){
116+
if(hfAgent == nullptr && controller != nullptr){
112117
auto appList = controller->getAppList();
113-
114118
for(auto iterApp=appList->begin();iterApp!=appList->end();++iterApp){
115119
if(dynamic_cast<HyperFlowAgent *>(*iterApp) != NULL) {
116120
HyperFlowAgent *hf = (HyperFlowAgent *) *iterApp;
117121
hfAgent = hf;
122+
return true;
118123
break;
119124
}
120125
}
121126
}
127+
return false;
128+
}
122129

123130

131+
void HF_LLDPAgent::receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details) {
132+
//set hfagent link
133+
LLDPAgent::receiveSignal(src,id,obj,details);
134+
Enter_Method("HF_LLDPAgent::receiveSignal %s", cComponent::getSignalName(id));
135+
136+
if (!searchHyperFlowAggent())
137+
throw cRuntimeError("HyperFlowAgent not synchronized, check if the agent is present in the network");
124138

125139
//check for hf messages to refire
126140
if(id == HyperFlowReFireSignalId){

src/openflow/hyperflow/HF_LLDPAgent.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ class HF_LLDPAgent:public LLDPAgent {
2525
LLDPMibGraph * getMibGraph();
2626

2727
protected:
28+
virtual bool searchHyperFlowAggent();
2829
virtual void receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details) override;
2930
virtual void initialize(int stage) override;
3031
virtual void handlePacketIn(Packet *) override;
31-
HyperFlowAgent * hfAgent;
32-
simsignal_t HyperFlowReFireSignalId;
32+
HyperFlowAgent * hfAgent = nullptr;
33+
static simsignal_t HyperFlowReFireSignalId;
3334
};
3435

3536

src/openflow/hyperflow/HyperFlowAgent.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#define MSGKIND_CHECKALIVEEVERY 703
1010
#define MSGKIND_HFCONNECT 704
1111

12+
simsignal_t HyperFlowAgent::HyperFlowReFireSignalId = registerSignal("HyperFlowReFire");
13+
1214
Define_Module(HyperFlowAgent);
1315

1416
HyperFlowAgent::HyperFlowAgent(){
@@ -38,8 +40,6 @@ void HyperFlowAgent::initialize(int stage){
3840
//socket.setDataTransferMode(TCP_TRANSFER_OBJECT);
3941
//schedule connection setup
4042

41-
//register signals
42-
HyperFlowReFireSignalId =registerSignal("HyperFlowReFire");
4343
}
4444
}
4545

@@ -188,7 +188,7 @@ void HyperFlowAgent::handleSyncReply(HF_SyncReply * msg){
188188
if(strcmp((*iterData).srcController.c_str(),controller->getFullPath().c_str())!=0){
189189
HF_ReFire_Wrapper * rfWrapper = new HF_ReFire_Wrapper();
190190
rfWrapper->setDataChannelEntry(*iterData);
191-
emit(HyperFlowReFireSignalId,rfWrapper);
191+
emit(HyperFlowReFireSignalId, rfWrapper);
192192
delete rfWrapper;
193193
}
194194
}
@@ -216,9 +216,9 @@ void HyperFlowAgent::handleCheckAlive(){
216216
}
217217

218218
void HyperFlowAgent::synchronizeDataChannelEntry(DataChannelEntry entry){
219-
EV << "HyperFlowAgent::Sent Change" << endl;
220219
Enter_Method_Silent();
221220

221+
EV_DEBUG << "HyperFlowAgent::Sent Change" << endl;
222222
auto change = makeShared<HF_ChangeNotification>();
223223
change->setChunkLength(B(sizeof(entry)));
224224
change->setEntry(entry);

src/openflow/hyperflow/HyperFlowAgent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class HyperFlowAgent:public AbstractTCPControllerApp {
4646
std::list<std::string> knownControllers;
4747
std::list<std::string> failedControllers;
4848

49-
simsignal_t HyperFlowReFireSignalId;
49+
static simsignal_t HyperFlowReFireSignalId;
5050

5151
virtual void handleStartOperation(LifecycleOperation *operation) override;
5252

src/openflow/openflow/protocol/openflow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ struct ofp_port {
312312
uint32_t curr_speed; /* Current port bitrate in kbps. */
313313
uint32_t max_speed; /* Max port bitrate in kbps */
314314
int interfaceId = -1;
315+
cModule *mac = nullptr;
315316
};
316317

317318
enum ofp_port_config {

0 commit comments

Comments
 (0)