I have a standalone box without an RTC. It does have a millisecond tick timer though, which is accurate.
I am sending, via a USB UART port to a Windows machine. I can also write to the box via the same way from the Windows machine.
When I receive the bytes sent by the box via the serial port, there is a noticable delay. That delay is something like 16ms, and that is not something that can be fixed on Windows.
So, given data sent from the box, how can I, the Windows machine, know what exact millisecond the box sent it, despite the delay, syncing it to a real timestamp?
I could send the current milliseconds that the box counts with the data, but then that would be outdated by the time it is received.
For example:
at 10ms, the box sends data.
the Windows machine receives the data 20ms later due to delay or whatever.
Windows then has to assume the box sent the data at 30ms, but it should be 10ms.
I tried sending the current box ms on each data sending, but then I do not know how much time has passed.
A simple solution is to send a message and reply and count the total time for the two-way round trip, and then subtract half of it.
Eg:
clockless box sends "what time is it?" message and records the value of its tick counter when it sends the message as #1234.
Host sends back "it's 11:59:59.999".
clockless box receives this message when its tick counter says #1250.
The clockless box knows that the time 11:59:59.999 equates to somewhere between tick #1234 and tick #1250.
The clockless box assumes that 11:59:59.999 equates to half-way between these ticks, so it adjusts its software RTC to make tick #1242 equals 11:59:59.999.
Related
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
I have a requirement as stated # https://kafka.apache.org/21/documentation/streams/developer-guide/dsl-api.html#window-final-results for waiting until window is closed in order to handle late out of order event by buffering it for duration of window.
Per my understanding of this feature is once windowing is created, the window works like wall clock processing, e.g. Creating for 1 hour window, The window starts ticking once first event comes. This 1hr window is closed exactly one hour later and all the events buffered so far will be forwarded to down stream. However, i need to be able to hold this window even longer say conditionally for as long as required e.g. based on state / information in external system such as database.
To be precise my requirement for event forwarding is (windows of 1 hour if external state record says it is good) or (hold for as long as required until external record says it's good and resume tracking of the event until the event make it fully 1hr, disregarding the time when external system is not good)
To elaborate this 2nd condition, e.g. if my window duration 1 1hr , my event starts at 00:00, if on 00:30 it is down and back normal on 00:45, the window should extend until 01:15.
Is it possible to pause and resume the forwarding of events conditionally based on my requirement above ?
Do I have to use transformation / processor and use value store manually to track the first processing time of my event and conditionally forwarding buffered events in punctuator ?
I appreciate all kind of work around and suggestion for this requirement.
the window works like wall clock processing
No. Kafka Streams work on event-time, hence, the timestamps as returned from the TimestampExtractor (by default the embedded record timestamp) are use to advance time.
To be precise my requirement for event forwarding is (windows of 1 hour if external state record says it is good)
This would need a custom solution IMHO.
or (hold for as long as required until external record says it's good and resume tracking of the event until the event make it fully 1hr, disregarding the time when external system is not good)
Not 100% if I understand this part.
Is it possible to pause and resume the forwarding of events conditionally based on my requirement above ?
No.
Do I have to use transformation / processor and use value store manually to track the first processing time of my event and conditionally forwarding buffered events in punctuator ?
I think this might be required.
Check out this blog post, that explains how suppress() work in details, and when it emits based on observed event-time: https://www.confluent.io/blog/kafka-streams-take-on-watermarks-and-triggers
I have a computer (that use as server) and several board with Atmega microcontroller Something like:
The computer connect to board on UART & RS485 (with a USB to RS485 converter)(I have limitation that lead to I could not use ModBus). I want to broadcast a message from server over bus and fetch the ID from of each board (Board ID is 4 digit).
When the boards receive broadcast message and try to send their own ID and the server receive some fake ID and I think it related to Collisions problem when all boards want to send data in one time.
After I search about this problem found a way that put a constant in each board that save a special delay for send data and when board receive broadcast message send ID with that delay...in this way it work fine and I dont see the Collisions but have some problem:
May be the delay number of 2 board be same.
Good way for small count of board.
Extra process when want to install board on bus.
Anybody know with this problem and could help me how to solve this problem with better solution?
You are mentioning Modbus in your question although some of your other stated facts seem to deviate from there (like 4-digit device numbers, and Modbus only has 1-255). Also, Modbus does not support responses to broadcast messages. I thus doubt a bit you are actually using Modbus.
A scheme you could use (and that is classically used in MA networks) would be:
Once a broadcast is received, have the clients scan the bus for responses for a time frame based on its station ID. If your client can see one, have it wait a minimum bus time (the time a module needs to answer your broadcast message based on current bus timing + the round trip for the master acknowledging the broadcast answer) plus an additional time based on its module ID, then go back to (1)
If a client sees the bus unoccupied for the specified time, send back a broadcast answer.
Have the master acknowledge the broadcast response from this client with the shortest possible message.
If a client that has sent a broadcast response does not receive a proper ack, go back to (1)
This is not 100% secure and absolutely not according to the Modbus specification, but could work.
* is a transmission, - is a "wait"
**** (Bus master broadcast)
--------- station 100 waits 100ms
------------------ station 200 waits 200ms
**** Station 100 sends broadcast response
------------------ station 200 sees bus active and waits another 200ms
*** master acknowledges broadcast response of 100
------------------ station 200 sees bus active again and waits 200ms from last seen activity
**** Station 200 has seen bus quiet for 200ms and sends broadcast response
*** master acks brc response of 200
This can take quite a bit of time and needs the waiting times finely adjusted against the transmission time of broadcast responses and response acks, but can work, and actually is implemented that way in a lot of CSMA/CD networks.
It will probably take longer, but here is another way to do it. First, design your protocol so that each command contains (or an can contain) an ID, and boards only respond to commands for their ID. Then, on your host, you would iterate through each of the possible IDs and send a simple command to each of them. If you get a response, you know there is a board with that ID. If you don't get a response after some period of time, you know there is no board there.
I created a application that will send a data by bluetooth using a GKsession from background.
It is woking to send a data but , data sending will finish even i recall the function ever 30seconds. Is there any way to continue for more longer time?
Or is there an any limit for Iphone or BTM?
Don't know if there's any enforced limit but it's a good practice to define a ping function to broadcast a small message to all connected peers at a small interval like 15 seconds.
When using an old style analogue or ISDN telephone, the dialing of a number is not closed to the end. There is no signal the number is complete and finished. However, adapters and such enable old phones for VoIP using SIP.
As I understand, the SIP request headers contain the whole client address or number.
How then is a SIP session established without knowing if the dialed number is complete?
SIP (per se) doesn't say anything about when calls are made or dialing, that's entirely up to the device or program. Most ATAs act like traditional POTS phones connected to a switch, and dial off a completed dial-plan entry that matched (like 1-212-345-6789 or 911 or 411), or when a time since the last digit has elapsed (though most of those will end up forwarded to the "you've dialed an invalid number, please try again" message or beeps). True IP phones often function closer to a cellphone (or cordless phone) model, with a "call" or "dial" button.
In many devices the dial-plan is programmable, sometimes by the user, other times (more often) by the service provider (Vonage, etc), in a few by either party.
Depending on the dial-plan, it may do more or less validation of the number being dialed in the matching (like checking for valid area-code digits or not, etc).
by guessing. If there comes no additional digit within a certain number of seconds, the call will be made. Often you can speed up this by terminating your number with a # or similiar.
glglgl's guess is correct, a SIP device only initiates a call once it has acquired the full number it needs to use. SIP uses URIs in call requests which are very similar to email addresses and in the same manner that sending an email to a partial address is likely to fail initiating a call with a partial SIP URI is also likely to.
As to how SIP devices recognise when the user has completed the number it's normally done with a timeout, for example no more keys pressed within 10 seconds, or by the user pressing a "Send" key which as glglgl also alludes to will often be the # key on phones connected to an ATA. IP Phones typically have a "Send" or "Dial" button.
Some ATAs do allow you to adjust the timeout to detect when a user has completed dialling. I know the original Sipura ATAs (now owned by Cisco) allowed the delay to be configured in their internal dialplan.