Call Us Today! 877.742.2583

Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Remove sections redundant with other pages


titleTable of Contents (click to expand)

Table of Contents


0. About

A description of how FreeSWITCH processes a typical SIP call.



1. Typical SIP Call Between Registered

titleClick here to expand UML diagram
PlantUML Macro
title Typical SIP Call From Registered Extension


partition CS_NEW {
:Create new channel\n A-leg;

if (Match ACL?) then (match)
  :sip_authorized\n = true;
  :Digest authenticate;
  if (Authenticated?) then (auth)
    :sip_authorized\n = true;
  else (reject)

partition CS_INIT {
:Initialize channel\n A-leg;

:parse SDP<
:Send BREAK>
:Lookup caller's context in\n user directory entry;
note right: Context = "default" in\n vanilla configs

partition CS_ROUTING {
#LightGreen:Hunt XML\nDialplan;

  if (extension condition) then (true)
    :add actions to\n to-do list;
  else (false)
    :add anti-actions to\n to-do list;
repeat while (Next extension exists\n AND\n continue = true?)

partition CS_EXECUTE {
:Execute to-do list;

:Set channel variables;

if (bridge or\n transfer?) then (bridge)
  :Create new channel\n B-leg;
  note left: State CS_NEW
  :Initialize channel\n B-leg;
  note left: State CS_INIT
  :Send invite>
  :Send SDP>
  :Send BREAK>
  note left: CS_ROUTING
  :Consume media<
  :Select codec;
  if (early media) then (true)
    :Play early media>
else (transfer)
  #LightGreen:Begin new pass through\n specified dialplan context;

-> Someone answers;
:Receive\n 200 OK<
:Send ACK>

  :Exchange media;
repeat while (BYE?)

partition CS_HANGUP {
-> BYE;
:Send KILL>
:Clear the bridge;
:Send clearance code>

partition CS_REPORTING {
:Write CDR;

partition CS_DESTROY {
:Destroy B-leg;
:Destroy A-leg;


Call States


In the routing state

hunts through the XML dial plan. When it finds a condition test that returns true it builds a to-do list with name–value action pairs, including lists of variables to set and dialplan applications to execute later such as "bridge". During this routing state none of the applications encountered will be executed, except for a limited number that can be run immediately by including the "inline" attribute.


The execute state performs the instructions compiled in the routing state. The name–value pairs are parsed and executed.


The hangup state either transfers the call back to the routing state, if there is a name–value pair that requests it, or else it will hang up the call.

Channel States

A channel (representing a call leg) will go occupy many different states during its lifetime. The table below lists the different states that a channel can occupy, and what each of those states means.

Channel StateDescriptionCS_NEWChannel is newly created.CS_INITChannel has been initialized.CS_ROUTINGChannel is hunting through a dialplan for an extension to execute.CS_SOFT_EXECUTEChannel is ready to execute from 3rd party control.CS_EXECUTEChannel is executing its dialplan instructions.CS_EXCHANGE_MEDIAChannel is exchanging media with another channel.CS_PARKChannel is accepting media awaiting commands.CS_CONSUME_MEDIAChannel is consuming all media and dropping it.CS_HIBERNATEChannel is in a sleep state.CS_RESETChannel is in a reset state.CS_HANGUPChannel is flagged for hangup and ready to end. Media will now end, and no further call routing will occur.CS_REPORTINGThe channel is already hung up, media has already ended, and now it's time to do any sort of reporting processes such as CDR logging.CS_DESTROYChannel is ready to be destroyed and out of the state machine. Memory utilized by the channel is freed and memory pools are returned to the core.

State Handlers

Custom state handlers can be added to the channels either globally or on a per-channel basis. This will allow you to do your own custom reporting or clean up your own dynamically created objects, for example. Custom handlers can also then be removed from a channel.

2. See Also