ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have been tasked to look for ways to synchronize data being received in main and standby systems. I have 3 sensors which are pushing the data packets in main and standby PCs in serial format in a one-way transmission. The data stream is being fed to both the main and standby systems are are supposed to be identical.
I have to write an algorithm in C to compare the data being received in the main and standby PCs and check for any differences in the two streams(They are supposed to be exactly the same).
Also, how do i go about the taking over mechanism of standby PC in case of failure in main pC?
Did you work something out yourself already?
You should start drawing it out; What do you have already? How would you move forward? What are the challenges, and how do you think to overcome them?
This pretty much sounds like a homework assignment (being the specific language you have to use and the information provided)
Although it seems like overkill, it is better to use existing clustering tools than to try to put something ad-hoc together yourself. You would have to find and debug all the race conditions at startup and shutdown, for example.
I had worked on the prequel of this algorithm wherein i was tasked to develop an algorithm to sniff a data packet and extract the timestamp and other info out of it. This extracted data from the packets will be now fed to another system in a serial format (ethernet) and my task now is to check whether the data being received in these 2 systems (after splitting) is identical or not. Also, the data going out of the systems after processing is identical or not.
I have not worked on this kind of assignment before and looking for suggestions to start sir. I have to look for ways to :-
1. Split the data in 2 identical streams.
2. Check the data at output of the processing programs in both main and standby systems and ensure that the two outputs are identical.
3. Look for ways for auto-takeover of standby system in case of main system failure.
4. look for ways of standby system synchronisation with main system in case of its restarting.
I hope to receive the right direction from you sir.
Although it seems like overkill, it is better to use existing clustering tools than to try to put something ad-hoc together yourself. You would have to find and debug all the race conditions at startup and shutdown, for example.
I agree that this smells very strongly of "[do not do a ...] thing already done," but one technique that is commonly used in data communication is Cyclic Redundancy Check (CRC). As bytes come in, you can count them and update a CRC. Separately remember what the CRC value was at the latest, say, 100th packet; keep a rolling history of those. Those tallies should be the same.
It's also useful, and almost always done, to calculate a CRC as part of each packet that is sent or received, so that a message can be recognized as garbled as soon as it arrives. (It is possible to correct some errors in this way.)
Again, though ... "you're not the first person on Planet Earth to have tackled this problem, so don't waste much time trying to invent a new one." Instead, look for existing solutions, which might well be more thorough and complete than any you have yet thought of.
I agree that this smells very strongly of "[do not do a ...] thing already done," but one technique that is commonly used in data communication is Cyclic Redundancy Check (CRC). As bytes come in, you can count them and update a CRC. Separately remember what the CRC value was at the latest, say, 100th packet; keep a rolling history of those. Those tallies should be the same.
It's also useful, and almost always done, to calculate a CRC as part of each packet that is sent or received, so that a message can be recognized as garbled as soon as it arrives. (It is possible to correct some errors in this way.)
Again, though ... "you're not the first person on Planet Earth to have tackled this problem, so don't waste much time trying to invent a new one." Instead, look for existing solutions, which might well be more thorough and complete than any you have yet thought of.
Thanx Sundialsvcs....I have never used CRC before and need some clarity on its implementation sir.
I have a custom packet coming from a sensor. Its configuration is :-
so you get a char[22] (one char is one byte, and you start at 0);
Most likely byte 22 is a CRC; See what kind of correlation the data has with the first 21 bytes.
And then try to find out on the interwebs what a CRC is, there's so much documentation in that regard, that I'll not reinvent that and write it down here.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.