How to configure back 180 or 183 in FreeSWITCH is a frequently asked question. However, the answer is far less simple than you might think.
To understand how to configure, first you need to understand the ins and outs of 180 and 183. In addition, you need to know what you are going to do.
What My question, of course, I know what I'm going to do! "Maybe you'll roar like this, maybe you really know what you're going to do, but I don't know." So before you get a valid answer, you have to learn to let me know.
OK, let's not argue about this, let's say 180 and 183.
In SIP communication, all 1-beginning responses are called temporary responses, with 100,180 and 183 common. These responses are generally responses to invite requests. The use scenario is this: the calling user (a) initiates a call to the called User (B) to initiate a invite request, the called user receives the request, will give the caller a response, the general response process is back to 100, followed by 180, or (and) 183.
INVITE
A <-----------> B
180/183
Of these, 100 is mainly the signaling layer, its function is B tells a it received a invite request. About its role can also be said, but then to the bottom of the signaling, we generally can not pay attention.
The function of 180/183 is b to tell a, you can listen back to the bell tone.
What is a back ring tone? This is going to start with an earlier analog phone era. A to B phone, b Words of opportunity ringing, and A's phone playback back ring tone (beep), so that a will know B phone ringing.
So, the ring tone is the analog phone era of things, its role is to give a a hint, the other side of the phone is ringing, so that a can be assured to wait for B to answer the phone. Of course, with the progress of technology and the development of the times, the ring tone is also in progress, typically, in addition to the beep, telecom operators will also use this time to wait for users to put some music, or even advertising, anyway idle is idle. These music or advertisements are called ring tones, which are played before a and B are formally on the phone, and therefore do not charge a. However, because the ring is also a resource, operators may charge B (b music to improve their own force, or advertising to enhance their image and even gain business interests, charges are justified).
In the SIP era, these ring tones or ringtones need to be described in sip, which are real sound data called media. But in order to distinguish it from the real media (that is, A and B real call data), it is the early media, that is, early media.
The full name of the SIP is (Session initiation Protocol, which is the Conversation Initiation Protocol), it is only the negotiation of the completion of the session, but the actual media how to transport it requires another protocol to negotiate, is responsible for describing the media protocol called SDP (session Description Protocol), which is the session Description protocol. However, the SDP is parasitic in sip, typically, it is parasitic in invite messages and 183 messages. When a calls to B, it needs to place its SDP in the invite message to B, while B puts its own SDP in the 183 message and sends it back to a. When both parties know each other's SDP, the real media data can be transmitted, at which point A will hear B's early media.
To help you understand the SDP, let's go further. Assuming B is answering the call, B responds with a $ OK message with an SDP (which may or may not be the same as in 183) to establish a and b real calls, after all, a gives B a call to speak to B, not to listen to music or ads in early media.
So, whether it's the SDP in 183, or the SDP in the OK, it's all about creating media services. The difference is just one called early media and the other is media. In fact, early media and media differences in addition to one is the advertisement of a real B sound outside, the difference is not small, to say the difference, that is, the operator's charges are different, because early media is not charged.
Maybe someone started to talk about me, but, I'm sure, some people really do not understand what I said above, including some people who began to call me wordy. Don't believe it, be patient and look down.
Well, 183 and 200 seem to understand a little, what is the difference between 180 and 183?
Between 180 and 183 is a difference of 3.
You said I was kidding? Well, the crap is all RFC-defined, and the RFC doesn't define their differences!
However, the RfC outlines that everyone is going to go, so we all follow their own understanding of the implementation of 180 and 183.
Now the most popular way to achieve this is: 180 without sdp,183 with SDP. FreeSWITCH also abide by this agreement.
So, the difference between 180 and 183 is not 3, nor is it the other, the key is to see them with no SDP, that is 180 can also take sdp,183 or without SDP. To prevent confusion, we think that 180 is not with SDP and 183 with SDP. As mentioned above, these are in line with the minds of most people.
So, with the SDP 183 we said above, 180 without the SDP what is the use?
Aren't we talking about the progress of the times? SIP terminal belongs to the intelligent terminal, more advanced than the previous analog phone. One of them is that it can distinguish between 180 and 183. If a SIP terminal receives 183, it will negotiate the media, the B-side sends the early media in its own speakers, but if received is 180, no SDP can not negotiate media, therefore, B will not be able to give a hair early media. What to do, can not let the Lord call the user wait Ah, so, A's phone in this case can produce a ring tone, or any user on a phone set music.
Well, here, whether you understand it or not, I'll tell you what to say anyway.
So, how do you configure back 180 or 183 in FreeSWITCH?
FreeSWITCH is a multi-functional SIP server, here, for the sake of simplicity, let's think of it as a generic sip UA. For example, it is B.
Within FreeSWITCH, FreeSWITCH's behavior is controlled by some function functions called application. When a call arrives, FreeSWITCH looks for a dial plan (DialPlan) to determine which application to perform. For example, below the DialPlan, when a call arrives, it first executes answer, gives the other party back to the other side, then executes playback to put a sound (read from the sound file), then hang up the machine.
<action application= "Answer"/>
<action application= "Playback" data= "/tmp/hello.wav"/>
<action application= "Hangup"/>
If you test this piece of DialPlan yourself, you will find that FreeSWITCH will not return to 180 and will not return to 183, but directly back to 200. Here, answer want to be a B pick-up answer, in the SIP directly back to 200.
Of course, "the paper came to the end of shallow, I know this matter to preach." "As far as it is, you have to try it yourself, and the best way to learn about SIP is not to look at the RfC, but to follow what I've said (and the examples in the FreeSWITCH authoritative guide) to grab a bag." If you try to be wrong, do not blame me, perhaps your dialplan inside too many things, in these several application before you do not know the other application.
Okay, so how do you get it back to 183?
In the above DialPlan answer that line removed, back to 183.
Why is it?
Because the role of playback is to play a sound to a, a media channel is established before B sends a sound to a. If there is a answer,freeswitch will send a K OK, with the SDP to establish a media channel. If there is no answer, then FreeSWITCH will send 183, with the SDP to establish a media channel, and at this time, hello.wav media content becomes early media.
So, send not send 183 to see you before answer or answer after the execution of playback.
What about 180? It is also very simple, which is to execute a ring_ready before sending 180, i.e.:
<action application= "Ring_ready"/>
<action application= "Answer"/>
<action application= "Playback" data= "/tmp/hello.wav"/>
<action application= "Hangup"/>
In the example above, if you grab a bag, you can see 180, but you probably won't hear the ring tone. The reason is simple, answer executes too fast. Try to pause between the ring_ready and the answer to hear the back ring tone. In the example below, sleep can pause for 2 seconds (2000 milliseconds) after sending 180 and then send the OK:
<action application= "Ring_ready"/>
<action application= "Sleep" data= "/>"
<action application= "Answer"/>
We already know how to make FreeSWITCH 180 or 183, is the problem solved?
Obviously not, I know you are not so simple in practical applications. We're here to treat FreeSWITCH as B, but actually you want FreeSWITCH to be freeswitch,b B. What do you mean? FreeSWITCH is actually a b2bua, it's an intermediary, and the topology you want is like this:
A <--------> FreeSWITCH <---------> B
Oh, you see, my first words, the answer to your question, the answers are far less than you think simple. Now, we need to list (guess) all the situations you want.
Well, even if I guess this time, go ahead and say it.
The middleman is also bad, because he can have n different strategies. As for which strategy to use, look at B's mood, also depends on freeswitch mood. Ah, plainly, there is no standard answer. So you still have to tell me what you want. If you don't tell me, I'll have to guess, or I'll tell you all the n possibilities.
First, let's look at a familiar situation first. FreeSWITCH can pretend that it is B, so that the configuration method is the same as above, but it stark reality after pretending, to use bridge this application to call B, and connect the telephone.
<action application= "Ring_ready"/>
<action application= "Sleep" data= "/>"
<action application= "Answer"/>
<action application= "Playback" data= "/tmp/hello.wav"/>
<action application= "bridge" data= "user/b"/>
So in the above configuration, as to whether it is 180 or 183, the configuration of the same way as above, there is no need to say more.
Second, FreeSWITCH is in a good mood and wants to hear B's opinion. If it does not execute ring_ready and does not execute answer, it directly uses bridge to call B.
<action application= "bridge" data= "user/b"/>
This is actually simple, that is, if B to FreeSWITCH reply 180,freeswitch to a back to 180, if B back to 183,freeswitch a back to 183. This is actually the equivalent of FreeSWITCH, and all messages are transparent. (However, remember: FreeSWITCH is a b2bua, that is, it is an intermediary, it does not directly take B back to its 180 or 183 message "turn" to a, but own a new generation of a 180 or 183 message back to a. Of course, perhaps you do not care about this, but the more you say the less clear, I am more tired, or else they will say that my answer is not rigorous. Or, in case I'm wrong, what do you mean by asking? )
Again, FreeSWITCH and b these two days not to deal with, what things are screwed. B back to 180,freeswitch back to 183,b back to 183,freeswitch back to 180.
Well, it seems to be getting more and more complicated. There are two different cases.
First look at the situation of B back to 180. FreeSWITCH want to give a back a 183, because B 180 without media, FreeSWITCH will "build" a media out, therefore, it thought of this way, before bridge build a media:
<action application= "Set" Data= "Ringback=/tmp/ring.wav"/>
<action application= "bridge" data= "user/b"/>
Since there is no B prior to the execution of bridge, FreeSWITCH does not know when B returns 180 or 183. By setting a variable (ringback) with set before bridge, it is actually equivalent to FreeSWITCH to bridge a set, to bridge stage, no matter when you go to the B 180,freeswitch will play to a pre-"made" Good back ring tone ring.wav. Of course, FreeSWITCH to send a media to a before the first to use 183 to establish a media channel, which completes the conversion of 180 to 183.
So, it's also the FreeSWITCH design--a bridge that changes its behavior through a ringback variable.
Look at the case of 183 change 180.
If B FreeSWITCH back to the 183,freeswitch to a back to 180, then the media information can not be sent to a. So, the implementation is also very simple, or a simple bridge, but the B sent to the early media ignored the line:
<action application= "Ring_ready"/>
<action application= "Bridge" Data= "{ignore_early_media=true}user/b"/>
different from set. Set is a application that acts on the current channel, which is a channel (not yet B). and {ignore_early_media=true} This syntax, in the establishment of the B-end channel, while the Ignore_early_media action on B. Again, FreeSWITCH is a b2bua, so the call between A and b produces two channel, the so-called A-leg and B-leg.
In establishing B-channel, Ignore_early_media also gave Bridge a set. That is, whenever B returns to 183, ignore it. Since we chose to ignore it, we used Ring_ready to send a 180 in front of bridge in order for a to still hear the back ring sound. Strictly speaking, it is not 183 change 180, because FreeSWITCH to receive 183 before it has been sent out 180, but if you do not lie on the inside of the FreeSWITCH look, who knows when to become?
N kind of situation said N species, will always have n+1. Since FreeSWITCH is in the middle, can it replace the advertisement (ringtone) sent by B with its own advertisement? Yes, but I'm not going to teach you how to do it. Unfortunately, if you are not particularly stupid, I have already taught you ...
Reading here, do you think this question is a good answer?
180 or 183?