|
a/src/DAF/AE/AEPing.cc |
|
b/src/DAF/AE/AEPing.cc |
|
... |
|
... |
27 |
const char* PAR_RATE = "rate";
|
27 |
const char* PAR_RATE = "rate";
|
28 |
const char* PAR_DSTAPNAME = "dstApName";
|
28 |
const char* PAR_DSTAPNAME = "dstApName";
|
29 |
const char* PAR_DSTAPINSTANCE = "dstApInstance";
|
29 |
const char* PAR_DSTAPINSTANCE = "dstApInstance";
|
30 |
const char* PAR_DSTAENAME = "dstAeName";
|
30 |
const char* PAR_DSTAENAME = "dstAeName";
|
31 |
const char* PAR_DSTAEINSTANCE = "dstAeInstance";
|
31 |
const char* PAR_DSTAEINSTANCE = "dstAeInstance";
|
|
|
32 |
const char* VAL_MODULEPATH = "getFullPath()";
|
32 |
|
33 |
|
33 |
AEPing::AEPing() {
|
34 |
AEPing::AEPing() {
|
34 |
}
|
35 |
}
|
35 |
|
36 |
|
36 |
AEPing::~AEPing() {
|
37 |
AEPing::~AEPing() {
|
|
... |
|
... |
44 |
}
|
45 |
}
|
45 |
|
46 |
|
46 |
void AEPing::preparePing() {
|
47 |
void AEPing::preparePing() {
|
47 |
//Schedule Data transfer
|
48 |
//Schedule Data transfer
|
48 |
for (int i = 0; i < rate && pingAt + i < stopAt; i++) {
|
49 |
for (int i = 0; i < rate && pingAt + i < stopAt; i++) {
|
49 |
std::stringstream ss;
|
50 |
std::ostringstream ss;
|
50 |
ss << MSG_PING << i;
|
51 |
ss << MSG_PING << i;
|
51 |
cMessage* m2 = new cMessage(ss.str().c_str());
|
52 |
cMessage* m2 = new cMessage(ss.str().c_str());
|
52 |
scheduleAt(pingAt + i, m2);
|
53 |
scheduleAt(pingAt + i, m2);
|
53 |
}
|
54 |
}
|
54 |
}
|
55 |
}
|
|
... |
|
... |
80 |
dstApName = this->par(PAR_DSTAPNAME).stringValue();
|
81 |
dstApName = this->par(PAR_DSTAPNAME).stringValue();
|
81 |
dstApInstance = this->par(PAR_DSTAPINSTANCE).stringValue();
|
82 |
dstApInstance = this->par(PAR_DSTAPINSTANCE).stringValue();
|
82 |
dstAeName = this->par(PAR_DSTAENAME).stringValue();
|
83 |
dstAeName = this->par(PAR_DSTAENAME).stringValue();
|
83 |
dstAeInstance = this->par(PAR_DSTAEINSTANCE).stringValue();
|
84 |
dstAeInstance = this->par(PAR_DSTAEINSTANCE).stringValue();
|
84 |
|
85 |
|
85 |
//Flow
|
|
|
86 |
APNamingInfo src = this->getApni();
|
|
|
87 |
APNamingInfo dst = APNamingInfo( APN(this->dstApName), this->dstApInstance,
|
|
|
88 |
this->dstAeName, this->dstAeInstance);
|
|
|
89 |
Flow fl = Flow(src, dst);
|
|
|
90 |
fl.setQosParameters(this->getQoSRequirements());
|
|
|
91 |
|
|
|
92 |
//Insert it to the Flows ADT
|
|
|
93 |
insertFlow(fl);
|
|
|
94 |
|
|
|
95 |
//Schedule AllocateRequest
|
86 |
//Schedule AllocateRequest
|
96 |
if (startAt > 0)
|
87 |
if (startAt > 0)
|
97 |
prepareAllocateRequest();
|
88 |
prepareAllocateRequest();
|
98 |
//Schedule Data transfer
|
89 |
//Schedule Data transfer
|
99 |
if (pingAt > 0)
|
90 |
if (pingAt > 0)
|
100 |
preparePing();
|
91 |
preparePing();
|
101 |
//Schedule DeallocateRequest
|
92 |
//Schedule DeallocateRequest
|
102 |
if (stopAt > 0)
|
93 |
if (stopAt > 0)
|
103 |
prepareDeallocateRequest();
|
94 |
prepareDeallocateRequest();
|
104 |
|
95 |
|
|
|
96 |
myPath = this->getFullPath();
|
|
|
97 |
|
105 |
//Watchers
|
98 |
//Watchers
|
106 |
WATCH_LIST(flows);
|
99 |
WATCH_LIST(flows);
|
107 |
}
|
100 |
}
|
108 |
|
101 |
|
109 |
void AEPing::handleSelfMessage(cMessage *msg) {
|
102 |
void AEPing::handleSelfMessage(cMessage *msg) {
|
110 |
//EV << flows.back().info() << endl;
|
103 |
//EV << flows.back().info() << endl;
|
111 |
if ( !strcmp(msg->getName(), "StartCommunication") ) {
|
104 |
if ( !strcmp(msg->getName(), TIM_START) ) {
|
112 |
//signalizeAllocateRequest(&flows.back());
|
|
|
113 |
//FIXME: Vesely - last flow in a list?!
|
105 |
//FIXME: Vesely - last flow in a list?!
|
|
|
106 |
|
|
|
107 |
//Flow
|
|
|
108 |
APNamingInfo src = this->getApni();
|
|
|
109 |
APNamingInfo dst = APNamingInfo( APN(this->dstApName), this->dstApInstance,
|
|
|
110 |
this->dstAeName, this->dstAeInstance);
|
|
|
111 |
|
|
|
112 |
Flow fl = Flow(src, dst);
|
|
|
113 |
fl.setQosParameters(this->getQoSRequirements());
|
|
|
114 |
|
|
|
115 |
//Insert it to the Flows ADT
|
|
|
116 |
insertFlow(fl);
|
|
|
117 |
|
114 |
Irm->receiveAllocationRequest(&flows.back());
|
118 |
sendAllocationRequest(&flows.back());
|
115 |
}
|
119 |
}
|
116 |
else if ( !strcmp(msg->getName(), "StopCommunication") )
|
120 |
else if ( !strcmp(msg->getName(), TIM_STOP) ) {
|
|
|
121 |
//FIXME: Vesely - last flow in a list?!
|
117 |
//signalizeDeallocateRequest(&flows.back());
|
122 |
sendDeallocationRequest(&flows.back());
|
118 |
//Irm->receiveDeallocationRequest(&flows.back());
|
123 |
}
|
119 |
EV << "StopCommunication";
|
|
|
120 |
else if ( strstr(msg->getName(), "PING") ) {
|
124 |
else if ( strstr(msg->getName(), MSG_PING) ) {
|
121 |
//TODO: Vesely - Send M_READ
|
125 |
//Create PING messsage
|
122 |
std::stringstream ss;
|
126 |
CDAP_M_Read* ping = new CDAP_M_Read(VAL_MODULEPATH);
|
123 |
ss << "M_READ(" << msg->getName() << ")";
|
127 |
object_t obj;
|
124 |
cMessage* ping = new cMessage(ss.str().c_str());
|
128 |
obj.objectName = VAL_MODULEPATH;
|
125 |
send(ping , "dataIo$o", 0);
|
129 |
obj.objectClass = "string";
|
|
|
130 |
obj.objectInstance = -1;
|
|
|
131 |
obj.objectVal = (cObject*)(&myPath);
|
|
|
132 |
ping->setObject(obj);
|
|
|
133 |
|
|
|
134 |
//Send message
|
|
|
135 |
sendData(&flows.back(), ping);
|
126 |
}
|
136 |
}
|
127 |
else
|
137 |
else
|
128 |
EV << this->getFullPath() << " received unknown self-message " << msg->getName();
|
138 |
EV << this->getFullPath() << " received unknown self-message " << msg->getName();
|
129 |
delete(msg);
|
139 |
delete(msg);
|
130 |
}
|
140 |
}
|
|
... |
|
... |
132 |
void AEPing::handleMessage(cMessage *msg)
|
142 |
void AEPing::handleMessage(cMessage *msg)
|
133 |
{
|
143 |
{
|
134 |
if ( msg->isSelfMessage() )
|
144 |
if ( msg->isSelfMessage() )
|
135 |
this->handleSelfMessage(msg);
|
145 |
this->handleSelfMessage(msg);
|
136 |
}
|
146 |
}
|
|
|
147 |
|
|
|
148 |
void AEPing::processMRead(CDAPMessage* msg) {
|
|
|
149 |
CDAP_M_Read* msg1 = check_and_cast<CDAP_M_Read*>(msg);
|
|
|
150 |
|
|
|
151 |
EV << "Received M_Read";
|
|
|
152 |
object_t object = msg1->getObject();
|
|
|
153 |
EV << " with object '" << object.objectClass << "'" << endl;
|
|
|
154 |
|
|
|
155 |
if ( strstr(object.objectName.c_str(), VAL_MODULEPATH) ) {
|
|
|
156 |
std::string* source = (std::string*)(object.objectVal);
|
|
|
157 |
std::ostringstream os;
|
|
|
158 |
os << "Ping requested by " << *source << endl;
|
|
|
159 |
bubble(os.str().c_str());
|
|
|
160 |
EV << os.str().c_str();
|
|
|
161 |
|
|
|
162 |
//Create PING response
|
|
|
163 |
CDAP_M_Read_R* pong = new CDAP_M_Read_R(VAL_MODULEPATH);
|
|
|
164 |
object_t obj;
|
|
|
165 |
obj.objectName = VAL_MODULEPATH;
|
|
|
166 |
obj.objectClass = "string";
|
|
|
167 |
obj.objectInstance = -1;
|
|
|
168 |
obj.objectVal = (cObject*)(&myPath);
|
|
|
169 |
pong->setObject(obj);
|
|
|
170 |
|
|
|
171 |
sendData(&flows.back(), pong);
|
|
|
172 |
}
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
void AEPing::processMReadR(CDAPMessage* msg) {
|
|
|
176 |
CDAP_M_Read_R* msg1 = check_and_cast<CDAP_M_Read_R*>(msg);
|
|
|
177 |
|
|
|
178 |
EV << "Received M_Read_R";
|
|
|
179 |
object_t object = msg1->getObject();
|
|
|
180 |
EV << " with object '" << object.objectClass << "'" << endl;
|
|
|
181 |
|
|
|
182 |
if ( strstr(object.objectName.c_str(), VAL_MODULEPATH) ) {
|
|
|
183 |
std::string* source = (std::string*)(object.objectVal);
|
|
|
184 |
std::ostringstream os;
|
|
|
185 |
os << "Ping replied by " << *source << endl;
|
|
|
186 |
bubble(os.str().c_str());
|
|
|
187 |
EV << os.str().c_str();
|
|
|
188 |
}
|
|
|
189 |
}
|