Abstract:
Networks primitives are provided for establishing and maintaining channels and secure channels. In one embodiment, requests to open a new channel are handled only in a listen mode and, after authentication, the channel provides secure communication. In one embodiment, a secure channel is initialized and fixed if broken so that a plurality of threads may share it. In one embodiment, a no listen mode is applied if the number of new channels handled per time period is more than a threshold.

Description:
BACKGROUND 
       [0001]    Computer networks are made from basic building blocks, called network primitives. Computer networks deal with various issues, such as asynchronous execution, multithreading, and faulty channels. However, existing network primitives do not take all of those into account. Consequently, computer networks lack simplicity, reliability, correctness, and efficiency. For example, in existing networks, a server is constantly listening for incoming requests to open a new channel. Depending on the needs of the application, this may be a waste of resources and expose the server to malicious communication. 
       SUMMARY 
       [0002]    Embodiments are provided for establishing and maintaining channels and secure channels. In one embodiment, switching between a no listen mode and a listen mode determines whether requests to open a new channel are ignored or handled, respectively, and when a channel is established, it is authenticated and may be used for secure communication. Any authentication method may be used. In one embodiment, a secure channel is established and shared by a plurality of threads, and is guaranteed to be renewed if broken. Any method for establishing a secure channel may be used. In one embodiment, a no listen mode and a listen mode are used with a counter and a threshold to limit the number of new channels handled per time period. 
     
    
     
       DRAWINGS 
         [0003]    The following figures illustrate the embodiments by way of example. They do not limit their scope. 
           [0004]      FIG. 1  shows a flow diagram of a method of establishing a secure channel, in accordance with one embodiment. 
           [0005]      FIG. 2  shows a flow diagram of a method of establishing and maintaining a secure channel, in accordance with one embodiment. 
           [0006]      FIG. 3  shows a flow diagram of a method of limiting new channels handling, in accordance with one embodiment. 
       
    
    
     DETAILED DESCRIPTION 
       [0007]    This section includes detailed examples, particular embodiments, and specific terminology. These are not meant to limit the scope. They are intended to provide clear and through understanding, cover alternatives, modifications, and equivalents. 
         [0008]    Communication involves a plurality of parties. The set of parties that communicate with a party is the neighbors of that party. A party has at least one thread. A thread is a unit of execution, such as a software thread, a hardware thread, a process, and so on. Parties may have a unique identifier and may be in different or identical locations. The location may be represented using a physical or a logical address. For example, two parties on the same device could be threads or processes, identified by a thread id or process id, respectively. The parties communicate via a channel. For example, the channel may be a TCP (Transfer Control Protocol) connection or shared memory or a file. Data sent on the channel may or may not arrive, may or may not be delayed, and may or may not be corrupted. A channel may be closed in any way. For example, a TCP channel may be closed with or without a termination notice. 
         [0009]    A party is in listening mode if it accepts requests to open a new channel. Otherwise, it is in a no listen mode. A listening policy selects a listening mode. Any listening policy can be used. For example, in a single channel per neighbor policy, a party listens until a channel has been established with each of its neighbors, and then switches back to a no listen mode, resuming listening only if a channel with one of the neighbors drops. As another example, in an always listen policy, a party is always in a listen mode. 
         [0010]    A secure channel provides data confidentiality, data integrity, and authenticity. Elements such as identifiers, tokens, and cryptographic functions may be used to establish a secure channel. For example, encryption provides data confidentiality, signatures provide data integrity, and signcryption provides both. Each pair of parties may or may not have a unique channel, and elements used to establish a channel in one direction may or may not be used to establish a channel in the reverse direction. For example, if each party has unique elements for establishing a secure channel with any other party, then each channel is unique and the elements are unidirectional. 
         [0011]      FIG. 1  shows a flow diagram of a method of establishing a secure channel, in accordance with one embodiment. Requests to open a channel are ignored in a no listen  100  mode and accepted in listen  102  mode. Any listening policy, such as a single channel per neighbor policy, may be used. When a request to open a channel is accepted, a channel  104  is established. An identifier  106  is read from the channel. If the identifier is invalid, then the channel is closed  108 . 
         [0012]    The identifier may be validated in any way. For example, it can be validated using a list, a database, a predicate, and so on. If the identifier is valid, then the channel is authenticated  110 . Any authentication method can be used. For example, a signcryption function corresponding to the identifier may be applied to the channel so that a token can be read, and authentication is successful if the token is valid. If authentication is unsuccessful, then the channel is closed. Otherwise, a secure channel  112  is outputted, and one of the listening modes is resumed. The secure channel may be used for secure communication. 
         [0013]      FIG. 2  shows a flow diagram of a method of establishing and maintaining a secure channel, in accordance with one embodiment. An initialization  200  thread establishes a secure channel  112  and waits for a signal. Any method for establishing the secure channel may be used. A worker  202  thread uses the secure channel to execute logic. Any logic may be used. If the secure channel closes for any reason, such as an exception, then the initialization thread is signaled to reestablish the secure channel. Any method for signaling may be used. Any number of worker threads may be used. 
         [0014]    The secure channel may be placed in a queue  206  so that it can be shared between more than one thread. The queue is initially empty. At any given time, at most one thread can take the secure channel from the queue or put it back in the queue. Other threads block if the queue is empty. The queue may be used for signaling. 
         [0015]    If the secure channel is idle, then a worker thread executing the echo  204  logic sends and receives data on the secure channel. Any data may be sent and received. For example, the echo logic may send a randomly selected first number, read back a second number, and close the secure channel if the first number and the second number are not equal. 
         [0016]      FIG. 3  shows a flow diagram of a method of limiting new channels handling, in accordance with one embodiment. Requests to open a channel are ignored in a no listen  100  mode and accepted in a listen  102  mode. Any listening policy, such as a single channel per neighbor policy, may be used. A counter, a threshold, and a time variable are used. The counter is initially zero. If the counter equals zero  300 , then the time variable is set  302  to the current time plus a period. Any value can be used for the threshold and the period. For example, a period of one second and a threshold value of ten mean that at most ten channels would be handled per second. If the counter is smaller than the threshold  304 , then the counter is incremented  306 , the channel is handled  308 , and listening resumes. Otherwise, the counter is reset  310 . If the current time is bigger than the time variable  312 , then the channel is handled  308  and listening resumes. Otherwise the channel is closed  314 , and a no listen mode is selected. Listen mode resumes when the current time equals the time variable. 
         [0017]    The handler can execute any logic. For example, the handler may launch a new thread that authenticates the channel so that a secure channel is obtained. 
         [0018]    The specific embodiments and specific terminology used above should not be construed as limiting the scope of the embodiments. These details have been presented for purposes of illustration and are not intended to be exhaustive. Many modifications and uses are possible. The scope of the embodiments is defined by the Claims appended hereto and their equivalents.