dnatividade / VEINS-tutorials

Tutorials about VEINS, Sumo and OMNet++
GNU General Public License v3.0
15 stars 2 forks source link

Communication between RSU and Central Authority #3

Closed barkhabaheti closed 10 months ago

barkhabaheti commented 1 year ago

hey ! i have to make a project in which there are lots of rsu and cars and a central authority.in which car send message to rsu and at rsu we divide the levels according to their emergency message and then rsu send the message with signature to central authority and central authority will check the identity of cars and record the message. thank you in advance.

dnatividade commented 11 months ago

Ok. Or... put in your Makefile: LIBS = -lcryptopp

dnatividade commented 11 months ago

Demonstration: https://www.youtube.com/watch?v=BjRA-AtXm8Y

barkhabaheti commented 11 months ago

traci.zip hi in this i have changed code. what i have to do is car sending to rsu and rsu sending to CA and then a ACK should be send from CA to RSU and RSU to CAR. in my case ACK to RSU is sending perfectly but ACK form RSU to CAR is not happening. can you please check and tell me what to do.

dnatividade commented 11 months ago

Okay, I understand what you did wrong. I'll make a video explaining it to you.

dnatividade commented 11 months ago

Fixing the code

However, the best way to do this would be to immediately send the RSU ACK to the car and only then send the RSU message to the CA.

Not recommended: CAR --msg--> RSU RSU --msg--> CA CA --ack--> RSU RSU --ack--> CAR

Recommended: CAR --msg--> RSU RSU --ack--> CAR RSU --msg--> CA CA --ack--> RSU

This is because in a scenario with many vehicles, if the RSU receives a message from car1, forwards it to the CA, and in this period receives a message from car2, the address of car1 will be replaced by the address of car2 and car1 will never receive the ack . You understood?

dnatividade commented 11 months ago

Another thing you should do is send the message and wait for ack. If you don't receive ack (within 2 seconds, for example), send the message again. Because collisions or packet losses may occur.

barkhabaheti commented 11 months ago

Okay thank you

On Sat, 16 Sep 2023 at 8:15 PM, dnatividade @.***> wrote:

Another thing you should do is send the message and wait for ack. If you don't receive ack (within 2 seconds, for example), send the message again. Because collisions or packet losses may occur.

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1722245178, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQJR7PL3BASTNGVDCFLX2W3QDANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

barkhabaheti commented 11 months ago

Hi i m not able to build crypto library in windows. I downloaded it from github. And try to build it in visual studio but in it, it is showing unloaded i m stuck now don’t understand what to do.

On Sat, 16 Sep 2023 at 9:17 PM, Barkha Baheti MTCS, SPUP < @.***> wrote:

Okay thank you

On Sat, 16 Sep 2023 at 8:15 PM, dnatividade @.***> wrote:

Another thing you should do is send the message and wait for ack. If you don't receive ack (within 2 seconds, for example), send the message again. Because collisions or packet losses may occur.

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1722245178, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQJR7PL3BASTNGVDCFLX2W3QDANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

dnatividade commented 11 months ago

In this case I would need to install Windows on a VM to test. I might try to do that on Saturday...

barkhabaheti commented 11 months ago

Ok, sounds good.

On Wed, 20 Sep 2023 at 4:09 PM, dnatividade @.***> wrote:

In this case I would need to install Windows on a VM to test. I might try to do that on Saturday...

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1727465934, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQIQUMTYDCSGQU67JKLX3LBUPANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

barkhabaheti commented 11 months ago

Demonstration: https://www.youtube.com/watch?v=BjRA-AtXm8Y

in this video after install just added the include but what is the middle process for omnet where you included these files what changes should i make to run this.

dnatividade commented 11 months ago

This video shows the entire process that needs to be done to make it work. The crypto++ library was installed at first with the apt install libcrypto++-dev command. Remembering that this procedure only works on Debian-based Linux distributions. At 5:39 of the video I show where to configure the compiler to insert the cryptopp library into the liker (-lcryptopp)

barkhabaheti commented 11 months ago

Thanks, I'll check it out.

On Thu, 21 Sep 2023 at 4:35 PM, dnatividade @.***> wrote:

