Doubango Sip/IMS registration process

Source: Internet
Author: User

I have developed custom Sip/IMS video clients, and supported voice, video, and instant communication functions. The video formats support h263, h264, and MPEG4 soft decoding, and provide hardware coding/decoding interfaces, provide servers. If you are interested, please contact me.

Registration process (Java --> C ++ --> C)

 

Register (ngnsipservice. Java)

|

Register (ngnregistrationsession. Java)

|

Register _ (sipsession. cxx)

|

Tsip_action_register (stip_api_register.c)

 

Tsip_action_register

In three steps:

_ Tsip_action_create creates a registration request. tsip_dialog_layer_new creates a registration session to prepare for entering the state machine. tsip_dialog_fsm_act
Enter the state machine mode.

 

 

 

1. _ tsip_action_create

 

Create a registration request. Here we only create an abstract request. The request corresponds to the SIP method. The SIP Protocol defines

Register, invite, publish, subscribe, bye, message, and other methods.

Then, call _ tsip_action_set to initialize the parameters passed through the upper layer (Java.

 

2. After the request is successfully created, the Session Layer tsip_dialog_layer_new is created.

Each request method in the SIP protocol corresponds to a session, that is, a session. This function creates a session for the corresponding session based on the session type. for session registration, call tsip_dialog_register_create to create a Session Layer, and save the created session to the session linked list of the protocol stack. (1) tsip_dialog_register_create (tsip_dialog_register.c) create a registration session

Internally, a new registered object tsip_dialog_register_def_t is added. The constructor performs the following actions.

Step 3 in tsip_dialog_register_ctor:

 

A. tsip_dialog_init initializes basic session information, which is divided into the client and server. At the same time, the state machine of the session is created and the state of the state machine is initialized.

B. tsk_fsm_set_callback_terminated sets the registration session end state machine callback.

C. tsip_dialog_register_init initializes the registration session information.

 

 

 

Tsip_dialog_register_client_init initializes the client state machine callback for the registration request.

 

This is actually the callback function that should be called during a request from one status to another.

Tsip_dialog_register_server_init has the same functions.

 

Tsip_dialog_register_event_callback sets the callback for the registration event from the transport layer, and sends the notification to the upper layer.

 

 

     

     

  1. Tsip_dialog_fsm_act is the entry for all sip sessions to enter the state machine.

    The parameter is session, session type, SIP message, and request .]

    This function calls the common function tsk_fsm_act of the state machine. Execute a specific request and change the state of the state machine of the corresponding session.

    Inttsk_fsm_act (tsk_fsm_t * Self, tsk_fsm_action_id action, const void * cond_data1, const void * cond_data2 ,...)

 

Internally, It is a loop that constantly detects the status and calls the corresponding callback based on the status.

 

Each state machine has an initial state as the Operation Entry. For registration requests, the entry is,

 

Tsk_fsm_add_always (_ fsm_state_started, _ fsm_action_oregister, _ fsm_state_inprogress, tsip_dialog_register_started_2_inprogress_x_oregister, "comment "),

 

 

 

    Tsk_fsm_act will execute the tsip_dialog_register_started_2_inprogress_x_oregister callback at the beginning,

    This callback is performed from status _ fsm_state_started to _ fsm_state_inprogress,

    Internally, change the current status to _ fsm_state_inprogress, which provides the entry to call the next status for tsk_fsm_act.

    The function internally calls tsip_dialog_register_send_register to create the Transaction layer, initialize the state machine at the Transaction layer, and finally calls the transport layer socket interface to send the request.

    Because SIP divides the Transaction layer into several types based on the request type, including client request (invite) transactions, client non-request transactions (such as bye, register), and Server Request transactions, non-request transaction on the server side.

 

Therefore, a non-requesting client transaction layer is created for the registration request.

Tsip_dialog_register_send_register ---> tsip_dialog_request_new

---> Tsip_dialog_request_send ----> tsip_transac_layer_new ---> tsip_transac_start

---> Tsip_transac_nict_start: enters the state machine mode at the Transaction layer.

Here, the transaction layer Event Callback tsip_transac_nict_event_callback is set when the transaction layer is created.

For example, if a register request is sent, the server returns a OK response. At this time, the transport layer uses this response as an event to the Transaction layer. The transaction layer receives this time and parses it and enters the state machine.

 

 

So for
For a SIP request, two state machines are running, one is the Session Layer state machine and the other is the Transaction Layer state machine.

 

     

     

So far, a register request has been sent, and the Session Layer and Transaction Layer state machines are running,

At this time, if the server returns a successful registration, it will send a OK response to the transport layer of the client.

Tsip_transport_layer_dgram_cb, tsip_transport_layer_handle_incoming_msg,

Tsip_transac_layer_handle_incoming_msg, tsip_transac_layer_find_client

 

After receiving the response, the transport layer of the client finds whether the transaction has been created based on the transaction ID of the response.

The callback function of the response Transaction layer is called Based on the callback function specified during the transaction creation. Here, the callback function is tsip_transac_nict_event_callback. This function internally calls the tsip_transac_fsm_act state machine of the Transaction Layer Based on the message type, for example 200
The callback specified when the transaction layer is created. Here is tsip_transac_nict_trying_2_completed_x_200_to_699.

Calls the Session Layer callback to notify the upper layer of successful registration. Tsip_dialog_register_event_callback

This function calls the corresponding session-layer state machine according to the status, tsip_dialog_register_inprogress_2_connected_x_2xx, modifies the current status of the state machine, prepares for the next status, and finally calls tsip_dialog_register_signal to launch.

Event mechanism: tsip_dialog_register_signal creates a registration event through tsip_register_event_signal, and then puts the event in the event queue when the protocol stack is started,

 

Tsip_stack_start starts the run thread internally to process protocol stack events.

/* = Runnable = */

Tsk_runnable (stack)-> run = run;

If (ret = tsk_runnable_start (tsk_runnable (stack), tsip_event_def_t ))){

Stack_error_desc = "failed to start timer manager ";

Tsk_debug_error ("% s", stack_error_desc );

Gotobail;

}

Continuously scan the event queue in the run thread, pop an event, and send it to the callback of the specified event when the SIP protocol stack is created, so that the protocol stack events (Transaction Layer events, Session Layer events, protocol Stack events) are returned to upper-layer users.

 

So far, an analysis of a normal registration process (without considering exceptions, 401 certification process, etc.) has been completed.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.