MGCP

Posted by Max on December 2, 2014

RFC 3435

概述

媒体网关控制协议(MGCP)是一种 VOIP 协议,应用于分开的多媒体网关单元之间。

MGCP采用了一种呼叫控制结构,这些“智能”呼叫控制处于网关外部,并由呼叫代理控制。MGCP设 定呼叫代理之间采用同步方式发送连续命令和响应给在它们控制下的网关,但其并没有为同步呼 叫代理设置专门的机制。基本上, MGCP是一种主从协议,由网关去执行由呼叫代理发送的命令。

MGCP采用的连接模式,其基本构架是端点和连接。端点是源数据或数据接收器,可以是物理的也 可以是虚拟的。物理端点的创建需要安装相应硬件设备,而虚拟端点的创建可由软件完成。连接 可以是点对点方式也可以是多点方式。

在MGCP模型中,网关主要负责音频信号转换功能,呼叫代理主要处理呼叫信令和呼叫处理功能。 因此,从结果来看,呼叫代理实现了H.323标准协议信令层并充当了H.323体系的“关守”或“端点” 的角色。

连接流程图

从网关来看,连接状态图如下:

          Create connection
              received
                  |
                  V
         +-------------------+
         |resource allocation|-(failed)-+
         +-------------------+          |
                  |           (connection refused)
            (successful)
                  |
                  v
     +----------->+
     |            |
     |   +-------------------+
     |   |  remote session   |
     |   |   description     |----------(yes)--------+
     |   |    available ?    |                       |
     |   +-------------------+                       |
     |            |                                  |
     |          (no)                                 |
     |            |                                  |
     |      +-----------+                         +------+
     | +--->| half open |------> Delete   <-------| open |<----------+
     | |    |  (wait)   |      Connection         |(wait)|           |
     | |    +-----------+       received          +------+           |
     | |          |                 |                |               |
     | |   Modify Connection        |         Modify Connection      |
     | |      received              |            received            |
     | |          |                 |                |               |
     | | +--------------------+     |       +--------------------+   |
     | | |assess modification |     |       |assess modification |   |
     | | +--------------------+     |       +--------------------+   |
     | |    |             |         |          |             |       |
     | |(failed)     (successful)   |      (failed)     (successful) |
     | |    |             |         |          |             |       |
     | +<---+             |         |          +-------------+-------+
     |                    |         |
     +<-------------------+         |
                                    |
                           +-----------------+
                           | Free connection |
                           | resources.      |
                           | Report.         |
                           +-----------------+
                                    |
                                    V

报文格式

报文采用明文编码,大小写不敏感。

请求报文

所有的请求报文都包含一个命令头,有的还接一个会话描述。

命令头由两部分组成:

  1. 命令行

命令行包含行为标识,传输标识,目的终端标识,MGCP协议版本。这四部分以ASCII明文编码, 以空格,ASCII空格(0x20)或ASCII tab(0x09)分隔。

MGCP有九种行为命令,其编码如下:

Verb Code
EndpointConfiguration EPCF
CreateConnection CRCX
ModifyConnection MDCX
DeleteConnection DLCX
NotificationRequest RQNT
Notify NTFY
AuditEndpoint AUEP
AuditConnection AUCX
RestartInProgress RSIP

MGCP使用一个传输标识码来关联命令和和其响应,支持最高九位十进制数编码。

MGCP终端标识编码为大小写不敏感的email地址(参考RFC 5321)。

  1. 参数集

参数集包含零行或多行参数。每行格式为参数名: 参数值,冒号后的空格数为零或多个。参 数集中包含参数如下:

