Abstract:
A time control apparatus provided in a slave machine and synchronizing time information with time information of a master machine connected over a network includes: calculation units respectively calculating time difference candidates of the slave machine with respect to the master machine and network delays indicative of an average of times necessary for communication of first and second messages over the network based on transmission and reception times of the first messages which are transmitted from the master machine and received using the slave machine and transmission and reception times of the second messages which are transmitted from the slave machine and received using the master machine; a selection unit selecting one of the calculated time difference candidates as a time difference based on the calculated network delays; and an adjustment unit adjusting the time information of the slave machine based on the selected time difference.

Description:
FIELD 
     The present disclosure relates to a time control apparatus, a time control method, and a program, and, in particular, to a time control apparatus, a time control method, and a program which are suitable for being used when time information is synchronized with that of a master machine connected over a network with high precision. 
     BACKGROUND 
     In the related art, there is provided a structure in which the respective internal time information of apparatuses which are connected over a network are synchronized, and IEEE 1588 PTP (Precision Time Protocol) has been known as a representative thereof (for example, refer to JP-A-2010-190635). 
     According to IEEE 1588 PTP, by transmitting PTP messages between a master machine (hereinafter, referred to as “PTP master”) and a slave machine (hereinafter, referred to as “PTP slave”) which are connected over a network, it is possible to synchronize the time information of a PTP slave with the time information of a PTP master with a high sub-μ sec precision. In detail, an internal oscillation frequency f 2  of the PTP slave is synchronized with an internal oscillation frequency f 1  of the PTP master, and, thereafter, the time information of the PTP slave is synchronized with the time information of the PTP master. 
     Hereinafter, a process of synchronizing the internal oscillation frequency f 2  of the PTP slave with the internal oscillation frequency f 1  of the PTP master is called frequency synchronization, and a process of synchronizing the time information of the PTP slave with the time information of the PTP master is called time synchronization. 
       FIG. 1  illustrates an overview of a high-precision time synchronization process using IEEE 1588 PTP according to the related art. 
     The PTP master transmits Sync message which functions as a PTP message including a transmission time T 1   i  which is the time information of the PTP master on the network during a predetermined period Δm based on the oscillation frequency f 1 . Meanwhile, the PTP slave extracts the transmission time T 1   i  included in Sync message in response to the reception of Sync message which is transmitted from the PTP master, and reads a reception time T 2   i  which is the time information of the PTP slave. That is, the PTP slave acquires the transmission time T 1   i  and the reception time T 2   1  whenever a Sync packet is received. 
     In addition, the PTP slave transmits Delay_req message which functions as a PTP message to the PTP master over the network, and reads a transmission time T 3  which is the time information of the PTP slave. Meanwhile, the PTP master reads a reception time T 4  which is the time information of the PTP master in response to the reception of Delay_req message, and transmits Delay_res message, which functions as a PTP message including the reception time T 4 , to the PTP slave as a reply. Therefore, the PTP slave acquires the transmission time T 3  of Delay_req message from the PTP slave and the reception time T 4  of the PTP master by transmitting Delay_req message and receiving Delay_res message which is the answer in response to Delay_req message. 
     Here, it is assumed that a time which a necessary for the transmission of PTP messages, such as Sync message, Delay_req message, and Delay_res message, over the network (hereinafter, referred to as a “network delay time”) is not changed and is usually uniform. 
     Under this assumption, if the oscillation frequency f 1  of the PTP master is equal to the oscillation frequency f 2  of the PTP slave, the transmission interval of Sync message of the PTP master Δm=T 1   2 −T 1   1  is equal to the reception interval of Sync message of the PTP slave Δs=T 2   2 −T 2   1 . In other words, in a case in which the difference between Δm and Δs, that is, Δm−Δs is not 0, the case can be said that there are errors between the oscillation frequency f 1  of the PTP master and the oscillation frequency f 2  of the PTP slave, thus oscillation frequencies are not synchronized. 
     Therefore, with respect to the frequency synchronization, the oscillation frequency f 2  of the PTP slave may be adjusted such that the difference between Δm and Δs, that is, Δm−Δs (hereinafter, referred to as “frequency deviation”) is 0 in the PTP slave. The frequency deviation Δm−Δs is calculated using the following Equation 1.
 
