MGCP/Megaco - The Basics

When a gateway detects an off hook condition, it tells the gateway controller, which might respond with a command to instruct the gateway to put dial tone on the line and listen for DTMF tones indicating the dialled number. After detecting the number, the gateway controller determines how to route the call and, using an inter-gateway signalling protocol such as SIP, H.323, or Q.BICC, contacts the terminating controller. The terminating controller could instruct the appropriate gateway to ring the dialled line. When the gateway detects the dialled line is off hook, both gateways could be instructed by their respective gateway controllers to establish two-way voice across the data network. Thus, these protocols have ways to detect conditions on endpoints and notify the gateway controller of their occurrence; place signals (such as dial tone) on the line; and create media streams between endpoints on the gateway and the data network, such as RTP streams.
There are two basic constructs in MGCP/Megaco: terminations and contexts. Terminations represent streams entering or leaving the gateway (for example, analogue telephone lines, RTP streams, or MP3 streams). Terminations have properties, such as the maximum size of a jitter buffer, which can be inspected and modified by the gateway controller. A termination is given a name, or TerminationID, by the gateway. Some terminations, which typically represent ports on the gateway, such as analogue loops or DS0s, are instantiated by the gateway when it boots and remain active all the time. Other terminations are created when they are needed, get used, and then are released. Such terminations are called "ephemerals" and are used to represent flows on the packet network, such as an RTP stream.
Terminations may be placed into contexts, which are defined as when two or more termination streams are mixed and connected together. The normal, "active" context might have a physical termination (say, one DS0 in an E3) and one ephemeral one (the RTP stream connecting the gateway to the network). Contexts are created and released by the gateway under command of the gateway controller. Once created, a context is given a name (ContextID), and can have terminations added and removed from it. A context is created by adding the first termination, and it is released by removing the last termination.
MGCP/Megaco uses a series of commands to manipulate terminations, contexts, events, and signals:
- Add - adds a termination to a context and may be used to create a new context at the same time.
- Subtract - removes a termination from a context and may result in the context being released if no terminations remain.
- Move - moves a termination from one context to another.
- Modify - changes the state of the termination.
- AuditValue and AuditCapabilities - return information about the terminations, contexts, and general gateway state and capabilities.
- ServiceChange - creates a control association between a gateway and a gateway controller and also deals with some failover situations.