Is there a way to sniff/listen an unicast packet/message on Omnet?

99 views
Skip to first unread message

Ali Arslan

unread,
Jul 30, 2019, 2:49:34 PM7/30/19
to OMNeT++ Users
I am doing development for WSN in Omnet.

I want to sniff a unicast message but I don't have an idea how can i do it in Omnet. I made some research but i couldn't found any method for that

When I send data to another node, I am sending it as an unicast with this method :


cModule *nodeIndex = flatTopolojiModulu->getSubmodule("n", i);//n is array
sendDirect
(new cMessage("msg"), nodeIndex, "in");


I am using ``sendDirect`` method because I am working on wireless network. According to this description : https://stackoverflow.com/a/36082721/5736731

``sendDirect`` method is usually the case in wireless networks.

But when send message with sendDirect, a message is being handled by receiver node. For example, according to code example above:

if ``i=2``, message that is sent only can handle by node which has index "2" from
``void AnyClassName::handleMessage(cMessage *msg)`` function

Rudolf Hornig

unread,
Jul 31, 2019, 5:35:18 AM7/31/19
to OMNeT++ Users
Using this approach to model wireless simulation is very basic. (more) Proper wireless simulations (like in INET framework) are usually done in a different way:

You have a separate global module which represents the radio medium as a whole (i.e. the electromagnetic spectrum). You pass the packet to be transmitted to the medium module (which knows the physical location of all nodes) then the medium itself computes attenuation etc. and passes the packet to all the nodes that may receive it. Then the modules decide whether they want to drop it because it is not addressed to them. In this scenario, you can program a node to accept all packets regardless of MAC address so you could listen on all traffic.

If you go with the simple approach you have mentioned, you are doing the addressing already when you send, so you really send only one copy to the destination. In that case you have to explicitly implement a broadcast (i.e. copy the packet and send it to all nodes or at least to all nodes that are in promiscuous mode) 

Ali Arslan

unread,
Jul 31, 2019, 3:01:28 PM7/31/19
to OMNeT++ Users
Thank you for your advices. At first, I will reply your second  answer. I do not want to send broadcast or multicast message. Because energy of the each node is important for me. I am trying to develop energy efficient protocol. So i am sending message as unicast. I want to sniff a packet of unicast message. For example wireshark is doing this but i am working on WSN and i am using omnet that's way i am looking solution in omnet for packet sniffing in unicast transmission.

For example, A is a sender node and B is a receiver node. Node C is "sniffer/listener" and it is between A and B. When I send packet from A to B, I want to "C" listens packet. In other word, "C" should overhear the packet and it can control the data of the packet which is sent from A to B. "C" should listen packet, even if I didn't send the packet directly to node C. Is it possible in Omnet?

And lastly, is there any example on the internet related in your first advice? (documentation/code example from git or from any other platforms)


31 Temmuz 2019 Çarşamba 12:35:18 UTC+3 tarihinde Rudolf Hornig yazdı:

Rudolf Hornig

unread,
Aug 1, 2019, 7:40:28 AM8/1/19
to OMNeT++ Users


On Wednesday, July 31, 2019 at 9:01:28 PM UTC+2, Ali Arslan wrote:
Thank you for your advices. At first, I will reply your second  answer. I do not want to send broadcast or multicast message. Because energy of the each node is important for me. I am trying to develop energy efficient protocol. So i am sending message as unicast. I want to sniff a packet of unicast message. For example wireshark is doing this but i am working on WSN and i am using omnet that's way i am looking solution in omnet for packet sniffing in unicast transmission.

Energy wise it does not matter whether you are sending a unicast or multicast message. In real world, your source node puts out some energy in the electromagnetic spectrum and that propagates in every direction and reaches all nodes once the radio wave reaches them. Wheter the node can/will capture that message depends only on the signal to noise ratio at the receiving station. Once the packet is received, the node decides whether it keeps the data and passes up to upper layer protocols or throws away. Broadcast messages are always sent up while unicast messages are sent up only if the receiving node's mac address matches the destination mac address. 

This mechanism (i.e. the propagation of radio waves in every direction) is usually modeled in OMNeT by copying the message for each node and sending all messages separately. However this is just how it is *modeled* it does not mean that you have to calculate the energy consumption for each transmission. You can count the whole broadcast as a single transmission.
 
 

For example, A is a sender node and B is a receiver node. Node C is "sniffer/listener" and it is between A and B. When I send packet from A to B, I want to "C" listens packet. In other word, "C" should overhear the packet and it can control the data of the packet which is sent from A to B. "C" should listen packet, even if I didn't send the packet directly to node C. Is it possible in Omnet?
Yes, you can model this listening as I written above by sending a copy to each possible listener independently from each other. (note that the reception is also independent in real world. Receiving the packet by the C node does not affect the reception at B)

Now the part where C can *control* the in flight packet is not possible. But this would not possible in real world either? How would C modify the packet which is traveling at the speed of light in the empty space? By the time C decodes the packet, B would also receive it. Also C cannot receive and transmit new data at the same time at the same frequency as it would interfere with its own reception.
 
 

And lastly, is there any example on the internet related in your first advice? (documentation/code example from git or from any other platforms)
INET does it that way. Older frameworks like MiXiM did this too. In INET take a look at the UnitRadio folder, which is a very simple radio model:

 
Reply all
Reply to author
Forward
0 new messages