When the physical process replies to node through sensor manager, I want to send source_snapshot[i].time along with retVal.
For this purpose, I am using phyMsg->setTimestamp() function in Physical Process and getTimestamp() wherever needed.
Is this the correct practice?
EDIT: or maybe I can add a time variable in physical process message structure?
Related
I have been working on a position-based protocol using veins-inet and I want to get the position of the destination node.
In my code, I got the IP Address of the destination from the datagram.
const L3Address& destAddr = datagram->getDestinationAddress();
and I want to get the current position of this node.
I already checked the following question
How to get RSU coordinate from TraCIDem11p.cc?
But it seems that it refers to the node by using the node ID.
Is there a way to get the position of the node by referring to its IP Address?
I am using instant veins-4.7.1
A very simple solution would be to have each node publish its current L3Address and Coord to a lookup table whenever it moves. This lookup table could be located in a shared module or every node could have its own lookup table. Remember, you are writing C++ code, so even a simple singleton class with methods for getting/setting information is enough to coordinate this.
If, however, the process of "a node figures out where another node is" is something you would like to model (e.g., this should be a process that takes some time, can fail, causes load on the wireless channel, ...) you would first need to decide how this information would be transferred in real life, then model this using messages exchanged between nodes.
I'm using the wireless example, and i want get the simulation time and save in parameter for calculate the time the packet arrival and the packet send. Have anyone solution for these?
There is a statistics for this automatically collected in application models (i.e. like BasicUdpApp etc.). It's called endToEndDelay.
The proper way to do this (and this what is already done in INET) is that you during packet creation you should add a TAG to the sent packet which contains a simtime_t variable and put the actual simtime there and then read the same TAG when the packet arrives and calculate the difference. Putting values into the "parameters" of a message would NOT work as the packets could be fragmented/defragmented in the network so their identity is not kept and the attached parameters are destroyed.
But again, this is already present in INET 4.2
when sensor manager sends the request to physical process using gate index for sensor device :
send(requestMsg, "toNodeContainerModule", corrPhyProcess[sensorIndex]);
will the physical process receive the request message regardless of the distance with node? or whether the physical process receives the msg or not will depend on the distance?
The physical process has a fixed value and it never changes.
The physical process will always get the message from any node.
Figure 1 of the Castalia manual shows that a physical process module is connected to all the nodes. So when a node sends an OMNeT message to that module, it will be received.
Of course, what will the physical process do with the message and what value it will return, it depends on the specific physical process you implement.
Modbus is a a request and response type serial communication. Basically the master send out a request and one of the slave response.
I am modifing the code on a microcontroller which is a master unit on a modbus network. This unit also has a small dot-matrix LCD and some buttons for user interface. The microcontroller is running at 16MHz.
The problem is after the master unit send out a request, it does not know when the slave response, so it may need to wait for a relatively long time. However as this unit has buttons and LCD, it can not wait at a point for too long because the user will feel lag when he pressed a button. The original code is using a RTOS. It seperate the user interface task and the serial communication tasks so it has no problem. Now I need to change it to non-RTOS code. I have implemented a system tick timer which will interrupt at each 1ms. What is the proper (or common) way to do that?
It is possible to do quite a lot with just a single task, especially if you have interrupts. The intermediate position between a single very simple task and an RTOS is a cyclic executive. See http://www3.nd.edu/~cpoellab/teaching/cse40463/slides10.pdf for a brief overview of the spectrum of functionality from a cyclic executive up to a fully preemptive multitasking operating system. You will find much more if you search on this phrase and related phrases, including very sophisticated schemes for making sure that the system never misses its deadlines. If you are an aircraft flight control system, forgetting to check the aircraft pitch angle every X ms can cause problems elsewhere :-)
One way to rewrite code which is naturally multi-threaded is to maintain a model of the state of the system, such as a collection of objects each representing a modbus connection, indexed by a connection id. Then write a routine for every sort of event that can happen, including the arrival of a clock interrupt. When that event happens these routines typically work out which connection is involved, retrieve it from the main collection (or create it from scratch and enter it there if necessary) do the work associated with that particular sort of event, and then return.
It is often convenient to keep a queue of future events, indexed by time, and to have a routine that creates an object representing something to be done at some future time (such as calling a method to check for the expiration of a timeout) and puts this object on the queue.
You need to worry about interrupt processing getting called halfway through an event service routine. One way to deal with this is to lock out interrupts when that could cause a problem. Another way is to have the interrupt routine do nothing more than put an object on a queue that something else will check for later, or just set a flag. Then you need only lock out interrupts when you are checking for items on the queue and removing them.
A number of communications protocols are implemented in this way. Even in a true multitasking operating system you very often don't want to have to create a new thread every time you need to create a new connection. The two main problems with this is that the code is less clear than code which has a thread per object, because stuff that naturally goes together is chopped up into loads of event service events, and if any of the event service methods burn significant amounts of cpu, the system will stall because nothing else will happen when this is going on.
I am working on NTCIP/SNMP Protocol I was able to connect to the device controller using one one of the MIBBrowser and was able to walk through the different objects(OIDS) loaded through a MIB File. However,When I do a walk over the dmsMessageTable I can see only two messages(again through object IDs) being retrieved but the Device controller has more than two messages. The Messages being retrieved are default one provided with the device.
Can anyone help in this ?
Are you using the correct primary index (the second last node of the OID)? This node corresponds to the message memory type. For changeable messages the index should be 3 or 4.
You can retrieve the number of messages for the memory type, (for example, for changeable messages use dmsNumChangeableMsg - 1.3.6.1.4.1.1206.4.2.3.5.2.0) and then the last node of your OID should correspond to the message number in that type of memory bank.
EXAMPLE:
For the first message in changeable memory:
1.3.6.1.4.1.1206.4.2.3.5.8.1.3.3.1
For the second message in volatile memory:
1.3.6.1.4.1.1206.4.2.3.5.8.1.3.4.2