Skip to content

Commit

Permalink
added trim broadcast script
Browse files Browse the repository at this point in the history
  • Loading branch information
valdiz777 committed Apr 25, 2017
1 parent e99227f commit bce579b
Show file tree
Hide file tree
Showing 12 changed files with 139,206 additions and 208,170 deletions.
382 changes: 191 additions & 191 deletions dvcastlayer/simulations/results/General-0.sca

Large diffs are not rendered by default.

178 changes: 89 additions & 89 deletions dvcastlayer/simulations/results/General-0.vci

Large diffs are not rendered by default.

251,592 changes: 138,856 additions & 112,736 deletions dvcastlayer/simulations/results/General-0.vec

Large diffs are not rendered by default.

84 changes: 38 additions & 46 deletions dvcastlayer/src/application/DVCastLayer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ bool contains(std::deque<int> * queue, int key);
bool contains(std::map<int, std::string> delayedRB, int key);
void remove(std::deque<int> * queue, int key);

// chose cluster ROI
int clusterRadius = 250;
// ROI = 2 * clusterRadius
int clusterRadius = 2500;

Define_Module(DVCastLayer);
void DVCastLayer::initialize(int stage) {
Expand Down Expand Up @@ -94,44 +94,39 @@ void DVCastLayer::onData(WaveShortMessage* wsm) {
return;
}

if (!contains(&rcvdMessages, wsm->getSerial())) {
// this is a new message, add to received message queue
rcvdMessages.push_back(wsm->getSerial());
if (!NB_OPPOSITE.empty()) {
if (NB_OPPOSITE.size() == 1
&& (NB_OPPOSITE.front() == wsm->getSenderAddress())) {
ODC = false;
}
ODC = true;
} else {
if (!NB_OPPOSITE.empty()) {
if (NB_OPPOSITE.size() == 1
&& (NB_OPPOSITE.front() == wsm->getSenderAddress())) {
ODC = false;
}
ODC = true;
} else {
ODC = false;
}

Dflg = (wsm->getRecipientAddress() == getParentModule()->getIndex()) ?
true : false;
MDC = (NB_FRONT.empty() || NB_BACK.empty()) ? false : true;

EV << "MDC:" << MDC << " ODC:" << ODC << " Dflg:" << Dflg << endl;

if (!MDC) {
// no broadcast suppression yet
if (ODC) {
sendMessage(wsm->getWsmData(), -1, wsm->getSerial());
sentMessages.push_back(wsm->getSerial());
if (!Dflg) {
findHost()->getDisplayString().updateWith("r=16,pink");
if (!contains(delayedRB, wsm->getSerial())) {
delayedRB.insert(
std::pair<int, std::string>(wsm->getSerial(),
wsm->getWsmData()));
}
Dflg = (wsm->getRecipientAddress() == getParentModule()->getIndex()) ?
true : false;
MDC = (NB_FRONT.empty() || NB_BACK.empty()) ? false : true;

EV << "MDC:" << MDC << " ODC:" << ODC << " Dflg:" << Dflg << endl;

if (!MDC) {
// no broadcast suppression yet
if (ODC) {
sendMessage(wsm->getWsmData(), -1, wsm->getSerial());
if (!Dflg) {
findHost()->getDisplayString().updateWith("r=16,pink");
if (!contains(delayedRB, wsm->getSerial())) {
delayedRB.insert(
std::pair<int, std::string>(wsm->getSerial(),
wsm->getWsmData()));
}
} else {
findHost()->getDisplayString().updateWith("r=16,blue");
delayedRB.insert(
std::pair<int, std::string>(wsm->getSerial(),
wsm->getWsmData()));
}
} else {
findHost()->getDisplayString().updateWith("r=16,blue");
delayedRB.insert(
std::pair<int, std::string>(wsm->getSerial(),
wsm->getWsmData()));
}
}
}
Expand Down Expand Up @@ -178,17 +173,12 @@ void DVCastLayer::handleParkingUpdate(cObject* obj) {
// send hellos evertime we move 50 meters in x or y
void DVCastLayer::handlePositionUpdate(cObject* obj) {
BaseWaveApplLayer::handlePositionUpdate(obj);
//sentAccidentMessage = (sentAccidentMessage) ? false : true;

dlastx += std::abs(mobility->getCurrentPosition().x - lastx);
dlasty += std::abs(mobility->getCurrentPosition().y - lasty);

if ((dlastx >= clusterRadius / 2) || (dlasty >= clusterRadius / 2)) {
// Send hello in 1Hz freqency
if (simTime() - lastDroveAt > 1) {
DVCast* wsm = prepareHello("hello", beaconLengthBits, type_CCH,
beaconPriority, -1, 72);
sendHello(wsm);
dlastx = (dlastx > clusterRadius / 2) ? 0 : dlastx;
dlasty = (dlasty > clusterRadius / 2) ? 0 : dlasty;
}

if (mobility->getSpeed() < 1) {
Expand All @@ -205,8 +195,6 @@ void DVCastLayer::handlePositionUpdate(cObject* obj) {
} else {
lastDroveAt = simTime();
}
lastx = mobility->getCurrentPosition().x;
lasty = mobility->getCurrentPosition().y;
}

void DVCastLayer::sendWSM(WaveShortMessage* wsm) {
Expand Down Expand Up @@ -308,7 +296,7 @@ void DVCastLayer::neigbors_tables(Coord senderPosition, int senderId,

MDC = (NB_FRONT.empty() || NB_BACK.empty()) ? false : true;

if (!NB_OPPOSITE.empty()){
if (!NB_OPPOSITE.empty()) {
ODC = true;
} else {
ODC = false;
Expand All @@ -333,8 +321,12 @@ void DVCastLayer::neigbors_tables(Coord senderPosition, int senderId,
if (!MDC) { //verify MDC is still false
sendMessage(x.second, -1, x.first);
}

}
delayedRB.empty();
while (!delayedRB.empty())
{
delayedRB.erase(delayedRB.begin());
}
ODC = true;
}
}
Expand Down
4 changes: 0 additions & 4 deletions dvcastlayer/src/application/DVCastLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ class DVCastLayer: public BaseWaveApplLayer {
AnnotationManager* annotations;
simtime_t lastDroveAt;

double lasty = 0;
double lastx = 0;
double dlasty = 0;
double dlastx = 0;
std::deque<int> NB_FRONT, NB_BACK, NB_OPPOSITE;
std::deque<int> rcvdMessages;
std::deque<int> sentMessages;
Expand Down
2 changes: 1 addition & 1 deletion dyna-dvcastlayer/simulations/omnetpp.ini
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ sim-time-limit = 6000s
##########################################################
# WaveAppLayer #
##########################################################
*.node[*].applType = "DVCastLayer"
*.node[*].applType = "Dyna_DVCastLayer"
*.node[*].appl.debug = false
*.node[*].appl.headerLength = 256 bit
*.node[*].appl.sendBeacons = false
Expand Down
Loading

0 comments on commit bce579b

Please sign in to comment.