This video shows the entire process that needs to be done to make it work. The crypto++ library was installed at first with the apt install libcrypto++-dev command. Remembering that this procedure only works on Debian-based Linux distributions. At 5:39 of the video I show where to configure the compiler to insert the cryptopp library into the liker (-lcryptopp)

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1729347085, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQM5CXQENGRBWHHMZF3X3QNRDANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

barkhabaheti commented 11 months ago

how to include and what to include the file path.

On Thu, Sep 21, 2023 at 4:56 PM Barkha Baheti MTCS, SPUP < @.***> wrote:

Thanks, I'll check it out.

On Thu, 21 Sep 2023 at 4:35 PM, dnatividade @.***> wrote:

This video shows the entire process that needs to be done to make it work. The crypto++ library was installed at first with the apt install libcrypto++-dev command. Remembering that this procedure only works on Debian-based Linux distributions. At 5:39 of the video I show where to configure the compiler to insert the cryptopp library into the liker (-lcryptopp)

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1729347085, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQM5CXQENGRBWHHMZF3X3QNRDANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

barkhabaheti commented 11 months ago

lib include i tried this..

dnatividade commented 11 months ago

I didn't need to change anything there. I just needed to configure this:

Captura de tela de 2023-09-22 09-49-36

Captura de tela de 2023-09-22 09-49-23

barkhabaheti commented 11 months ago

I did this but it didn’t work how the omnet will find the path without including it. I didn’t get it. What i did was download the library and run the crypt.sln file in visual studio and in solution explorer 4 file created and i build these files and in cryptopp fuolder two folders created x64 and 32. After that i did link thing in omnet. On Fri, 22 Sep 2023 at 6:22 PM, dnatividade @.***> wrote:

I didn't need to change anything there. I just needed to configure this:

[image: Captura de tela de 2023-09-22 09-49-36] https://user-images.githubusercontent.com/43869367/269941877-0fa2b864-b0ec-4edc-af1d-96d6ba4a4119.png

[image: Captura de tela de 2023-09-22 09-49-23] https://user-images.githubusercontent.com/43869367/269941909-6f0fa3cf-ff03-4134-9340-021ff7a396a0.png

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1731364212, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQKDDERJZNDZSHJ7QLDX3WC2BANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

dnatividade commented 11 months ago

I did this but it didn’t work how the omnet will find the path without including it.

When I install crypto++ from the Linux repository, the libraries go to OS path, so I don't need to configure anything.

What i did was download the library and run the crypt.sln file in visual studio and in solution explorer 4 file created and i build these files and in cryptopp fuolder two folders created x64 and 32. After that i did link thing in omnet.

I don't understand anything about Windows and Visual Studio. I would need to test...

barkhabaheti commented 11 months ago

Will you be able to do it today?

On Fri, 22 Sep 2023 at 8:29 PM, dnatividade @.***> wrote:

I did this but it didn’t work how the omnet will find the path without including it.

When I install crypto++ from the Linux repository, the libraries go to OS path, so I don't need to configure anything.

What i did was download the library and run the crypt.sln file in visual studio and in solution explorer 4 file created and i build these files and in cryptopp fuolder two folders created x64 and 32. After that i did link thing in omnet.

I don't understand anything about Windows and Visual Studio. I would need to test...

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1731569673, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQJ7NO2LEBELBCESX43X3WRWHANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

dnatividade commented 11 months ago

I will try...

barkhabaheti commented 11 months ago

hey did you tried it ...

On Sun, Sep 24, 2023 at 1:09 AM dnatividade @.***> wrote:

I will try...

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1732395063, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQLGSACYSFU42UI5J73X343HVANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

barkhabaheti commented 11 months ago

hey I can use crc32. in which i want when car sending message to rsu it will send its crc32 hash too

dnatividade commented 11 months ago

hey did you tried it ... On Sun, Sep 24, 2023 at 1:09 AM dnatividade @.> wrote: I will try... — Reply to this email directly, view it on GitHub <#3 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQLGSACYSFU42UI5J73X343HVANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.>

Yes, I managed to get the simulation to work with crypto++ on Windows. I will upload a video to show you how to do it.

