In veins i'm trying to simulate a VANET scenario in which if road is blocked then after specific time the car broadcast a message including blocked roadId and count of vehicles around it's 100 meter.
In TraCIDemo11p application when the car is stopped for longer than 10 seconds it changes the node color to red (to show an accident) and sends a message out to other cars containing the blocked road id, all this is done in handlePositionUpdate mehtod:
findHost()->getDisplayString().updateWith("r=16,red");
sentMessage = true;
WaveShortMessage* wsm = new WaveShortMessage();
populateWSM(wsm);
wsm->setWsmData(mobility->getRoadId().c_str());
//host is standing still due to crash
if (dataOnSch) {
startService(Channels::SCH2, 42, "Traffic Information Service");
//started service and server advertising, schedule message to self to send later
scheduleAt(computeAsynchronousSendingTime(1,type_SCH),wsm);
}
else {
//send right away on CCH, because channel switching is disabled
sendDown(wsm);
}
The limit of 100m can be set by updating maxInterfDist value in in .ini file
*.connectionManager.maxInterfDist = 100m
Now the problem I have is how to get the count of vehicles and 100m of area, I have an idea that this will be done using TraCI and most probably using LaneAreaDetector's getJamLengthVehicle but i'm not getting how this will be done in veins, is their any equivalent method or i'm looking in wrong direction?