How to drop specific packet captured in NS-3 mesh node? - wifi

I'm using NS-3 v3.28.1 to simulation a WiFi Mesh network. The grid topology (actually only one line, with IEEE 802.11s stack installed at each node, HWMP protocol) contains 3 WiFi Mesh nodes, Node0, Node1 and Node2. Then I bind a UDP socket (acting as receiver) in Node0, and another (acting as sender) in Node2. Node2 send a UDP packet to Node0 through Node1 every 10ms. The topology as follow:
Node0 (receiver) <--- Node1 <---- Node2 (sender)
10.1.1.1/24              10.1.1.2/24      10.1.1.3/24
Then I set a MonitorSnifferRx function on Node1 to listen udp packets sent from Node2 to Node0 using Config::ConnectWithoutContext:
Config::ConnectWithoutContext ("/NodeList/1/DeviceList/*/Phy/MonitorSnifferRx", MakeCallback (&DecodeRxPktCB));
In Node1 callback function DecodeRxPktCB, I can decode the udp packet sent from Node2 to Node0.
My question is :
when a specific UDP packet captured (with content match some rules) in Node1's MonitorSnifferRx callback function, how can I drop it thus it will not transfer to Node0? I see that the first parameter in MonitorSnifferRx callback function is "Ptr< const Packet > packet", with const value only can read.

You can use the NS-3 Packet class to grab the information you need and filter it.
If you can, I'd recommend adding a packet tag (or ByteTag) on the sender, making it easier for your middle node to filter it. Packet tag details are also on the link above.

Related

Capturing Profisafe packets using Lua Wireshark dissector

I am writing a Lua script to capture profisafe packets on wireshark.It is above the profinet layer in the stack.The wireshark dissect the profinet packets but does not dissect the profisafe.
For other protocols built on tcp or udp protocol one can do something like
local tcp_port = Dissector.get("tcp.port")
tcp_port:add(1234,foo_protocol)
to capture the packets that arises and received by the port 1234.
But profisafe is built on profinet and does not contain tcp or udp as the underlying layer.How to capture the packets in this case? I tried giving ethernet frame address in the place of port name but it did not work.
Use the menu Edit, Preferences, Protocols and search for PNIO:
PNIO options
Then select the checkbox "Enable detailed PROFIsafe dissection" and define a directory, where the GSDML file of the PROFIsafe device is located.

How to calculate the number of packets sent to or forwarded by a node in RPL protocol of ContikiOS?

In RPL for selecting the best parent with the trust model In order to select a trusted parent, direct and indirect trust must be calculated. For direct trust computation, the number of packets sent to node A by node B and the number of packets forwarded by node A on behalf of node B must be counted and I have trouble in determining the number of forwarded packets. Any help will be useful for solving this problem.
You can look at the values of uip_stat.ip.sent and uip_stat.ip.forwarded. Make sure to enable uIP statistics (#define UIP_CONF_STATISTICS 1).

Get total network traffic between all nodes in a cluster

I'm working in an docker overlay network with six nodes. I would like to measure the total network traffic between all nodes. I came across iftop but it only counts the bytes between the local machine and each node like:
node0(local)<->node1
node0(local)<->node2
...
but not:
node1<->node2
...
I had to install iftop on each node and even then I had to exclude the following connection because it was already counted above.
node1(local)<->node0
...
Or I had to sum up all total TX or RX values on each node. Additionally I had to start iftop on each node at the same time and pause it when my I see my specified process has finished. Is there an easier way so that I can simply start a record on any host and stop the recording to get the total bytes for this period?

Can we have two simultaneous udp streams between 2 specific pairs of IPs and Ports?

I'm trying to inspect and analyze my network traffic. Suddenly I found something confusing. I was thought that packets are splited to streams based on their (SRC_IP, DES_IP, SRC_PORT, SRC_PORT , PROTOCOL_NUM). But now I found two groups of packets with equal above features but interpreted as two different streams in Wireshark:
As you see below, the RTP packets with even packet numbers are a single stream and the RTP packets with odd packet number are another stream, while both has equal (SRC_IP, DES_IP, SRC_PORT, SRC_PORT , PROTOCOL_NUM). Why?
To compare the statistics:
They are interpreted as two different streams:
You are just looking at the UDP traffic from either direction. UDP stream 2 is from 192.168.1.162 to 192.168.1.159 and UDP stream 3 is from 192.168.1.159 to 192.168.1.162.
While there are two UDP streams, there is only one RTP session. This is because the RFC protocol states that you cannot multiplex on the same port. From RTP RFC Section 5.2.
In RTP, multiplexing is provided by the destination transport address
(network address and port number) which is different for each RTP session.
So, yes there are two simultaneous UDP streams, but it is just both hosts talking to each other during a RTP session.

How do I implement a labview server and client to send and receive network packets in parallel?

I am writing two programs (server.vi) and (client.vi). that communicate with each other over a TCP connection.
After the client opens a TCP connection with the server, the server responds with a packet of type "A". The client sends another packet of type "A" back to the server as an acknowledgement. At this point the server starts sending a continous stream of packets of type "B" to the client. And the client starts sending a continous stream of packets with type "C".
This means the sending an receiving of packets with types B and C will be in parallel.
How should I implement something like this in labview?
Here is one idea i have and I was hoping someone could either comment or provide a better suggestion.
the server has two while loops
a. first while loop consists of a TCP read function that receives packets of type "C".
b. second while loop consists of a TCP write function that sends packets of type "B"
the client has two while loops
a. first while loop consists of a TCP write function that sends packets of type "C"
b. second while loop consists of a TCP read function that receives packets of type "B".
This way we are sending and receiving packets of type "B" and "C" in parallel.
All the while loops are independent of each other and are essentially infinite unless both client and server programs are stopped.
Does this make any sense? Is there a more clever / better aproach to doing this?
That sounds like the appropriate way to have two processes run in parallel in LabVIEW, yes.
Have a look at the examples that come with LabVIEW - in LV 2012 there's a 'TCP Communicator - Active.vi' (Help->Find Examples->Networking->TCP & UDP) that looks like it does something similar to what you're describing.
You need to figure out when and how to stop each loop - the example above uses a local variable but you could also do it with a notifier, for example.

Resources