ms-van3t-devs / ms-van3t

A multi-stack, ETSI compliant, V2X framework for ns-3.
GNU General Public License v2.0
100 stars 33 forks source link

Error: msg="unsupported protocol 35143, only IPv4 and IPv6 are supported" #33

Open SunYuanYuan19 opened 1 month ago

SunYuanYuan19 commented 1 month ago

Hi Carlos, I tried to change the WiFi channel in v2p-vam-10811p.cc to nr channel, but I failed with the following error yy@yy:~/ms-van3t/ns-3-dev$ ./ns3 run scratch/v2p-vam-nr Sumo: wait for socket: 1s Loading configuration ... done. aborted. cond="protocolNumber != Ipv4L3Protocol::PROT_NUMBER && protocolNumber != Ipv6L3Protocol::PROT_NUMBER", msg="unsupported protocol 35143, only IPv4 and IPv6 are supported", +0.000000000s -1 file=/home/yy/ms-van3t/ns-3-dev/src/nr/model/nr-ue-net-device.cc, line=213 terminate called without an active exception Command 'build/scratch/ns3-dev-v2p-vam-nr-optimized' died with <Signals.SIGABRT: 6>. [mycode.zip](https://github.com/ms-van3t-devs/ms-van3t/files/15404433/mycode.zip) Do you have any Idea or can you give hints? Greetings Max

carlosrisma commented 1 month ago

Hi @SunYuanYuan19 ,

the reason why you are probably getting this error is because the nr model works using UDP sockets instead of ns-3's PacketSocket (which 80211p supports). The sample application for VAMs using 80211p only supports creating PacketSockets when calling : Ptr<Socket> sock = GeoNet::createGNPacketSocket(includedNode); In order to use NR-V2X you should replace that line for a new snippet of code that creates the correct UdpSocket, similar to how it is done in the emergencyVehicleAlert.cc sample application. You could try by replacing it with the following:

Ptr<Socket> sock;
TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
m_socket = Socket::CreateSocket (includedNode, tid);
if (m_socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), 19)) == -1)
{
  NS_FATAL_ERROR ("Failed to bind client socket for NR-V2X");
}
Ipv4Address groupAddress4 ("225.0.0.0");  
m_socket->Connect (InetSocketAddress (groupAddress4, 19));

Let me know if this helps !

BR, Carlos

SunYuanYuan19 commented 1 month ago

Hi Carlos,

Thank you so much for providing that sample code snippet. I've carefully reviewed it and I believe this approach of replacing the PacketSocket with a UdpSocket is likely the right solution to the issue I'm facing with using the NR-V2X model. As you mentioned, the nr model is based on UDP sockets rather than the PacketSocket used by the 80211p protocol, so this change makes a lot of sense. The example code you provided for creating the UdpSocket and connecting it looks very appropriate and should help me set up the correct socket for communicating with the NR-V2X model. I'll go ahead and try integrating this code into my program to see if it resolves the error I was encountering. Once again, thank you for the helpful suggestion - I really appreciate you taking the time to provide this guidance, as it will hopefully allow me to get my NR-V2X simulation working properly.

Best regards, SunYuanYuan19