In the veins_inet example in omnet ++ , i need to send the message ( accident ) to only some vehicles , not to all of them , which means i don't want to send the message in broadcast but i want to send it to specific vehicles at a simulation time that i choose ? Does anyone know how to do that ? I wonder if i should change the code in VeinsInetSampleApplication.cc ?? maybe i have to change the sendPacket method but i don't know how to do it ! i spent days trying to change the destination address , i used the senddirect () function , i added gates but i got a lot of errors ! Can you help me please ? :
Here is the code related to my issue from the example ( this is the code that sends the message in broadcast to all the vehicles without any changes ) , this is not the whole code but i chose from each class some lines that i think are related to my problem :
At the VeinsInetSampleApplication.cc :
// host[0] should stop at t=37s
/*if (getParentModule()->getIndex() == 4) {
auto callback = [this]() {
getParentModule()->getDisplayString().setTagArg("i", 1, "yellow");
traciVehicle->setSpeed(0);
auto payload = makeShared<VeinsInetSampleMessage>();
payload->setChunkLength(B(500));
payload->setRoadId(traciVehicle->getRoadId().c_str());
timestampPayload(payload);
auto packet = createPacket("accident");
packet->insertAtBack(payload);
sendPacket(std::move(packet));
// host should continue after 40s
auto callback = [this]() {
traciVehicle->setSpeed(-1);
};
timerManager.create(veins::TimerSpecification(callback).oneshotIn(SimTime(40, SIMTIME_S)));
};
timerManager.create(veins::TimerSpecification(callback).oneshotAt(SimTime(37, SIMTIME_S)));
}
The sendPacketMethod At the veinsInetApplicationBase.cc :
void VeinsInetApplicationBase::sendPacket(std::unique_ptr<inet::Packet> pk)
{
emit(packetSentSignal, pk.get());
socket.sendTo(pk.release(), destAddress, portNumber);
}
At the veinsInetApplicationBase.h :
inet::L3Address destAddress;
const int portNumber = 9001;
At the veinsInetApplicationBase.cc :
L3AddressResolver().tryResolve("224.0.0.1", destAddress);
ASSERT(!destAddress.isUnspecified());
socket.setOutputGate(gate("socketOut"));
socket.bind(L3Address(), portNumber);
At Scenario.ned :
node[0]: VeinsInetCar ;
And here i don't understand why is it only node[0] that is defined ? i have 6 nodes in my simulation , how can i specify the nodes i want to send the message to because i don't want to send it to all of the nodes , i just want to send my message to those that are distanced less than 500 m from the vehicle sending the message ? how to specify the destination addresses of the nodes based on the distance ? ( because i work with 802.11p)
Finally At the the omnet.ini :
[General]
network = Scenario
sim-time-limit = 140s
debug-on-errors = true
cmdenv-express-mode = true
image-path = ../../../../images
# UDPBasicApp
*.node[*].numApps = 1
*.node[*].app[0].typename = "mywork.veins_inet.VeinsInetSampleApplication"
*.node[*].app[0].interface = "wlan0"
# Ieee80211Interface
*.node[*].wlan[0].opMode = "p"
*.node[*].wlan[0].radio.typename = "Ieee80211DimensionalRadio"
*.node[*].wlan[0].radio.bandName = "5.9 GHz"
*.node[*].wlan[0].radio.channelNumber = 6
*.node[*].wlan[0].radio.transmitter.power = 20mW
*.node[*].wlan[0].radio.bandwidth = 10 MHz
*.node[*].wlan[*].radio.antenna.mobility.typename = "AttachedMobility"
*.node[*].wlan[*].radio.antenna.mobility.mobilityModule = "^.^.^.^.mobility"
*.node[*].wlan[*].radio.antenna.mobility.offsetX = -2.5m
*.node[*].wlan[*].radio.antenna.mobility.offsetZ = 1.5m
*.node[*].wlan[*].radio.antenna.mobility.constraintAreaMinX = 0m
*.node[*].wlan[*].radio.antenna.mobility.constraintAreaMaxX = 0m
*.node[*].wlan[*].radio.antenna.mobility.constraintAreaMinY = 0m
*.node[*].wlan[*].radio.antenna.mobility.constraintAreaMaxY = 0m
*.node[*].wlan[*].radio.antenna.mobility.constraintAreaMinZ = 0m
*.node[*].wlan[*].radio.antenna.mobility.constraintAreaMaxZ = 0m
# HostAutoConfigurator
*.node[*].ipv4.configurator.typename = "HostAutoConfigurator"
*.node[*].ipv4.configurator.interfaces = "wlan0"
*.node[*].ipv4.configurator.mcastGroups = "224.0.0.1"
# VeinsInetMobility
*.node[*].mobility.typename = "VeinsInetMobility"
# VeinsInetManager
*.manager.updateInterval = 0.1s
*.manager.host = "localhost"
*.manager.port = 9999
*.manager.autoShutdown = true
*.manager.launchConfig = xmldoc("enetcom.launchd.xml")
*.manager.moduleType = "mywork.veins_inet.VeinsInetCar"
# PhysicalEnvironment
*.physicalEnvironment.config = xmldoc("obstacles.xml")
*.radioMedium.obstacleLoss.typename = "IdealObstacleLoss"
# Misc
**.vector-recording = true
Now what i need to know is which lines from these lines i have to change and how shall i change them in order to make the message sent only to some vehicles i choose by myself in the simulation not to all the vehicles around ?? Please help me ! Thank you so much in advance !