dnatividade commented 11 months ago

hey I can use crc32. in which i want when car sending message to rsu it will send its crc32 hash too

OK. Did you see CRC32 in one of my examples?

dnatividade commented 11 months ago

How to run OMNeTt++, Veins and Crypto++ on MS Windows. https://www.youtube.com/watch?v=2gNghqiyM6U

barkhabaheti commented 11 months ago

Yes i saw your code but it didn’t work for me i want that the message which we are sending to the rsu from the car Message + hash(sender address + message) so how can i do this..

On Tue, 26 Sep 2023 at 7:24 PM, dnatividade @.***> wrote:

How to run OMNeTt++, Veins and Crypto++ on MS Windows. https://www.youtube.com/watch?v=2gNghqiyM6U

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1735592221, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQOH3JEA7TDUXROWXEDX4LNCJANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

dnatividade commented 11 months ago

Ok, in this case, you need to create a field into .msg file:

import veins.base.utils.Coord;
import veins.modules.messages.BaseFrame1609_4;
import veins.base.utils.SimpleAddress;

namespace veins;

packet TraCIDemo11pMessage extends BaseFrame1609_4 {
    string demoData;
    LAddress::L2Type senderAddress = -1;
    int serial = 0;
    unsigned long crc; //new field
}

Change hashCRCMsg() to:

/* My Functions
 * @author: dnatividade
 */
unsigned long TraCIDemo11p::hashCRCMsg(int carAddress, std::string dataWsm){
    //https://stackoverflow.com/a/25018742
    unsigned long  crc = crc32(0L, Z_NULL, 0);

    /*concatenate all message fields to compute hash
     * senderAddress(int)  +  data(string)
     */
    std::string allWsmFields = std::to_string(carAddress) +  dataWsm;
    //compute hash (for simplicity i am using CRC32 as hash function)
    //https://stackoverflow.com/a/25018742
    crc = crc32(crc, (const unsigned char*)allWsmFields.c_str(), strlen(allWsmFields.c_str()));

    return crc;
}

To send the message, add this after populateWSM():

