For simplification purposes, this topic assumes that no errors occur; however, the application does perform error checking.
As we have already seen in Management Component Operations, the management component sends the HELLO message to the data or control component, depending on the value in its local direction
variable. On the first iteration, the message goes to the data component. The code is as follows:
static component_id_e direction = HELLOPICS_ID_DATA; // first execution if(direction == HELLOPICS_ID_DATA) { rc = pconn_server_send(data_session, MSG_HELLO, &hello_data, sizeof(hello_data)); direction = HELLOPICS_ID_CTRL; // switch direction else { rc = pconn_server_send(ctrl_session, MSG_HELLO, &hello_data, sizeof(hello_data)); direction = HELLOPICS_ID_CTRL; // switch direction
The logic of the message flow among the components is illustrated in the following figure and described in the subsequent paragraphs.
The Message Cycle
mgmt_client_message()
handler is triggered on a message from the management component. If the message is MSG_HELLO
, the data component sends the message onward to the control component:
case MSG_HELLO: // Received a HELLO from the mgmt component, so // pass it along to the ctrl component rc = pconn_client_send(ctrl_client, MSG_HELLO, msg->data, sizeof(uint32_t));
receive_message()
handler is triggered on a message from the data component. If the message is MSG_HELLO
, the control component sends the message onward to the management component:
case MSG_HELLO: // Received a HELLO from the data component, so // pass it along to the mgmt component rc = pconn_client_send(mgmt_client, MSG_HELLO, msg->data, sizeof(uint32_t));
receive_message()
handler is triggered on a HELLO message, which it knows to be coming from the control component. In this case, the management component simply increments the messages-received counter and updates the data for the backup.
case MSG_HELLO: INSIST_ERR(msg->length == sizeof(uint32_t)); helloNum = ntohl(*((uint32_t *)msg->data)); junos_trace(HELLOPICS_TRACEFLAG_CONNECTION, "%s: Received a HELLO from the control component (%d)", __func__, helloNum); if(helloNum == hello_seq_num) { ++hellopics_stats.msgs_received; received = TRUE; } else { ++hellopics_stats.msgs_badorder; } update_replication_entry(&hellopics_stats); break;
direction
variable was set to HELLOPICS_ID_CTRL
after the management component sent the first HELLO message, the management component sends the second message to the control component, and the cycle continues.
The control component's receive_message()
handler is triggered on the message from the management component. If the message is MSG_HELLO
, the control component sends the message onward to the data component:
case MSG_HELLO: ... rc = pconn_server_send(data_session, MSG_HELLO, msg->data, sizeof(uint32_t)); ...
ctrl_client_message()
handler is triggered on a message from the control component. If the message is MSG_HELLO
, the data component sends the message onward to the management component,:
case MSG_HELLO: // Received a HELLO from the ctrl component, so // pass it along to the mgmt component ... rc = pconn_client_send(mgmt_client, MSG_HELLO, msg->data, sizeof(uint32_t)); ...
direction
variable, and a new cycle is initiated, this time in the opposite direction, beginning with the management component sending the message to the control component.Tracking and Displaying Application Statistics