Parameter name Code Parameter value
BearerInformation B A comma separated list.
CallId C A hexadecimal string, at most 32 characters in length.
Capabilities A A comma separated list.
ConnectionId I A hexadecimal string, at most 32 characters in length.
ConnectionMode M A text string.
ConnectionParameters P A comma separated list.
DetectEvents T A comma separated list.
DigitMap D A text encoding of a digit map.
EventStates ES A comma separated list.
LocalConnectionOptions L A comma separated list.
MaxMGCPDatagram MD A string of up to nine decimal digits.
NotifiedEntity N An identifier, in RFC 5321 format, composed of an arbitrary string and of the domain name of the requesting entity, possibly completed by a port number, as in: Call-agent@ca.example.net:5234.
ObservedEvents O A comma separated list.
PackageList PL A comma separated list.
QuarantineHandling Q A list of comma separated keywords.
ReasonCode E A string with a 3 digit integer optionally followed by a set of arbitrary characters.
RequestedEvents R A comma separated list.
RequestedInfo F A comma separated list of parameter codes.
RequestIdentifier X A hexadecimal string, at most 32 characters in length.
ResponseAck K A comma separated list of “confirmed transaction-id ranges”.
RestartDelay RD A number of seconds, encoded as a decimal number.
RestartMethod RM One of the keywords “graceful”, “forced”, “restart”, “disconnected” or “cancel-graceful”.
SecondConnectionId I2 Connection Id.
SecondEndpointId Z2 Endpoint Id.
SignalRequests S A list of the signal(s) name.
SpecificEndPointId Z An identifier, in RFC 5321 format, composed of an arbitrary string, followed by an “@” followed by the domain name of the gateway to which this endpoint is attached.
     
RemoteConnection-Descriptor RC Session Description.
LocalConnection-Descriptor LC Session Description.

不是每个行为命令都包含所有参数。行为与参数的对应关系如下:

    ------------------------------------------------------------------
   | Parameter name      | EP | CR | MD | DL | RQ | NT | AU | AU | RS |
   |                     | CF | CX | CX | CX | NT | FY | EP | CX | IP |
   |---------------------|----|----|----|----|----|----|----|----|----|
   | BearerInformation   |  O |  O |  O |  O |  O |  F |  F |  F |  F |
   | CallId              |  F |  M |  M |  O |  F |  F |  F |  F |  F |
   | Capabilities        |  F |  F |  F |  F |  F |  F |  F |  F |  F |
   | ConnectionId        |  F |  F |  M |  O |  F |  F |  F |  M |  F |
   | ConnectionMode      |  F |  M |  O |  F |  F |  F |  F |  F |  F |
   | Connection-         |  F |  F |  F |  O |  F |  F |  F |  F |  F |
   |   Parameters        |    |    |    |    |    |    |    |    |    |
   | DetectEvents        |  F |  O |  O |  O |  O |  F |  F |  F |  F |
   | DigitMap            |  F |  O |  O |  O |  O |  F |  F |  F |  F |
   | EventStates         |  F |  F |  F |  F |  F |  F |  F |  F |  F |
   | LocalConnection-    |  F |  O |  O |  F |  F |  F |  F |  F |  F |
   |            Options  |    |    |    |    |    |    |    |    |    |
   | MaxMGCPDatagram     |  F |  F |  F |  F |  F |  F |  F |  F |  F |
   | NotifiedEntity      |  F |  O |  O |  O |  O |  O |  F |  F |  F |
   | ObservedEvents      |  F |  F |  F |  F |  F |  M |  F |  F |  F |
   | PackageList         |  F |  F |  F |  F |  F |  F |  F |  F |  F |
   | QuarantineHandling  |  F |  O |  O |  O |  O |  F |  F |  F |  F |
   | ReasonCode          |  F |  F |  F |  O |  F |  F |  F |  F |  O |
   | RequestedEvents     |  F |  O |  O |  O |  O |  F |  F |  F |  F |
   | RequestIdentifier   |  F |  O |  O |  O |  M |  M |  F |  F |  F |
   | RequestedInfo       |  F |  F |  F |  F |  F |  F |  O |  M |  F |
   | ResponseAck         |  O |  O |  O |  O |  O |  O |  O |  O |  O |
   | RestartDelay        |  F |  F |  F |  F |  F |  F |  F |  F |  O |
   | RestartMethod       |  F |  F |  F |  F |  F |  F |  F |  F |  M |
   | SecondConnectionId  |  F |  F |  F |  F |  F |  F |  F |  F |  F |
   | SecondEndpointId    |  F |  O |  F |  F |  F |  F |  F |  F |  F |
   | SignalRequests      |  F |  O |  O |  O |  O |  F |  F |  F |  F |
   | SpecificEndpointId  |  F |  F |  F |  F |  F |  F |  F |  F |  F |
   |---------------------|----|----|----|----|----|----|----|----|----|
   | RemoteConnection-   |  F |  O |  O |  F |  F |  F |  F |  F |  F |
   |          Descriptor |    |    |    |    |    |    |    |    |    |
   | LocalConnection-    |  F |  F |  F |  F |  F |  F |  F |  F |  F |
   |          Descriptor |    |    |    |    |    |    |    |    |    |
    ------------------------------------------------------------------