wsm->setCrc(hashCRCMsg(myId, "message");
barkhabaheti commented 11 months ago

Ok, I will try.

On Tue, 26 Sep 2023 at 8:00 PM, dnatividade @.***> wrote:

Ok, in this case, you need to create a field into .msg file:

import veins.base.utils.Coord; import veins.modules.messages.BaseFrame1609_4; import veins.base.utils.SimpleAddress;

namespace veins;

packet TraCIDemo11pMessage extends BaseFrame1609_4 { string demoData; LAddress::L2Type senderAddress = -1; int serial = 0; unsigned long crc; //new field }

Change hashCRCMsg() to:

/* My Functions

  • @author: dnatividade */ unsigned long TraCIDemo11p::hashCRCMsg(int carAddress, std::string dataWsm){ //https://stackoverflow.com/a/25018742 unsigned long crc = crc32(0L, Z_NULL, 0);

    /*concatenate all message fields to compute hash

    • senderAddress(int) + data(string) / std::string allWsmFields = std::to_string(carAddress) + dataWsm; //compute hash (for simplicity i am using CRC32 as hash function) //https://stackoverflow.com/a/25018742 crc = crc32(crc, (const unsigned char)allWsmFields.c_str(), strlen(allWsmFields.c_str()));

    return crc; }

To send the message, add this after populateWSM():

wsm->setCrc(hashCRCMsg(myId, "message");

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1735664077, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQOP6AGBZX5XMQASQUTX4LRGTANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

dnatividade commented 11 months ago

If you can, please mark my answer as a solution in these StackOverflow links: (This is you, isn't it?)

https://stackoverflow.com/questions/76927399/how-to-make-changes-in-myveinsapp-using-demomessageapp

https://stackoverflow.com/questions/77065134/i-have-to-create-central-authority-unit-like-rsu-and-cars-in-veins-example/

barkhabaheti commented 11 months ago

How to run OMNeTt++, Veins and Crypto++ on MS Windows. https://www.youtube.com/watch?v=2gNghqiyM6U

how did you compile cryptopp file..

barkhabaheti commented 11 months ago

Done.

On Tue, Sep 26, 2023 at 10:23 PM dnatividade @.***> wrote:

If you can, please mark my answer as a solution in these StackOverflow links: (This is you, isn't it?)

https://stackoverflow.com/questions/76927399/how-to-make-changes-in-myveinsapp-using-demomessageapp

https://stackoverflow.com/questions/77065134/i-have-to-create-central-authority-unit-like-rsu-and-cars-in-veins-example/

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1735930751, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQPPSJ6ZY22YCJVT3XTX4MCBXANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

barkhabaheti commented 11 months ago

traci.zip i tried this but getting error..

barkhabaheti commented 11 months ago

how to handle this message at rsu...

dnatividade commented 11 months ago

Ok. You need to send a message from CAR to RSU containing: senderId, data, hash. Right? What about CA?

barkhabaheti commented 11 months ago

Rsu will send this details to ca and then ca will calculate hash again and compare it with the hash sended by the car to rsu and rsu to ca.

On Wed, 27 Sep 2023 at 7:09 PM, dnatividade @.***> wrote:

Ok. You need send a message from CAR to RSU containing: senderId, data, hash). Right? What about CA?

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1737420249, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQJ3EEJ5V2CA4BXYGADX4QUAVANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

dnatividade commented 11 months ago

The code is almost ready, but I just have one question: will the CA calculate the CRC based on the RSU ID or based on the ID of the vehicle that originally sent the message to the RSU?

dnatividade commented 11 months ago

traci-CRC_CAR-RSU-CA.zip

In this code:

barkhabaheti commented 11 months ago

Thanks, I'll check it out.

On Fri, 29 Sep 2023 at 12:40 AM, dnatividade @.***> wrote:

traci-CRC_CAR-RSU-CA.zip https://github.com/dnatividade/VEINS-tutorials/files/12753071/traci-CRC_CAR-RSU-CA.zip

In this code:

  • CAR computes CRC(myId, msgData) -> send to RSU
  • RSU computes CRC(carID, msgData)
    • if CRC correct: computes new CRC(myId, msgData) -> send to CA
  • At the end, the number of messages received by RSU and CA is shown

OBS.: I created a class called CRC and all nodes (vehicles, RSUs and CAs) use it to do CRC operations

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1739867072, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQPRKOOMP4773QMVZLTX4XDS5ANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

barkhabaheti commented 11 months ago

referenced by ../out/clang-release/src/veins/modules/application/traci/CRC.o:(CRC::hashCRCMsg(int, std::cxx11::basic_string<char, std::char_traits, std::allocator >)) referenced by ../out/clang-release/src/veins/modules/application/traci/CRC.o:(CRC::hashCRCMsg(int, std::cxx11::basic_string<char, std::char_traits, std::allocator >)) clang++: error: linker command failed with exit code 1 (use -v to see invocation) C:\Users\DELL\src\omnetpp-5.7\tools\win64\mingw64\bin/llvm-ar.exe: error: unable to load '../out/clang-release/src/libveins.dll.a': No such file or directory make[1]: [Makefile:216: ../out/clang-release/src/libveins.dll] Error 1 make[1]: Leaving directory '/c/Users/DELL/Downloads/veins_CA/veins/src' make: [Makefile:36: all] Error 2 "make MODE=release -j12 all" terminated with exit code 2. Build might be incomplete.

I AM GETTING THIS ERROR WHILE RUNNING YOUR CODE. WHILE RUNNING PREVIOUS ONE IT IS RUNNING Okay.

On Fri, Sep 29, 2023 at 10:40 AM Barkha Baheti MTCS, SPUP < @.***> wrote:

Thanks, I'll check it out.

On Fri, 29 Sep 2023 at 12:40 AM, dnatividade @.***> wrote:

traci-CRC_CAR-RSU-CA.zip https://github.com/dnatividade/VEINS-tutorials/files/12753071/traci-CRC_CAR-RSU-CA.zip

In this code:

  • CAR computes CRC(myId, msgData) -> send to RSU
  • RSU computes CRC(carID, msgData)
    • if CRC correct: computes new CRC(myId, msgData) -> send to CA
  • At the end, the number of messages received by RSU and CA is shown

OBS.: I created a class called CRC and all nodes (vehicles, RSUs and CAs) use it to do CRC operations

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1739867072, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQPRKOOMP4773QMVZLTX4XDS5ANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

dnatividade commented 11 months ago

https://github.com/dnatividade/VEINS-tutorials/assets/43869367/30676a35-ed78-45aa-8279-2b8e1d3ebfae

In this case I don't know what it could be. You can try searching StackOverflow about this error. I needed to see your environment, as it may have some invalid configuration. Try making a video showing the compilation process. Or send screenshots.

But I'm sending you the complete code for you to import into your OMNet++.

veins-complete_2023-09-28.zip

barkhabaheti commented 11 months ago

Before this code the code was running i hope whole project will be good to go.

On Fri, 29 Sep 2023 at 4:35 PM, dnatividade @.***> wrote:

https://github.com/dnatividade/VEINS-tutorials/assets/43869367/30676a35-ed78-45aa-8279-2b8e1d3ebfae

In this case I don't know what it could be. You can try searching StackOverflow about this error. I needed to see your environment, as it may have some invalid configuration. Try making a video showing the compilation process. Or send screenshots.

But I'm sending you the complete code for you to import into your OMNet++.

veins-complete_2023-09-28.zip https://github.com/dnatividade/VEINS-tutorials/files/12764494/veins-complete_2023-09-28.zip

— Reply to this email directly, view it on GitHub https://github.com/dnatividade/VEINS-tutorials/issues/3#issuecomment-1740714074, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HCZQMIY6GT5G4F5XADXWLX42TN5ANCNFSM6AAAAAA4J4YZBQ . You are receiving this because you authored the thread.Message ID: @.***>

dnatividade commented 11 months ago

Did you try the full code I sent you?

Send me your full old code.

barkhabaheti commented 11 months ago

while running your code im still getting these errors.. .tmplib6632(CRC.o): In function CRC::hashCRCMsg(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)': C:\Users\Dell\Downloads\veins\veins\src/veins/modules/application/traci/CRC.cc:9: undefined reference tocrc32' C:\Users\Dell\Downloads\veins\veins\src/veins/modules/application/traci/CRC.cc:11: undefined reference to `crc32' clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: [Makefile:265: ../out/clang-debug/src/libveins_dbg.dll] Error 1 make[1]: Leaving directory '/c/Users/Dell/Downloads/veins/veins/src' make: [Makefile:36: all] Error 2 "make MODE=debug -j4 all" terminated with exit code 2. Build might be incomplete.

barkhabaheti commented 11 months ago

did zlib libarary needs any other configuration..

barkhabaheti commented 11 months ago

i am not able to find the solution of of this error which version of omnet veins and sumo you are using.

dnatividade commented 11 months ago

zlibb needs to be declared in CRC.h:

//App: @dnat

#pragma once

#include "veins/modules/application/ieee80211p/DemoBaseApplLayer.h"
#include "veins/modules/application/traci/defines.h" //header with all necessary defines
#include <zlib.h>

/**
 * CRC Demo
 */
class CRC {
public:
    unsigned long hashCRCMsg(int carAddress, std::string dataWsm);

};
dnatividade commented 11 months ago

CRC.cc:

//App: @dnat

#include <veins/modules/application/traci/CRC.h>

unsigned long CRC::hashCRCMsg(int carAddress, std::string dataWsm){
    //https://stackoverflow.com/a/25018742
    unsigned long  crc = crc32(0L, Z_NULL, 0);
    std::string allWsmFields = std::to_string(carAddress) +  dataWsm;
    crc = crc32(crc, (const unsigned char*)allWsmFields.c_str(), strlen(allWsmFields.c_str()));

    return crc;
}
dnatividade commented 11 months ago

Hi. I tested this code on Windows and got the same error as you. I'll find out what the problem is and let you know...

dnatividade commented 11 months ago

You need to add zlib library in the linker options. Project -> Properties -> OMNeT++ -> Makemake -> src: ... -> Options -> Link -> Add: z linker-z

dnatividade commented 11 months ago

zlib-windows