Frequency deviation Δ m−Δs =( T 1 2   −T 1 1 )−( T 2 2   −T 2 1 )=( T 2 1   −T 1 1 )−( T 2 2   −T 1 2 )  (1)
 
     With respect to the time synchronization, time difference shown in Equation 4 may be calculated based on the transmission time T 1   2  and the reception time T 2   2  of Sync message and the transmission time T 3  and the reception time T 4  of Delay_req message in the PTP slave, and an internal clock T 2  may be adjusted such that the time difference is 0 in the PTP slave.
 
Network delay of Sync message=( T 2 2 −time difference)− T 1 2 =( T 2 2   −T 1 2 )−time difference  (2)
 
Network delay of Delay_req message= T 4−( T 3−time difference)=( T 4− T 3)+time difference  (3)
 
     It is assumed that the network delay of Sync message=the network delay of Delay_req message=uniform. Therefore, with respect to the time difference, subsequent Equation 4 is derived by subtracting Equation 3 from Equation 2.
 
Time difference={( T 2 2   −T 1 2 )−( T 4− T 3)}/2  (4)
 
     In addition, with respect to the network delay, subsequent Equation 5 is derived by adding Equation 2 to Equation 3.
 
Network delay={( T 2 2   −T 1 2 )+( T 4− T 3)}/2  (5)
 
     SUMMARY 
     However, if a high-capacity packet, such as an image signal, is flowed at high speed on a relevant network in which the PTP master is connected to the PTP slave, congestion occurs on the network, thus temporal increase may occur in the above-described network delay time of the PTP message. 
     For example, as shown in  FIG. 2 , there may be a case in which the network delay of Delay_req message (T 4   j-1 −T 3   j-1 ) increases compared to the network delay of Sync message (T 2   i-1 −T 1   i-1 ). In addition, on the contrary, there may be a case in which the network delay of Delay_req message (T 4   j −T 3   1 ) decreases compared to the network delay of Sync message (T 2   i −T 1   i ). 
     In these cases, since the above-described assumption that the network delay time of the PTP message is uniform is not realized, it is difficult to accurately perform the frequency synchronization or the time synchronization using the above-described method. 
     It is therefore desirable to enable time synchronization to be performed with a master machine on a network with high precision. 
     An embodiment of the present disclosure is directed to a time control apparatus which is provided in a slave machine and synchronizes time information with time information of a master machine connected over a network, the time control apparatus including: a plurality of calculation units that respectively calculate time difference candidates of the slave machine with respect to the master machine and network delays indicative of an average of a time which is necessary for communication of first messages over the network and a time which is necessary for communication of second messages over the network based on transmission and reception times of the first messages which are transmitted from the master machine and received using the slave machine and transmission and reception times of the second messages which are transmitted from the slave machine and received using the master machine; a selection unit that selects one of the plurality of calculated time difference candidates as a time difference based on the plurality of calculated network delays; and an adjustment unit that adjusts the time information of the slave machine based on the selected time difference. 
     The plurality of calculation units may respectively calculate the time difference candidates and the network delays based on the respective transmission/reception times of the first messages and the second messages which are combined from the plurality of first messages and the plurality of second messages which have different communication timings. 
     The plurality of calculation units may include first to third calculation units, the first calculation unit may calculate a first time difference candidate and a first network delay based on a transmission/reception time of a latest first message which is transmitted from the master machine and received using the slave machine and a transmission/reception time of a latest second message which is transmitted from the slave machine and received using the master machine, the second calculation unit may calculate a second time difference candidate and a second network delay based on a transmission/reception time of an immediately previous first message which is transmitted from the master machine and received using the slave machine and a transmission/reception time of the latest second message which is transmitted from the slave machine and received using the master machine, and the third calculation unit may calculate a third time difference candidate and a third network delay based on the transmission/reception time of the latest first message which is transmitted from the master machine and received using the slave machine and a transmission/reception time of an immediately previous second message which is transmitted from the slave machine and received using the master machine. 
     The selection unit may select the first time difference candidate as the time difference when the first network delay is less than a threshold value, may select the second time difference candidate as the time difference when the first network delay is equal to or greater than the threshold value and the second network delay is less than the third network delay, and may select the third time difference candidate as the time difference when the first network delay is equal to or greater than the threshold value and the second network delay is equal to or greater than the third network delay. 
     Another embodiment of the present disclosure is directed to a time control method of a time control apparatus which is provided in a slave machine and synchronizes time information with time information of a master machine connected over a network, the time control method including: calculating time difference candidates of the slave machine with respect to the master machine and network delays indicative of an average of a time which is necessary for communication of first messages over the network and a time which is necessary for communication of second messages over the network based on transmission and reception times of the first messages which are transmitted from the master machine and received using the slave machine and transmission and reception times of the second messages which are transmitted from the slave machine and received using the master machine; selecting one of the plurality of calculated time difference candidates as a time difference based on the plurality of calculated network delays; and adjusting the time information of the slave machine based on the selected time difference using the time control apparatus. 
     Still another embodiment of the present disclosure is directed to a program causing a computer, which is provided in a slave machine and synchronizes time information with time information of a master machine connected over a network, to function as: a plurality of calculation units that respectively calculate time difference candidates of the slave machine with respect to the master machine and network delays indicative of an average of a time which is necessary for communication of the first messages over the network and a time which is necessary for communication of the second messages over the network based on transmission/reception times of first messages which are transmitted from the master machine and received using the slave machine and transmission/reception times of second messages which are transmitted from the slave machine and received using the master machine; a selection unit that selects one of the plurality of calculated time difference candidates as a time difference based on the plurality of calculated network delays; and an adjustment unit that adjusts the time information of the slave machine based on the selected time difference. 
     In the embodiments of the present disclosure, the plurality of time difference candidates of the slave machine with respect to the master machine and the plurality of network delays each indicative of an average of the time which is necessary for communication of the first messages over the network and the time which is necessary for communication of the second messages over the network based on a plurality of combinations of the transmission/reception times of the first messages which are transmitted from the master machine and received using the slave machine and the transmission/reception times of the second messages which are transmitted from the slave machine and received using the master machine is provided. One of the plurality of calculated time difference candidates is selected as the time difference based on the plurality of calculated network delays, and the time information of the slave machine is adjusted based on the selected time difference. 
     According to the embodiments of the present disclosure, it is possible to perform time synchronization with the master machine on the network with high precision. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         FIG. 1  is a view illustrating an overview of a high-precision time synchronization process using IEEE 1588 PTP according to the related art; 
         FIG. 2  is a view illustrating an example in which network delays are changed; 
         FIG. 3  is a block diagram illustrating an example of the configuration of a time control apparatus to which the present disclosure is applied; 
         FIG. 4  is a flowchart illustrating a time adjustment process using the time control apparatus; and 
         FIG. 5  is a block diagram illustrating an example of the configuration of a computer. 
     
    
    
     DETAILED DESCRIPTION 
     Hereinafter, modes for implement the present disclosure (hereinafter, referred to as an “embodiment”) will be described in detail with reference to the accompanying drawings. 
     A time control apparatus according to an embodiment of the present disclosure is included in a PTP slave (slave machine) which synchronizes time information with time information of a PTP master in such a way as to transmit and receive a PTP message to and from the PTP master (master machine) on a network. In addition, frequency synchronization is performed in advance prior to this time synchronization, thus the oscillation frequency f 2  of the PTP slave is synchronized with the oscillation frequency f 1  of the PTP master with high precision. 
     [Example of Configuration of Time Control Apparatus] 
       FIG. 3  illustrates an example of the configuration of the time control apparatus according to the embodiment. A time control apparatus  10  calculates network delays D 1 , D 2 , and D 3  which respectively correspond to 3 types of time differences O 1 , O 2 , and O 3 , selects one of the time differences O 1 , O 2 , and O 3  based on the network delays D 1  to D 3 , and adjusts time information according to the selected time difference. 
     In addition, the time difference O 1  and the network delay D 1  are calculated based on the transmission/reception times of the latest Sync message and the latest Delay_req message. The time difference O 2  and the network delay D 2  are calculated based on the transmission/reception times of a previous Sync message and the latest Delay_req message. The time difference O 3  and the network delay D 3  are calculated based on the transmission/reception times of the latest Sync message and a previous Delay_req message. 
     The time control apparatus  10  includes subtraction units  11  and  12 . Further, the time control apparatus  10  includes a subtraction unit  13 , a division unit  14 , an addition unit  15 , and a division unit  16  as configurations used to calculate the time difference O 1  and the network delay D 1 . In addition, the time control apparatus  10  includes a delay unit  17 , a subtraction unit  18 , a division unit  19 , an addition unit  20 , and a division unit  21  as configurations used to calculate the time difference O 2  and the network delay D 2 . In addition, the time control apparatus  10  includes a delay unit  22 , a subtraction unit  23 , a division unit  24 , an addition unit  25 , and a division unit  26  as configurations used to calculate the time difference O 3  and the network delay D 3 . Furthermore, the time control apparatus  10  includes a selection unit  27 , a selection control unit  28 , and a time adjustment unit  29 . 
     The subtraction unit  11  subtracts a transmission time T 1   i  from a reception time T 2   i  of the latest Sync message which is received using the PTP slave, and outputs the result to the subtraction unit  13 , the addition unit  15 , the delay unit  17 , the subtraction unit  23 , and the addition unit  25 . 
     The subtraction unit  12  subtracts a transmission time T 3   j  from a reception time T 4   j  of the PTP master in the latest Delay_req message which is transmitted from the PTP slave, and outputs the result to the subtraction unit  13 , the addition unit  15 , the subtraction unit  18 , the addition unit  20 , and the delay unit  22 . 
     The subtraction unit  13  and the division unit  14  calculate Equation 4. That is, the time difference O 1  is calculated by subtracting (T 4   j −T 3   j ) which is the output of the subtraction unit  12  from (T 2   1 −T 1   j ) which is the output of the subtraction unit  11  and dividing the result by 2, and the time difference O 1  is output to the selection unit  27 . 
     The addition unit  15  and the division unit  16  calculate Equation 5. That is, the network delay D 1  is calculated by adding (T 2   i −T 1   i ) which is the output of the subtraction unit  11  to (T 4   j −T 3   j ) which is the output of the subtraction unit  12  and dividing the result by 2, and the network delay D 1  is output to the selection control unit  28 . 
     The delay unit  17  maintains (T 2   i −T 1   i ) which is the output of the subtraction unit  11 . When input is subsequently received from the subtraction unit  11 , the delay unit  17  outputs (T 2   i-1 −T 1   i-1 ) which is maintained until that time to the subtraction unit  18  and the addition unit  20 . 
     The subtraction unit  18  and the division unit  19  calculate Equation 4. That is, the time difference O 2  is calculated by subtracting (T 4   j −T 3   j ) which is the output of the subtraction unit  11  from (T 2   i-1 −T 1   i-1 ) which is the output of the delay unit  17 , and dividing the result by 2, and the time difference O 2  is output to the selection unit  27 . 
     The addition unit  20  and the division unit  21  calculate Equation 5. That is, the network delay D 2  is calculated by adding (T 2   i-1 −T 1   i-1 ) which is the output of the delay unit  17  to (T 4   j −T 3   j ) which is the output of the subtraction unit  11  and dividing the result by 2, and the network delay D 2  is output to the selection control unit  28 . 
     The delay unit  22  maintains (T 2   j −T 1   j ) which is the output of the subtraction unit  12 . When input is received from the subtraction unit  12 , the delay unit  22  outputs (T 2   j-1 −T 1   j-1 ) which is maintained until that time to the subtraction unit  23  and the addition unit  25 . 
     The subtraction unit  23  and the division unit  24  calculate Equation 4. That is, the time difference O 3  is calculated by subtracting (T 4   j-1 −T 3   j-1 ) which is the output of the delay unit  22  from (T 2   i −T 1   i ) which is the output of the subtraction unit  11  and dividing the result by 2, and the time difference O 3  is output to the selection unit  27 . 
     The addition unit  25  and the division unit  26  calculate Equation 5. That is, the network delay D 3  is calculated by adding (T 2   i −T 1   i ) which is the output of subtraction unit  11  to (T 4   j-1 −T 3   j-1 ) which is the output of the delay unit  22  and dividing the result by 2, and the network delay D 3  is output to the selection control unit  28 . 
     The selection unit  27  selects any one of the time difference O 1  which is input from the division unit  14 , the time difference O 2  which is input from the division unit  19 , and the time difference O 3  which is input from the division unit  24  under the control of the selection control unit  28 , and outputs the selected time difference to the time adjustment unit  29  as time difference O′. 
     The selection control unit  28  controls a selection process performed using the selection unit  27  based on the network delay D 1  which is input from the division unit  16 , the network delay D 2  which is input from the division unit  21 , and the network delay D 3  which is input from the division unit  26 . 
     The time adjustment unit  29  adjusts the internal time information of the PTP slave such that the time difference O′ which is input from the selection unit  27  is 0. 
     [Operation Description] 
     Subsequently, the operation of the time control apparatus  10  will be described.  FIG. 4  is a flowchart illustrating the time adjustment process performed using the time control apparatus  10 . 
     The time adjustment process is periodically performed at predetermined intervals. In addition, it is assumed that the frequency synchronization is performed prior to the time adjustment process. 
     In step S 1 , the subtraction unit  11  calculates and outputs (T 2   i −T 1   i ). The subtraction unit  12  calculates outputs (T 4   j −T 3   j ). 
     In step S 2 , the subtraction unit  13  and the division unit  14  calculate the time difference O 1 ={(T 2   i −T 1   i )−(T 4   j −T 3   j )}/2 and output the result to the selection unit  27 . The subtraction unit  18  and the division unit  19  calculate the time difference O 2 ={(T 2   i-1 −T 1   i-1 )−(T 4   j −T 3   j )}/2 and outputs the result to the selection unit  27 . The subtraction unit  23  and the division unit  24  calculates the time difference O 3 ={(T 2   i −T 1   i )−(T 4   j-1 −T 3   j-1 )}/2 and outputs the results to the selection unit  27 . 
     In step S 3 , the addition unit  15  and the division unit  16  calculate the network delay D 1 ={(T 2   i −T 1   i )+(T 4   j −T 3   j )}/2 and output the result to the selection control unit  28 . The addition unit  20  and the division unit  21  calculate the network delay D 2 ={(T 2   i-1 −T 1   i-1 )+(T 4   j −T 3   j )}/2 and output the result to the selection control unit  28 . The addition unit  25  and the division unit  26  calculate the network delay D 3 ={(T 2   i −T 1   i )+(T 4   j-1 −T 3   j-1 )}/2 and output the result to the selection control unit  28 . 
     In addition, in actual fact, the process in step S 2  and the process in step S 3  are performed at the same time. 
     In step S 4 , the selection control unit  28  determines whether or not the network delay D 1  is less than a predetermined threshold value. If a result of the determination is affirmative, the process proceeds to step S 5 . In step S 5 , the selection unit  27  selects the time difference O 1  which is input from the division unit  14  under the control performed using the selection control unit  28 , and outputs the selected time difference O 1  to the time adjustment unit  29  as the time difference O′. 
     If the result of the determination performed in step S 4  is negative, the process proceeds to step S 6 . In step S 6 , the selection control unit  28  determines whether or not the network delay D 2  is less than the network delay D 3 . If a result of the determination is affirmative, the process proceeds to step S 7 . In step S 7 , the selection unit  27  selects the time difference O 2  which is input from the division unit  19  under the control performed using the selection control unit  28 , and outputs the selected time difference O 2  to the time adjustment unit  29  as the time difference O′. 
     If the result of the determination performed in step S 6  is negative, the process proceeds to step S 8 . In step S 8 , the selection unit  27  selects the time difference O 3  which is input from the division unit  24  under the control performed using the selection control unit  28 , and outputs the selected time difference O 3  to the time adjustment unit  29  as the time difference O′. 
     In step S 9 , the time adjustment unit  29  adjusts the internal time information of the PTP slave such that the time difference O′ which is input from the selection unit  27  is 0. As above, the time adjustment process is terminated. 
     According to the above-described time adjustment process, if the network delay D 1 , which is calculated based on the latest Sync message and the transmission/reception time of the latest Delay_req message which are considered that a communication timing is the nearest, that is, variation in the network delays is the least, is less than the threshold value, time information is adjusted based on the time difference O 1 . 
     In addition, if the network delay D 1  is equal to or greater than the predetermined threshold value, the network delay D 2 , which is calculated based on the previous Sync message and the transmission/reception time of the latest Delay_req message, is compared with the network delay D 3 , which is calculated based on the latest Sync message and the transmission/reception time of the previous Delay_req message. Thereafter, the time information is adjusted based on the time difference O 2  or O 3  which corresponds to the lesser. 
     That is, according to the time adjustment process, since the time difference, which corresponds to the combination of the Synch message having less change in the network delay and the Delay_req message, is selected and used to adjust the time, it is possible to synchronize the time information of the PTP slave with the time information of the PTP master with high precision compared to the related art. 
     In addition, if the network delay D 1  is equal to or a greater than the predetermined threshold value and the lesser of the network delay D 2  and the network delay D 3  is greater than the predetermined threshold value, the time difference O′ may not be output to the time adjustment unit  29  and the adjustment of the time information may be postponed until a subsequent time adjustment process. 
     Further, for example, the network delays D 1  to D 3  are compared and the time difference corresponding to the minimum thereof may be set to the time difference O′. 
     In addition, although the time difference and the network delay are calculated by combining the latest Sync message with the first Delay_req message or the latest Delay_req message with the previous Sync message in the embodiment, the present disclosure is not limited thereto. For example, the time difference and the network delay may be calculated by combining the latest Sync message with an n-th Delay_req message or the latest Delay_req message with the n-th previous Sync message. 
     Further, although the time difference O′ is selected from among the calculated three types of time difference, O 1  to O 3  in the embodiment, four or more types time difference may be calculated and the time difference O′ may be selected therefrom. 
     Meanwhile, a series of processes performed using the above-described time control apparatus  10  can be performed using hardware and software. When the series of processes is performed using software, a program included in the software is installed in a computer. Here, the computer includes a computer which is incorporated with dedicated hardware or, for example, a general-purpose personal computer which can perform various types of functions by installing various types of programs. 
       FIG. 5  is a block diagram illustrating an example of the configuration of the hardware of the computer which performs the above-described series of processes using a program. 
     In the computer, a Central Processing Unit (CPU)  101 , a Read Only Memory (ROM)  102 , and a Random Access Memory (RAM)  103  are connected to each other via a bus  104 . 
     Further, an input/output interface  105  is connected to the bus  104 . An input unit  106 , an output unit  107 , a storage unit  108 , a communication unit  109 , and a drive  110  are connected to the input/output interface  105 . 
     The input unit  106  includes a keyboard, a mouse, and a microphone. The output unit  107  includes a display, and a speaker. The storage unit  108  includes a hard disk and a nonvolatile memory. The communication unit  109  includes a network interface. The drive  110  drives a removable media  111  such as a magnetic disc, an optical disc, a magneto-optical disk, or a semiconductor memory. 
     In the computer which is configured as described above, the above-described series of processes is performed in such a way that the CPU  101  loads a program stored in, for example, the storage unit  108  to the RAM  103  and executes the program via the input/output interface  105  and the bus  104 . 
     The program executed using the computer (CPU  101 ) can be recorded in the removable media  111  which functions as, for example, a package media, and can be provided. In addition, the program can be provided via a wired or wireless transmission media such as a local area network, the Internet, and digital satellite broadcasting. 
     In the computer, the program can be installed in the storage unit  108  via the input/output interface  105  by mounting the removable media  111  on the drive  110 . In addition, the program can be received using the communication unit  109  via a wired or wireless transmission media, and can be installed in the storage unit  108 . In addition, the program can be installed in the ROM  102  or the storage unit  108  in advance. 
     In addition, the program which is executed using the computer may be a program, the process of which is performed in chronological order according to the order described in the present specification, and may be a program, the process of which is performed in parallel or at a necessary timing that a call is made. 
     In addition, the embodiment of the present disclosure is not limited to the above-described embodiment, and various types of modifications are possible without departing the gist of the present disclosure. 
     The present disclosure contains subject matter related to that disclosed in Japanese Priority Patent Application JP 2012-011711 filed in the Japan Patent Office on Jan. 24, 2012, the entire contents of which are hereby incorporated by reference. 
     It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and alterations may occur depending on design requirements and other factors insofar as they are within the scope of the appended claims or the equivalents thereof.