响应报文

所有的响应报文都包含一个响应头,有的还接一些会话描述信息。

响应头由两部分组成:

  1. 响应行

响应行以三位十进制响应码开头,一个空格分隔,接传输标识码。有时再接一个文本说明,也以空格分隔。

  1. 参数集

参数集包含零行或多行参数,定义与命令报文相同。对不同命令报文的响应报文,对应的参数项如下:

    ------------------------------------------------------------------
   | Parameter name      | EP | CR | MD | DL | RQ | NT | AU | AU | RS |
   |                     | CF | CX | CX | CX | NT | FY | EP | CX | IP |
   |---------------------|----|----|----|----|----|----|----|----|----|
   | BearerInformation   |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | CallId              |  F |  F |  F |  F |  F |  F |  F |  O |  F |
   | Capabilities        |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | ConnectionId        |  F |  O |  F |  F |  F |  F |  O |  F |  F |
   | ConnectionMode      |  F |  F |  F |  F |  F |  F |  F |  O |  F |
   | Connection-         |  F |  F |  F |  O |  F |  F |  F |  O |  F |
   |   Parameters        |    |    |    |    |    |    |    |    |    |
   | DetectEvents        |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | DigitMap            |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | EventStates         |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | LocalConnection-    |  F |  F |  F |  F |  F |  F |  F |  O |  F |
   |            Options  |    |    |    |    |    |    |    |    |    |
   | MaxMGCPDatagram     |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | NotifiedEntity      |  F |  F |  F |  F |  F |  F |  O |  O |  O |
   | ObservedEvents      |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | QuarantineHandling  |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | PackageList         |  O |  O |  O |  O |  O |  O |  O |  O |  O |
   | ReasonCode          |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | RequestIdentifier   |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | ResponseAck         |  O |  O |  O |  O |  O |  O |  O |  O |  O |
   | RestartDelay        |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | RestartMethod       |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | RequestedEvents     |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | RequestedInfo       |  F |  F |  F |  F |  F |  F |  F |  F |  F |
   | SecondConnectionId  |  F |  O |  F |  F |  F |  F |  F |  F |  F |
   | SecondEndpointId    |  F |  O |  F |  F |  F |  F |  F |  F |  F |
   | SignalRequests      |  F |  F |  F |  F |  F |  F |  O |  F |  F |
   | SpecificEndpointId  |  F |  O |  F |  F |  F |  F |  O |  F |  F |
   |---------------------|----|----|----|----|----|----|----|----|----|
   | LocalConnection-    |  F |  O |  O |  F |  F |  F |  F |  O |  F |
   |         Descriptor  |    |    |    |    |    |    |    |    |    |
   | RemoteConnection-   |  F |  F |  F |  F |  F |  F |  F |  O |  F |
   |         Descriptor  |    |    |    |    |    |    |    |    |    |
    ------------------------------------------------------------------

路径协议

MGCP消息通过UDP传输。命令发往指定端点的注册IP地址,响应反馈给命令源地址(一般为IP地址 +UDP端口号的格式)。如果没有明确指定端点的UDP端口号,则使用默认值。呼叫代理发往网关, 默认端口号为2427;网关发往呼叫代理,默认2727。

注意:响应报文的源地址可能与命令报文的目的地址并不相同(端口号不同)。