riebl / vanetza

Open-source implementation of the ETSI C-ITS protocol stack
Other
202 stars 158 forks source link

CAMs with socktap but CamApplication::indicate() method does not get called #163

Closed ekamberoglu closed 2 years ago

ekamberoglu commented 2 years ago

Hello,

I have been trying to CAMs with socktap but CamApplication::indicate() method does not get called. When I debugged it, I noticed that the following if block of RouterContext::indicate method returns false:

 if (hdr.source != mib_.itsGnLocalGnAddr.mid() && hdr.type == access::ethertype::GeoNetworking)
void RouterContext::indicate(CohesivePacket&& packet, const EthernetHeader& hdr) {
  if (hdr.source != mib_.itsGnLocalGnAddr.mid() && hdr.type == access::ethertype::GeoNetworking) {
        std::cout << "received packet from " << hdr.source << " (" << packet.size() << " bytes)\n";
        std::unique_ptr<PacketVariant> up { new PacketVariant(std::move(packet)) };
        trigger_.schedule(); // ensure the clock is up-to-date for the security entity
        router_.indicate(std::move(up), hdr.source, hdr.destination);
        trigger_.schedule(); // schedule packet forwarding
    }
}

I am passing the following program arguments to socktap - main class:

--positioning static --link-layer ethernet --a ca --print-rx-cam

When I run it, the parameters' values in "if block":

hdr.source: 00:00:00:00:00:00
mib_.itsGnLocalGnAddr.mid: 00:00:00:00:00:00
hdr.type: 8
access::ethertype:GeoNetworking: 18313

I am very sorry for this trivial question (I am very new with Vanetza); what parameters do I have to pass as arguments that I can get true from the following "if block".

 if (hdr.source != mib_.itsGnLocalGnAddr.mid() && hdr.type == access::ethertype::GeoNetworking)

Thanks, Ekrem

riebl commented 2 years ago

Hi Ekrem,

you are using the Ethernet link layer on your local loopback device (the default if you don't specify a device with --interface). The loopback device has an all-zero MAC address, as you have already observed. Furthermore, we compare "our" MAC address with the one in the received packet to suppress "local echos". When running multiple socktap instances I recommend setting distinct MAC addresses for each process explicitly with the --mac-address parameters.

kelunik commented 2 years ago

I've mostly used veth for that purpose, so you have two connected local peer interfaces with their own mac address without relying on loopback directly:

sudo ip link add veth0 type veth peer name veth1
sudo ip link set dev veth0 up
sudo ip link set dev veth1 up
ekamberoglu commented 2 years ago

Thanks Raphael and Niklas!