我觉得part 3非常重要,所以尽量多写点,写得更详细点。下面开始。
三. 理解inbound call和outbound call的匹配规则
     1. Match inbound Dial Peers
     1)Inbound Dial Peers的参数和特性
      呼叫建立需要三种参数,有四个可配置的dial peer命令特性来匹配这三个参数。
      对源路由器来说,从POTS进入的 call leg 关联Inbound POTS dail peers ;
      对终端路由器来说,从Voice-Network 进入的call leg 关联Inbound Voice-Network  dail peers 。
     四种配置命令对应呼叫建立元素的关系表:
  dial-peer属性
描述 
 呼叫建立元素
gwy(config dial-peer)#
incoming called-number
DNIS_string 
  该命令定义被叫号,dialed number identification service (DNIS)。通常该命令使用被叫号来匹配inbound call leg对应的inbound call dial peer
被叫号
DNIS 
gwy(config dial-peer)#
  answer address
ANI_string
   该命令定义主叫号 ,automatic number identification (ANI) string。通常该命令使用主叫号来匹配inbound call leg对应的inbound call dial peer
  主叫号
ANI
  gwy(configdial-
peer)#
destination-pattern
string
    当该命令对应outbound call leg时,使用的是被叫号来匹配   outbound call dial peer
    当该命令对应inbound call leg时,使用的是主叫号来匹配inbound call dial peer
 
inbound时,是ANI;
outbound时,是DNIS 
 gwy(configdial-
peer)#
port port
该命令用于定义通过POTS port的呼叫
Voice Port 
 
     呼叫建立的三个元素
 呼叫建立的元素 描述
 called number (DNIS) 呼叫的被叫号码字符串。一般起来自ISDN的建立信息或者CAS的DNIS。
 calling number 
(ANI)
 代表呼叫起源的字符串。一般来自ISDN的建立信息或者CAS的ANI
 Voice Port 代表POTS的物理语音接口
 
  2.inbound 呼叫的匹配规则
     当cisco 网关接到一个呼叫建立的请求时,dial-peer 用于匹配进入的呼叫,并将呼叫路由到不同的进程和应用上。dial-peer不会逐位匹配字符串,相反,它会接受所有的字符串后再来匹配。
     路由器或者是网关用dial-peer匹配inbound call时,规则如下:
     1)Called number (DNIS) with incoming called-number
     首先,如果dial-peer配置了incoming called- number 命令,那么dial-peer都会去尝试匹配呼叫建立时的called number参数。一般的呼叫都会有called number ,所以推荐用这个命令来做inbound dial peer。这个属性的优先级高于answer-address和destination-pattern
     2)Calling Number (ANI) with answer-address
     如果没有配置 incoming called-number命令。那么,配置了answer-address 的dial-peer会尝试匹配calling number参数。这个命令可以用来匹配基于calling number的呼叫
     3)Calling Number (ANI) with destination-pattern
     如果没有匹配answer-number这条命令。那么,配置了destination-pattern的dial-peer会尝试匹配calling number参数。这个在后面详解!
     4)Voice-port
     如果第3条还没匹配,那么网关或者路由器会用dial-peer port去关联来自voice-port呼叫的calling-number参数
     5)最后如果都没有匹配的那么会默认调用default dial-peer 0 (PID 0)
     如果没有一个命令能匹配呼叫建立,那么网关会调用default dial-peer 0 来匹配呼叫。
     default dial-peer 0 (PID 0)的参数不能修改。并且default dial-peer 0 (PID 0)不能去协商非默认的服务参数,例如:
          Non-default Voice-Network capabilities: dtmf-relay, no vad
          Direct Inward Dial (DID)
          TCL Applications
   dial-peer 0 对于inbound call 默认的配置有:
     any codec
      vad enabled
      no rsvp support
      fax-rate voice
   dial-peer 0 对于outbound call 默认的配置有:
         no ivr application
    在每个阶段最长字符匹配规则仍然适用。
 
    3.Matching Outbound Dial Peers
    网关或者路由器会使用destination-pattern called_number来匹配outbound call
    1)对于POTS dial peer,port命令用于路由呼叫
    2)对于Voice-Network dial peers,session target命令用于路由呼叫。
另外,当outbound peer被匹配时需要考虑两种情况,DID的或non-DID。
    对于DID的情况:
    一个incoming dial peer被配置为下面的命令:
                       dial-peer voice 1 pots
                           incoming called-number 81690
                           voice-port 0:D
                           direct-inward-dial
    对于DID calls,呼叫建立时,必须包含所有的号码才会路由。当网关或者路由器选择outbound dial peer时,会将号码一起发给outbound dial-peer。
    例如,下面的配置:
                      dial-peer voice 3 voip
                         destination-pattern 816
                         session target ipv4:172.22.10.1
                      dial-peer voice 4 voip
                         destination-pattern 81690
                         session target ipv4:172.22.10.1
outbound会匹配 dial-peer 4!
       对于non-DID的情况:
       outbound call会逐位匹配号码,所以上面的例子会匹配dial-peer 3,但是出去的被叫号码是816.