Call Legs
0. About
You will frequently find the terms Channel, Call, Call Leg (the A leg and the B Leg) and Bridged Call. We will explain these terms here.
1. Call legs
When you place a phone call to another phone number, from the perspective of the switch that's handling the call, there are 2 parts to the call.
- First, when you dial the number, your phone starts a connection with the switch, and notifies the switch of the number you are trying to reach.
- Next, the switch will process the dialplan for the dialed number, and start a connection to the other party.
So there are now 2 separate connections to the switch:
- The first one is the incoming connection from the originator (caller), this is sometimes called an ingress.
- The second connection is the outbound connection to the recipient of the call (callee), this is sometimes called the egress.
Each of these 2 connections is referred to as a call leg.
A call leg is an inbound or outbound connection between the phone switch and an external party.
TODO Can the source and the destination of a call leg be the same?
See this post for a more elaborate explanation.
1.1 A leg vs B leg
The terminology of A leg and B leg can sometimes be confusing. In the strictest technical sense,
- the A leg represents ingress (the incoming call leg) to the switch, while
- the B leg represents egress (the outgoing call leg) from the switch.
In most cases, this means that
- the originator of the call is the A leg, and
- the recipient of the call is the B leg.
2. Channels
In FreeSWITCH, a channel represents a call leg.
Channels are controlled using the dialplan. In addition, each channel has a UUID that can be used to programatically manipulate the call, or report on in call detail records.
3. Calls
The term call refers to the end-to-end connection from the originator to the recipient.
3.1 One legged calls
As a corollary, technically
each call leg also counts as a call.
In this scenario, when someone is checking their voicemail, the caller is the originator, and the recipient is the switch. There is no B leg as the call is handled entirely on the switch with no need to bridge the call to another party.
Examples for one legged calls:
3.2 Bridged call
When the dialplan sets up a call that connects an A leg (an inbound channel) with a B leg (an outbound channel), we call this a bridged call.
Therefore, in a bridged call, the 2 legs will be counted as 1 call.
When calling internal extensions in a office, there is usually only 1 switch involved.
In a real world scenario, most often you will receive the phone call from your SIP Provider not directly from the originator, as a FreeSWITCH instance is only aware of the call legs it handles directly. So there might be multiple switches involved in getting the call from the originator to the recipient. However the same concept applies: In this case, the incoming leg (A leg) would be the connection from your SIP provider to your FreeSWITCH instance.
3.2.1 What happens when one side hangs up?
Usually this means that if one leg hangs up, the other leg continues with the dialplan (unless it doesn't have any more actions, or a dialplan at all). Bridges can be broken in other ways too, such as
Variables, that affect what happens to the other leg when the bridge ends, include
3.2.2 Can legs be bridged if they use different protocols?
As FreeSWITCH supports many different protocols, the 2 legs of a call can be using different ones. For example, if you are using FreeTDM with a Digium board for PRI, you can have the incoming leg on SIP, and the outgoing leg on TDM. Some protocols can also connect using the web browser instead of a phone. One of the powerful features of FreeSWITCH is that it bridges 2 channels even if they are using different protocols.
4. Channels vs Calls
To recapitulate,
- the term channel in FreeSWITCH refers to a call leg, and
- the term call refers to the end-to-end connection from the originator to the recipient.
When you see different values when you run show calls
and show channels
from the CLI, it is because show calls
only counts bridged calls. So, dialing from one phone to another phone will yield 2 channels and 1 call. This also explains why show calls
may return 0 while there are active calls.
You homework assignment tonight is to make several calls and experiment with these commands:
show calls
show channels
Try calling from phone to phone as well as trying things like calling voicemail.
5. Propagating variables from the A leg to the B leg
Sometimes you want to propagate variables from the A leg to the B leg or set new variables there. From the dialplan this can be done via the export command.
Comments:
When you see different values when you run show calls and show channels from the CLI, it is because show calls only counts bridged callsNot quite true. A call that is ringing shows up multiple times in "show calls", once for the inbound channel and once each for all the outbound channels. Posted by SMart at May 05, 2021 11:30 |
---|