Clients and Servers

The management component creates a server.

It expects to receive two connections for which it starts sessions, one from the control component and one from the data component. The control and data components act like clients connecting to the management component's server on the Routing Engine. (The management component is the only component running on the Routing Engine.)

The goal is to establish direct channels between the three components; thus, the application also establishes a channel between the data and control components. Although either of these could function as client to the other one's server, this application has arbitrarily chosen to make the control component function as the server to the data component: that is, in addition to being a client to the management component, the control component also starts a server. The control component expects to accept only one connection coming from the data component.

The data component is a client both of the management component and of the control component.

The functions in libconn use special prefixes to distinguish between clients and servers. The pconn_server_ prefix indicates an action in which the caller is acting as a server; the pconn_client_ prefix indicates an action in which the caller is acting as a client to a remote server. A pconn_session_ prefix indicates an action on an established connection to a server. A server can accept many sessions; however, a given client can connect to only one server at a time.

Event Handlers for Messages and Connections

The timer loop introduced in Management Component Operations governs the message generation. The control and data components each start a daemon that runs event handlers to process messages. Each event handler deals with specific states in the message flow, with the object of keeping the Hello message flowing in a cycle from one component to the next. Initially, the message flows from the management component, to the data component, to the control component, and back to the management component. On the next cycle, the management component reverses the direction, and the message flows to the control component, to the data component, and back to the management component.

The following simple figure shows this flow:

hellopics-flow-g016851.gif

Basic Communication Flow

The control component declares four event handlers for connection and message handling. Two work when the component is a server to the data component, and two work when it is a client of the management component:

Control Component as Server

receive_connection() processes a server connection to the data component. It is declared as part of the params structure that is passed to pconn_server_create().

receive_message() sends a READY message to the management component if the data component is ready, and a HELLO message to the management component if it received one from the data component; in other words, the management component is the client and the control component is the server. receive_message() is passed to pconn_server_create() as the msg_handler parameter.

receive_connection() and receive_message() are activated as follows:

 s_params.pconn_event_handler   = receive_connection;
    
    // bind
    ctrl_server = pconn_server_create(&s_params, ctx, receive_message, NULL);

Control Component as Client

client_connection() handles connection events for the control component's connection (as a client) to the management component. It sends a message ID or a READY message to the management component if the data component is available. It is declared as part of the params structure that is passed to pconn_client_connect_async().

client_message() passes HELLO messages that it has received from the management component onward to the data component. It processes READY and HELLO messages. It is passed to pconn_client_connect_async() as the msg_handler parameter.

client_connection() and client_message() are activated as follows:

  c_params.pconn_event_handler  = client_connection;
    
    // connect
    mgmt_client = pconn_client_connect_async(
                    &c_params, ctx, client_message, NULL);

Data Component Handlers

The data component always functions as a client. It contains the following handlers:

mgmt_client_connection() sends a message ID to the management component and requests peer information about the control component. It is declared as part of the params structure that is passed to pconn_client_connect_async().

mgmt_client_message() sends a HELLO message received from the management component to the control component, or if it has received peer information from the control component, sets up a connection to the control component to handle the message. It is passed to pconn_client_connect_async() as the msg_handler parameter.

In general, whenever the management component receives a peer-information-request message, it responds by sending the opposite peer's information. If a connection from the opposite peer has not been made, the information is held until the peer connects, and then sent.

mgmt_client_connection() and mgmt_client_message() are activated as follows in the connection initialization code:

 m_params.pconn_event_handler  = mgmt_client_connection;
    
    // connect
    mgmt_client = pconn_client_connect_async(
                    &m_params, ctx, mgmt_client_message, &ctx);
    

Initialization and Preparing to Send Messages


2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:26:47 2010 for Juniper Networks Partner Solution Development Platform JUNOS SDK 10.2R1 by Doxygen 1.4.5