Recently began to play the Dream Hand tour, in order to lead a front-end tour of the rebate must enter the general order, that has been a year useless, entered a few times prompt error (later confirmed that the system is busy only), I thought it was the general to make the time is wrong, so with the Xia Guan Network repair function. Also to the general to repair the principle of interest, so searched the following article, very detailed on the general order principle of speculation, feeling nine out of ten is right, after reading the feeling is very simple a function, let me think for a moment also unexpectedly.
Several key points to organize:
1. Use fixed serial number to ensure the uniqueness of the output code, time to ensure the dynamic
2. The general makes its own time accuracy is the basis, for example, within 1 weeks of error more than 1 hours I feel can accept (mainly see corrective mechanism)
3. Server output code time to add time correction factor t, T will be in the verification by the upper and lower y seconds to rectify, or player point repair to large-scale matching before and after the code to rectify, the first time is through the Code matching correction
4.3rd ensure that players use t automatically corrected, long-term non-use (if the difference is beyond the automatic correction range) to start a large-scale correction before and after the code
"Reprinted from" http://xy2.zhidao.163.com/showtopic/id_2014/
How the General Order works: conjecture
General order to protect the game ID in the form of account + password + dynamic password Well known, the general makes every minute change 6-digit password, commonly known as dynamic password.
Since the client (General order) in the factory, the same server side there is no physical direct connection, so, how to maintain logical synchronization with the server is the biggest problem, that is, how to ensure that the client generated dynamic password and server-side authentication dynamic password is a password?
Guess: The dynamic password generated by the client is a time-related dynamic password, that is, the relationship between the password M and the time t: M=rand (TX), Rand () is a random function, TX is the seed of a random function, X is another factor, such as the serial number of the order.
(1) X is a server-side known variable, the factory has been set up, the largest may be the general order of the serial number, service number or serial number corresponding to a factor, in the production of general order to write the initial data, the same time to the client and server, because each general order the serial number and service number is unique, thus, If you don't get the general order, you won't know X, and you won't know the dynamic password M.
Obviously, only the factor X is not enough, M=rand (x), is produced by a cipher M, but obviously cannot be changed dynamically and loses its meaning. Thus the factor T is indispensable.
(2) analysis, after the implantation of T, the server side of the T1 by the server-side clock, the user-side T2 affected by the user-side clock, the problem arises, how to ensure that after a period of time, T1=t2? One method is to use high-precision materials, to ensure that in 3 years of time t1=t2, significant cost, to the market about 30 yuan of electronic watches for example, to ensure that thousands of electronic watches 3 years of error within 1 minutes, can be said to be implausible.
(3) Assume: Server-side fixed T0, introducing factor T, server-side implantation t, T is the difference between the user-side clock and the server-side clock, that is, t=t2-t1. In this way, the client (general order) side of the password M=rand (t2x), server-side password m=rand[(t1+ t) X], so that for thousands of users (general order) on the server side as long as the record T, it is OK. This t can be recorded at the time the general made the production by implanting the server side.
(4) The problem of synchronization can be solved in this way, the server-side dynamic adjustment T. At the time of opening the military orders, when submitting serial number and dynamic password, the server side calculates m=rand[(t1+ T) X], and on the basis of T, calculates ..., t-5*60, t-4*60, t-3*60, t-2*60, t-1*60, t, t +1*60, t+2*60, t+3*60, t+4*60, t+5*60,... This sequence. The length of the sequence is based on the need, because it is a random 6-digit function, there is no repetition of m in this sequence. In this way, it is possible to calculate the difference in the number of n minutes around T to generate the password m, just than the dynamic password submitted to which the value of the sequence corresponding, you can dynamically adjust T. Assuming that the dynamic password is the same as the t-2*60 corresponding to the password, you can adjust the t= t-2*60. This solves the time error caused by the user-side (General order) from the factory to the open use. This n, according to the actual needs of the establishment, if the factory 1 months after a few hours, it will be the quality of military orders is very bad.
(6) After determining the T, the server side at each verification time, as long as the calculation of m1=rand[(t1+ t-y) x],m=rand[(t1+ t) x],m2=rand[(t1+ t+y) X], you can calculate the time of the Y-second near T, the password M, is to allow the general to make a time error of y seconds. In concrete use, some have been tested to prove that the general order has a time error. If the server-side m is not the same as the general order m, but the server side of the M1 with the general Order of M, you can dynamically adjust the t= t-y in real time, to achieve the general order with the server-side time synchronization.
(7) The principle of electronic meter: in the role of direct current (battery), through the transistor, tuning fork, quartz crystal, LSI and so on as the oscillator to generate a certain frequency of vibration, through a fixed frequency of vibration to drive the motor, or drive the LCD screen and so on timing. The key parts of the system are energy (batteries), oscillators, performance parts. To Quartz watch, for example, the quartz crystal on the surface of a certain voltage, quartz crystal will produce a fixed frequency of vibration, through the crossover drive motor, driving the pointer rotation, because the frequency fixed, the rotation of the pointer is constant, as long as the crossover adjustment to the same time, it can be timed. Therefore, electronic watch timing is accurate key to see the battery, the quality of the oscillator, when I was small when the electronic watch without electricity or change the battery, is usually not allowed, is affected by the battery voltage changes ...
I think:
1, irreversible algorithm, this is easy to achieve, the field of mathematics can be found a lot of random functions too much too.
2, the seed is synchronized with the server, corresponding to the TX in my formula, the server and the client can be implanted simultaneously.
3, dynamic password refresh every minute. The implant time factor is OK.
4, the key issue is still synchronization. From the former stage of NetEase to withdraw from the general to repair measures, it should be "to remind players to actively assist the time", with the new opening will be almost the same reason. and adjust frequent problems, you can also use the algorithm to change the frequency adjustment, reduce the burden on the server.
5, the method of synchronization also some, if you want to use, you can use the "Wireless Control Chronograph Clock", the principle is the standard Time service center will be the standard Time signal encoding, the use of radio long wave sent out, the table to receive time signal decoding, adjust the time, to ensure that the table end and time of the timing center is highly consistent.
"Reprint" General NetEase make work principle