Setting up router agent to use custom PHY (phy2) to send data from simulated modem to real modem - unetstack

I am working on an attribute based routing protocol, where source node (Node A) collect attributes from two neighbor nodes (Node B and C) and based on ranking, Node A decides,to forward its data either to Node B or Node C
Now, to test this algorithm in testbed with only two real UnetStack modems, as per the answer (by Prof. Mandar Chitre) to my previous post Is there a way to trasnmit and receive data between simulated and real modem in UnetStack I have implemented a phy2 PHYSICAL agent, using UnetSocket, as a proxy to send data to real modem.
However, now I am able to send data from Node B (gateway node) in simulation subnet to Node B in another subnet from phy2, but I want to send data using router. Please let me know, how I can setup router agent to use phy2.

The acoustic channel is not shared between the simulated and real modem, since the simulated modem can't transmit real sound in water, and so a real modem can't "hear" the simulated modem.
However, you could consider sending your information over a different link (e.g. UdpLink) that can send messages between a simulated node and a real modem, as long as both are connected to the same subnet over IP.
In fact, if you wanted a even closer simulation to your network, you could add an agent to the modem that would listen to the DatagramNtf from UdpLink and send an equivalent RxFrameNtf to topic(phy), simulating a frame that came over the acoustic channel.

Related

Trim frame details in XBee output

I would like to set up 3 XBee devices in API mode, one coordinator, two nodes. The coordinator will send payloads to either one of the nodes and address the XBee frames accordingly. The nodes will send messages only to the coordinator (never to each other).
Is it possible for the serial output of the node modules to trim off all API header/frame/checksum info before passing down data to the serial port (the device they are connected does not understand XBee API frame data). Likewise is it possible for the node modules to automatically add the relevant header/frame/checksum data when sending to the coordinator, again the device connected to the XBee serial port doesn't understand XBee frames so doesn't know how to add the frame data, only the payload.
I have complete control over the software at the coordinator end, so can manage the XBee frame data in my code there.
Yes, it's possible to run the non-coordinator devices in "AT mode" or "Transparent Serial" mode. It's also referred to as "Serial Cable Replacement Mode" because you can replace a serial cable with paired modules.
Configure DH and DL on the non-coordinators as 0 to automatically send serial data to the coordinator.
You can use Transmit API frames on the coordinator to address target nodes, and they will just send the payload out on the serial port.
You can even configure the modules with different baud rates.

force UDP broadcast via the network (disable loopback)

I want to send a UDP broadcast datagram to multiple devices on the network, including the sender device itself. The goal is to have all devices receive the data at the EXACT same time (well, +/- 5ms is OK).
The problem is that the network interface on the sending device is looping the data back, so it is received immediately (in contrast to the other devices where network latency comes into play - quite a bit for Wifi for instance)
Any idea how I can disable my network interface to loop the data back directly?
Another idea I had: Is it possible to create a virtual network interface to send the broadcast packet and listen on another interface which only receives it via the network?
I am trying to do that in C on a Linux machine. Any help would be greatly appreciated!
UDP are sent as IP-payload. The routing of IP packets is a domain of the IP stack. It decides how a packet is transferred to the destination. When you IP stack detects that the destination is the local host it will enqueue the packet in the receive queue and the packet will be available immediatly. If your adapters' send queues are filled that you will have a delay. So you can't make a synchronization with this concept.
If you need a hard synchronization you should utilize NTP or SNTP tro synchronize the clocks and define a comment start time for your desired common operation.
Edit:
The (S)NTP protocol is designed to synchronize at millisecond Level. You will get a precision that you can't achieve with any Transmission of UDP packets due to the reason I described above.

Information exchange between two computers connected over wireless

I would like to get some ideas on this topic which is new for me and i am interested to learn more on this.
I have developed a voice controlled application which is written in C program which should control some operation. I want to control these operations on another computer connected over wireless network.
I want to do the following,
when my voice is recognized at Computer A with a "String A", It should send this "String A" to COmputer B, Computer B sends a request to acknowledge to computer A, when computer A send Acknowledge string "Yes" to B, Computer B will execute a operation (for example open the notepad).
PS: Computer A and B, both are Linux, Ubuntu machines
How to start doing this Information exchange? Also provide some useful links along with your suggestions. I am sure it will help me a lot in completing this.
basically you can use socket communications. Write client and server sockets on both the machines. One to Receive command and other one to send commands. Upon Getting the sockets ready (the whole dance of bind, listen etc.,), you kickoff the voice2text module. OnVoice2TextConverted, send the message to other machine via socket. OnReceive at other machine, prepare another message (ack) to send it to request initiator. Define a message structure for mode communication between these two machines(see if you have to serialize or use XML/JSON). when you shout 'enough', detect the voice through your module and tear down the sockets. Intimate this to other party before tear down. Perform clean up.

Xbee mesh network: Can end-devices have bi-directional communication with a coordinator?

Quick question: I'm setting up a mesh network with Digi's Xbees series 2, one coordinator and as many as 8 end-devices and as the title implies.
I was wondering if the end-devices could receive data from the coordinator, making for a 2-way communication as I know they can send data to it. These are used in an Arduino-based robot location triangulation project.
Yes, you can do it using API mode if you know the mac address of the device you want to talk to.
Try it here: Digi API Frame Maker. The Frame you need to use is Transmit Request (type 0x10).
You can do it in Transparent Mode too, but in this case you need to enter command mode and set the device address before sending data each time you need to talk to a different module (using ATDLand ATDH commands).

Open UDP socket between source and destination, modify it and forward it to the original destination

I am running a simple network that contains 2 nodes and a gateway. My scenario is as follows: Node1 wants to send a UDP IPv6 socket to Node2 via the Gateway which has to open the sockets, verifies data and then forwarding it.
I configured an internal network between Node1 and Gateway having an address of aaaa::/20, and an other network between Gateway and Node2 having an address of aaab::/20. I modified Node1 routing table to send packets destined to aaab::/20 network via its aaaa::/20 interface connected to the Gateway, and configured the former to forward packets.
My problem is by doing so, the Gateway became completely transparent. I want my gateway to be able to catch sockets even if they are not destined to it, opening them, modifying them and forwarding them to their original destination. Googled this and I found suggestions to use iptables, but i'm not expert with them.
I'm using 3 virtual machines under linux and programming with c. Any help please?!!
Iptables is not something to be afraid of ;) it has its own defined C functions. Go through the interface library and apply it to your own case. That is to run a program in the gateway, to capture all packets passing through it. There is documentation.

Resources