Abstract:
Measuring latency in computer systems, such as electronic trading systems, communicating with a plurality of clients by means of multicasting via a communication network. A sending host has a sending application adapted to distribute messages to a receiving application of a receiving host of a client. The method includes: providing a message to be sent from the sending application to the receiving application with a time stamp indicating the point of time the message was sent; transferring the message together with the time stamp from a multicast framework of the sending host to a multicast framework of the receiving host; extracting the time stamp from the message when the message is received by a receiving application of the receiving host; and comparing the point of time indicated by the extracted time stamp with a current time of the receiving host in order to calculate a latency for the message.

Description:
TECHNICAL AREA  
       [0001]     The present invention generally relates to computer networks using multicast techniques such as electronic trading systems for trading stocks, bonds, futures, options and other financial instruments as well as betting and e-gaming, and in particular to methods, systems, computer readable mediums and computer program products for such systems.  
       BACKGROUND OF THE INVENTION  
       [0002]     During the last decade, almost all the world&#39;s exchanges and marketplaces have introduced electronic trading systems. These systems either replace the traditional trading floors or are used as complements to them. Today a large number of exchanges throughout the world utilize electronic trading to trade stocks, bonds, futures, options and other financial instruments. These electronic exchanges generally include three basic components, namely server computers (host), communication servers, and the exchanges participants&#39; computers (client). The host constitutes, so to speak, the heart of the electronic trading system. The hosts operations includes, for example, order-matching, maintaining order books and positions or price information. Participants, e.g., traders, are capable of communicating with the host by means of high speed data lines, high speed communications servers and the Internet. Thus, the traders can participate in the market by means of the clients communicating with the host.  
         [0003]     A fundamental property of such financial messaging networks is the ability to deliver information from one sender, for example, the host, to a large number of recipients, for example, the clients. This introduces the need for multicasting technologies in order to avoid the high bandwidth requirements that would be the result of a plurality of point-to-point connections (i.e. sending the message once for each recipient).  
         [0004]     One important quality measure in a transaction-oriented environment, such as an electronic trading system, is the latency of transactions, i.e. the length of time (usually measured in seconds or milliseconds) between the point of time the message was submitted for publishing by a sending application to the point of time that particular message was received by the receiving application. Or in other words, the travelling time for the message from the sender to the receiver. This is often expressed as an average latency (e.g. 50 milliseconds) for a large number of transactions, or as a confidence interval (95% of the transactions have a latency of less than 50 milliseconds). In order to measure the latency, the time the transactions was sent and the time it was received must be compared. The latency is calculated as the difference between these two points of time. If the processing times in the sending and receiving applications are negligible, the latency is approximately the same as the network latency, i.e. the period of time required for transferring one message (transaction) from the sending host to the receiving host.  
         [0005]     However, if the nature of the communication protocol adds waiting times in the sender and/or the receiver, the network latency is not a good approximation of the perceived latency for the entire transaction. A “reliable multicast” protocol is especially susceptible to waiting times since messages may be queued while waiting for re-transmission in order to maintain a reliable, gap-free, stream of messages.  
         [0006]     Thus, there is need of an improved method and system for measuring latency in a more reliable and accurate way in such multicast system.  
       SUMMARY OF THE INVENTION  
       [0007]     The present invention includes an improved approach to measuring latency in a more reliable and accurate way in multicast systems. In its various embodiments, the present invention provides a system, a method, a computer program, and a computer readable medium that take advantage of this new approach.  
         [0008]     In the context of the present invention, the term “latency” refers to a period of time (usually measured in seconds or milliseconds) between a message being submitted for publishing by the sending device until the same message is received by the receiving device.  
         [0009]     In connection with this application, the term “reliable multicast” refers to a mechanism where a message is broadcasted to a multiple recipients at the same time, but where the implementation also guarantees that all messages reach the recipients in due order and without gaps.  
         [0010]     According to a first aspect of the present invention, there is provided a method for measuring latency in a computer network system communicating with a plurality of clients by means of multicasting via a communication network, which system comprises a sending host including a sending application adapted to distribute messages to a receiving application of a receiving host of a client. The method includes providing a message to be sent from the sending application to the receiving application with a time stamp indicating the point of time the message was sent; transferring the message together with the time stamp from a multicast framework of the sending host to a multicast framework of the receiving host; extracting the time stamp from the message when the message is received by a receiving application of the receiving host; and comparing the point of time indicated by the extracted time stamp with a current time of the receiving host in order to calculate a latency for the message.  
         [0011]     According to a second aspect of the present invention, there is provided a system for measuring latency in a computer network system communicating with a plurality of clients by means of multicasting via a communication network, which system comprises a sending host including a sending application adapted to distribute messages to a receiving application of a receiving host of a client. The sending host comprises a multicast framework including a message generating means adapted to generate a message to be sent from the sending application to the receiving application having a time stamp indicating the point of time the message was sent, wherein the framework is adapted to send the message together with the time stamp to a multicast framework of the receiving host; and the receiving host comprises latency calculating means adapted to extract the time stamp from the message when the message is sent to the receiving application; and compare the point of time indicated by the extracted time stamp with a current time of the receiving host in order to calculate a latency for the message.  
         [0012]     According to third aspect of the present invention, there is provided a computer program product, which when executed on a computer, performs the method according to the first aspect of the present invention.  
         [0013]     According to a further aspect of the present invention, there is provided a computer readable medium comprising instructions for bringing a computer to perform the method according to the first aspect of the present invention.  
         [0014]     Thus, the invention is based on the idea of identifying when a message actually is sent from the sending application of the sending host and, on the receiving end, identifying when the same message actually is received by the receiving application. Thereby, it is possible to obtain a good approximation of the total latency for a message, i.e. the network latency as well as the latency caused by waiting times in the sending queue and the receiving queue. This can be achieved by providing selected messages with time stamps, which time stamps can be used to calculate the total latency. Accordingly, the solution according to the present invention provides a reliable and accurate measure of the total latency in comparison with the conventional technique where, in practice, only the network latency is measured since the waiting times for a message cannot be estimated in a reliable way. Messages can be queued in the sender before transmission and can also be queued in the receiver while waiting for re-transmission to fill a “gap” in the sequence where a previous message has been lost. The time spent in these queues depends on, inter alia, the network bandwidth and the quality of the network as well as performance of the sending host and the receiving host. Consequently, another advantage of some embodiments of the present invention is that it is possible to obtain a approximation of the latency that is not affected by network parameters such as the network bandwidth, the quality of the network or the performance of, for example the sending host and the receiving host. A good approximation of the latency provides a useful information for configuration of, e.g. the multicast framework and the network. For example, whether the network bandwidth should be changed or whether the queue sizes of the sender queue and the receiver queue should be changed, etc. Another advantage with the present invention is that the latency can be measured without any substantial increase in processing load due to the fact that only selected messages are provided with time stamps. That is, the calculation of the latency may be only performed on these selected messages.  
         [0015]     In a preferred embodiment of the present invention, heartbeat messages are injected into the same message stream as the application messages are used. Thus, these heartbeat messages are subjected to queuing in the sender and the receiver. Moreover, they are also sequence-numbered, which entails that if a heartbeat message is lost in the network it will be subject to gap detection and re-transmission in the same way as regular (application) messages. In fact, the message processing logic in the frameworks is unaware of the message content and does not treat heartbeats differently than other messages. In one embodiment, the heartbeat messages are sent out at regular intervals, for example, one each second.  
         [0016]     According to an embodiment, an internal clock of the sending host and an internal clock of the receiving host are synchronized. Alternatively, a time difference between the internal clock of the sending host and the internal clock of the receiving host can be regularly measured. Thereby, it is possible to obtain a very good approximation of the latency.  
         [0017]     As realized by the person skilled in the art, the methods of the present invention, as well as preferred embodiments thereof, are suitable to realize as a computer program or a computer readable medium.  
     
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0018]     In the following description of an embodiment of the invention, reference will be made to the accompanying drawings of which:  
         [0019]      FIG. 1  is a general view of a conventional electronic trading system in which the present invention may be implemented;  
         [0020]      FIG. 2  schematically shows a sending host and a receiving host of a multicast environment according to an embodiment of the present invention;  
         [0021]      FIG. 3  schematically shows the general principles of the method for measuring latency in a multicast environment according to the present invention; and  
         [0022]      FIG. 4  schematically shows another embodiment of the present invention. 
     
    
     DETAILED DESCRIPTION OF THE INVENTION  
       [0023]     In the following there will be discussed preferred embodiments of the method and system for measuring latency in a computer network using a multicasting service, such as an electronic trading system. As the skilled man realizes, the invention can be implemented in any computer network employing a multicasting technology even if the invention in the context of this application is described as being implemented within the contents of an electronic trading system.  
         [0024]     With reference first to  FIG. 1 , a conventional electronic trading system in which the present invention can be implemented will be discussed. A number of clients, here indicated by client A  12   a , client B  12   b , and client C  12   c , communicate with the trading or exchange system  10 . Thus, traders can participate in the market by means of the clients  12   a - 12   c  communicating with the exchange system  10  via a communication network  15 . The clients  12   a - 12   c  may link to the system  10  via high speed data lines, high speed communication servers, or the Internet. High speed data lines establish direct connection between a client and the system. Connection can also be established between the client and the system by configuring high speed networks or communication servers at strategic access points in locations where traders physically are located. The Internet is a third communication means enabling traders, using, for example, the clients  12   a - 12   c , to communicate with system  10  using, for example, high speed data lines connected to the Internet. Hence, traders are allowed to be located anywhere they can establish a connection to the Internet.  
         [0025]     The system  10  comprises a receiving gateway  14  arranged to receive incoming messages or transactions, for example, an order to buy a stock at a defined price from the clients  12   a - 12   c . Thereafter, the transactions are sent by the receiving gateway  14  to a processing means  16  containing business logic where the transactions are processed in accordance with the logic. The results are, in turn, sent further on to a publisher gateway  18 , which publishes the results. The functions and design of the processing means, as well a the receiving gateway and the publisher gateway, are not described in further detail herein as they are well known to the man skilled within the art. The publisher gateway  18  may, for example, be adapted to send messages containing results of a processed incoming transaction from one clients  12   a - 12   c  back to all the clients  12   a - 12   c . This kind of communication with the clients is preferably performed by means of a multicasting technology, which will be explained in more detail hereinafter.  
         [0026]     Turning now to  FIG. 2 , one embodiment of system for measuring latency in a multicast environment according to the present invention will be described. The system  20  comprises at least one sending host  21  and at least one receiving host  22  communicating via a communication network  25 . The system  20  may be an electronic trading system such as that described above with reference to  FIG. 1 , the sending host  21  may be a publishing means such as that described above with reference to  FIG. 1  and the receiving host  22  may be located at a client  12   a - 12   c.    
         [0027]     As the skilled man within the art easily realizes, the invention can be used within one single host, i.e. for measuring latency between a sending application and a receiving application within the same host. In  FIG. 4 , such an example is shown schematically. Like or similar part in  FIGS. 1 and 4  are denoted with the same reference numerals. As can be seen, both the sending application  23  and the receiving application  35  are arranged within the same host  51 . The communication between the sending application  23  and the receiving application is thus performed via an internal network (not shown).  
         [0028]     The sending host  21  comprises a multicast framework  27  adapted to provide messages generated by a message generating means  24  to be sent from the sending host  21  to the receiving host  22  with a time stamp indicating the point of time a particular message is sent. This can be performed in accordance with conventional practice within the art. In one embodiment, the message generating means  24  is a heartbeat generator adapted to generate heartbeat messages.  
         [0029]     Furthermore, the multicast framework is also adapted to send the message together with the time stamp to a multicast framework  29  of the receiving host  22 . The multicast framework  29  of the receiving host  21  comprises a latency calculating means  33 . The latency calculating means  33  is, in turn, adapted to extract the time stamp from the received messages when a message is sent to the receiving application  35  and compare the point of time indicated by the extracted time stamp with a current time of the receiving host  22  in order to calculate a latency for the message. Alternatively, the latency calculating means  33  may be adapted to extract the time stamp from only selected messages, thereby the processing load can be reduced.  
         [0030]     In a preferred embodiment, only selected messages, i.e. heartbeats, are provided with time stamps and, thus, the latency calculating means  33  only have to extract the time stamp from these selected messages.  
         [0031]     In a preferred embodiment, the multicast framework  27  of the sending host  21  is adapted to provide the selected message with a time stamp indicating the moment the message enters a sending queue  26  of the multicast framework  27  of the sending host  21  since this is the point where a regular message should be sent to the receiving host  22 . Moreover, the latency calculating means  33  is adapted to extract the time stamp the moment the selected message leaves a receiving queue  31  of the multicast framework  29  of the receiving host  22  since this is the point where a regular message should be delivered to the receiving application  35 .  
         [0032]     To ensure that the heartbeats measure the total travel time for a message, including the waiting time in sending queues and receiving queues, the heartbeats are injected into the same message stream as the regular (application) messages. This is shown in the sending queue  26  and the receiving queue  31 , where regular messages are indicated with the letter m and the heartbeat with the letter h. In the receiving queue  31 , the empty message indicates a sequence gap, i.e. a message has been lost during the transmission. Hence, the heartbeat messages are also sequence-numbered in the same way as regular (application) messages, meaning that if a heartbeat message is lost in the network it will be subject to gap detection and re-transmission in the same way as a regular message. In fact, the message processing logic in the frameworks  27 ,  29  is unaware of the message content and does not treat heartbeat messages differently than any other message.  
         [0033]     Preferably, the sending host  21  and the receiving host  22  are adapted to communicate in order to synchronize an internal clock of the sending host  21  and an internal clock of the receiving host  22  in order to secure an accurate calculation of the latency. In an alternative embodiment, the sending host  21  and the receiving host  22  are adapted to communicate in order to regularly measure a time difference between an internal clock of the sending host  21  and an internal clock of the receiving host  22 .  
         [0034]     With reference to  FIG. 3 , the general principles of the method for measuring latency in a multicast environment according to the present invention will be described. First, in step  40 , a message to be sent from sending host  21  to the receiving host  22  is provided with a time stamp indicating the point of time the message is sent according to the current time of the sending host  21 .  
         [0035]     As described above, the message is preferably a heartbeat message. The heartbeat is sequence-numbered and is placed in the sending queue  26 . Then, at step  42 , the message is transferred together with the time stamp from a multicast framework  27  of the sending host  21  to a multicast framework  29  of the receiving host  22  via the communication network  25 . The communication network  25  may be a so called unreliable network in contrast to the multicast frameworks  27 ,  29  of the sending host  21  and the receiving host  22 , respectively. A reliable multicast system is a system where a message is broadcasted to multiple recipients at the same time but where it is also guaranteed that all messages reach the intended recipients in order and without any gaps. Thus, normally, since the messages are sent partly over unreliable networks (i.e. the communication network  25 ), it can not be guaranteed that all messages reach the intended recipient in due order and messages may be lost in the network during the transmission. However, if a message sent by multicast is lost for some reason, the receiver will detect this and request a re-transmission of that particular message, see  FIG. 2  where such a missing message in the sequence is indicated with an empty message box in the receiving queue  31 . At receipt at the receiving host  22 , the heartbeat is placed in the receiving queue  31  of the multicast framework  29 . Subsequently, at step  44 , the time stamp is extracted from the heartbeat message when the heartbeat message is received by the receiving application  35  of the receiving host  22 . Finally, at step  46 , the point of time indicated by the extracted time stamp is compared with a current time of the receiving host  22  in order to calculate a latency for the message.  
         [0036]     In the present invention it is accordingly identified when a message actually is sent from the sending application of the sending host and, on the receiving end, when the same message actually is received by the receiving application. Thus, a reliable and accurate approximation of the total latency for a message, i.e. the network latency as well as the latency caused by waiting times in the sending queue and the receiving queue, can be obtained without being affected by network parameters such as the network bandwidth or the quality of the network.  
         [0037]     In a preferred embodiment of the present invention, heartbeat messages injected into the same message stream as the application messages are used and these heartbeat messages are subjected to queuing in the sender and the receiver. Moreover, they are also sequence-numbered, which entail that if a heartbeat message is lost in the network it will be subject to gap detection and re-transmission in the same way as regular (application) messages. This is indicated in  FIG. 2 , where a gap is indicated with an empty message box in the receiving queue  31 . In fact, the message processing logic in the frameworks is unaware of the message content and does not treat heartbeats differently than other messages. In one embodiment, the heartbeat messages are sent out at regular intervals, for example, one each second.  
         [0038]     In a preferred embodiment, the time stamp indicates the point of time the heartbeat message enters the sending queue  26  and, further, the time stamp is extracted by the latency calculating means  33  when the heartbeat message leaves the receiving queue  31 .  
         [0039]     Although specific embodiments have been shown and described herein for purposes of illustration and exemplification, it is understood by those of ordinary skill in the art that the specific embodiments shown and described may be substituted for a wide variety of alternative and/or equivalent implementations without departing from the scope of the invention. Those of ordinary skill in the art will readily appreciate that the present invention could be implemented in a wide variety of embodiments, including hardware and software implementations, or combinations thereof. As an example, all functions of the inventive method and the system can be implemented in a server connected to a large number of sending systems and receiving systems. This application is intended to cover any adaptations or variations of the preferred embodiments discussed herein. Consequently, the present invention is defined by the wording of the appended claims and equivalents thereof.