ManiAm / VENTOS_Public

VEhicular NeTwork Open Simulator (VENTOS)
http://maniam.github.io/VENTOS/
GNU General Public License v3.0
57 stars 25 forks source link

Send packet prob. #10

Closed paullee714 closed 6 years ago

paullee714 commented 6 years ago

first of all, Thank for this VENTOS tool.

now here is my problem.

how can i make 'a vehicle' and 'a RSU' send data packet? not just beacon frame.

ManiAm commented 6 years ago
  1. Right click on the src/msg folder and click 'New | Message Definition (msg)'. Give it a name like dataMsg.msg and click next. click Empty Message File and then click Finish.

  2. Write your message. For example:

cplusplus {{
#include "WaveShortMessage_m.h"
}}
class Veins::WaveShortMessage;
namespace VENTOS;

packet dataMsg extends WaveShortMessage
{
    string sender;
    int target;
};
  1. Go to the nodes/vehicle or nodes/RSU and find a place that you need to create your message.

  2. Include the message header like below. Since the message name is dataMsg then we will have dataMsg_m as header file.

#include "dataMsg_m.h"

  1. Create and fill the message like below. Note that TYPE_DATA is the new enum type that you need to add to the WaveApplMessageTypes that is defined in the 04_BaseWaveApplLayer.h file located in src/baseAppl folder.
    dataMsg* d = new dataMsg("myMessage", TYPE_DATA);
    // add header length
    d->addBitLength(headerLength);
     .....
  1. Now you can send the data with send command like:

send(d, lowerLayerOut);

Let me know if you have any other questions. I will add a section on creating message in the VENTOS manual later.

paullee714 commented 6 years ago

dataMsg in nodes/vehicle or nodes/RSU ?? i can't understand what should i do in that file...

paullee714 commented 6 years ago

can you give me more specific comments after number 2?

ManiAm commented 6 years ago

I have created a new example that shows how to send data packets. Get the latest version of the manual and go to Section 17.1. Also get the latest VENTOS code to get the new example. Go to the VENTOS folder and run 'git pull'