OMNeT++ : how to send a packet via specific wireless interface?

247 views Asked by At

I have two nodes, each consists of two WLAN interfaces, wlan0 is ieee80211, wlan1 is ieee80215 based on AdHoc Host from INET framework.

I'm sending a packet with UDP BasicAPP. When I enable both WLAN interfaces, it always sends the packet through wlan0 (i.e. ieee80211 protocol). If I want to send the packet with ieee80215, I must disable the ieee80211 WLAN interface in the sender node.

Is there any way to detemine which WLAN interface will be used for sending a packet?

2

There are 2 answers

0
alex31 On

You can choose which Interface you want to select to send the packet, and add the InterfaceReq Tag to the packet. The following code sends an udp packet over wlan1 interface.

InterfaceEntry *ifEntry = interfaceTable->getInterfaceByName("wlan1");
Packet *udpPacket = new Packet("Packet");
udpPacket->addTagIfAbsent<InterfaceReq>()->setInterfaceId(ifEntry->getInterfaceId());

Or, in the other hand, you can use the following if you know the Interface ID:

InterfaceEntry *ifEntry = interfaceTable->getInterfaceById(int interfaceID);
0
Rudi On

As those are different wireless technologies, they are obviously on different IP networks. Or at least they should be configured to be on different networks. If they are on different networks, your destination IP is clearly select which interface the packet should use.

In short, your IP (addresses and network) is probably not configured properly, that's why you can's select between the two interface using just the IP address.