メニュー

Expand
ページを評価:

Twilio VoiceでSIPを使用する

はじめる前に

SIP Interfaceを使用できるようにする前に、Twilioアカウントにサインアップする必要があります(すでに持っている場合、その必要はありません)。 サインアップこちら

概要

通信インフラをTwilioに接続して、コールセンターやIVRなどといった Programmable Voice アプリケーションを、Twilioのパワフルかつ柔軟な音声通話機能とともに構築を始めましょう。 Twilioへは公開インターネットで接続できるほか、代替としてTwilioのInterconnectを利用したプライベート接続も可能です。Programmable Voice SIPでは、音声通話をグローバルなリーチで任意の固定電話、携帯電話、ブラウザー、モバイルApp、またはSIPエンドポイントにルーティングできます。

下図は、通話フローにおけるTwilioクラウドの位置付けについて示しています。

Programmable Voice SIP ダイアグラム

SIPとは何か? 

Session Initiation Protocol (SIP) は音声およびビデオ通話用のマルチメディア通信セッション管理に広く採用されている標準の通信プロトコルです。 SIPはオンプレミスまたは仮想PBXのような通信インフラとTwilioの通信プラットフォーム間の通信を確立するために使用できます。

TwilioへSIPを送信する

Twilio’s Programmable Voice SIP Interface product enables you to use your existing SIP communications infrastructure to initiate SIP sessions with the Twilio Cloud. SIP Interface uses Twilio’s TwiML language and/or Twilio’s REST APIs to create advanced voice applications. Learn how to get started connecting your SIP communications infrastructure to the Twilio Cloud.

TwilioからのSIPを受信する

TwilioのProgrammable Voice SIP Interface製品では、既存のSIP通信インフラを使用してTwilioクラウドでのSIPセッションの開始、TwilioのTwiML TwiML 言語やREST APIの使用で高度な音声通話アプリケーションを行うことができます。SIPの通信インフラをTwilioクラウドに接続する方法についての学習をはじめましょう。

制限事項

Make sure you are aware of the following Programmable Voice SIP Domain limits.

機能

SIP Registration

Twilio allows you to register your SIP Phones or SIP Endpoints with Twilio. SIP Registration is used to identify the location of the SIP Endpoints. Therefore, the user can receive calls irrespective of physical location of the SIP Endpoint.

This feature allows your SIP Endpoints can send REGISTER request to Twilio. For details see here.

Call Transfers using SIP REFER from Twilio

Call transfer enables you to move an active call from one endpoint to another, in SIP this is accomplished using the SIP REFER method.

Twilio supports initiating SIP REFER method from Twilio towards your IP communications infrastructure leveraging the <Refer> verb.

Call Transfers using SIP REFER to Twilio

Call transfer enables you to move an active call from one endpoint to another, in SIP this is accomplished using the SIP REFER method.

Twilio's programmable SIP call supports "blind" call transfers. This means you're now able to request a call be transferred by sending Twilio a SIP REFER message from your SIP communications infrastructure. See details here.

Parallel and Serial call using SIP

This feature allows customers to dial multiple SIP endpoints both sequentially and parallelly. See details here.

SIP Custom Header

SIP custom header allows you to send customized headers.

UUI (User-to-User Information) Header

UUI header allows you to send contextual information over the SIP call. You can check Sending-sip with UUI and Receiving-sip with UUI for further UUI details.

DTMF

Twilio supports RFC-2833 for sending and receiving DTMF.

メディアコーデック

Twilio supports G.711 μ-law (PCMU) and A-law (PCMA) codecs for media. These are the most popular codecs used by carriers so transcoding is unnecessary.

TLSを使用したSIPトラフィックの安全強化

Encryption ensures that the call signaling remains private during transmission. Transport Layer Security (TLS) provides encryption for SIP signaling.

To enable TLS, ensure that you have imported Twilio's Root CA Certificate. There is no further configuration required for TLS and you can start sending over port 5061 straight away. TLS Functionality/Port 5061 is always active and does not require a manual toggle like Secure Media. To stop using TLS, simply send SIP to Port 5060 or remove the transport=tls parameter.

SIP Interface supports the following configurations for TLS:

  • 5060 (no TLS, No Secure Media)
  • 5061 (TLS, No Secure Media)
  • 5061 (TLS, Secure Media)

For calls where TLS is active this will cause certain functionality to behave differently:

  • SIP PCAPs from the console will produce only a blank file.
  • Call meta data will continue to be available for example major error codes, start time, end time, to/from.
  • SIP Refer will function as expected using TLS.

When sending TLS SIP traffic to Twilio, you will need to ensure that your infrastructure is using next-hop domain as opposed to next-hop ip. This is a common misconfiguration and will cause a 403 error that will not be visible on your Twilio account. Traffic must be sent to the domain {example}.sip.{region}.twilio.com, rather than an IP address in order to associate the traffic with your Twilio account.

Secure Media

Secure Media uses encryption to ensure that the call media and associated signaling remains private during transmission. Secure Real-Time Protocol (SRTP) provides encryption for media. For details see here.

TLS/SRTP Specifications

  • SIP TLS
    • Versions: Twilio supports TLSv1.0, TLSv1.1 and TLSv1.2.
      Note: Twilio strongly recommends the use of TLS version 1.2.
    • Ciphers: ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-ECDSA-AES128-SHA256, ECDHE-RSA-AES128-SHA256, ECDHE-ECDSA-AES256-GCM-SHA384, ECDHE-RSA-AES256-GCM-SHA384, ECDHE-ECDSA-AES256-SHA384, ECDHE-RSA-AES256-SHA384, AES128-GCM-SHA256, AES128-SHA256, AES128-SHA, AES256-GCM-SHA384, AES256-SHA256, AES256-SHA
    • If you are using TwiML to send SIP from Twilio, to enable encryption you must use the transport=tls parameter in your SIP noun in your Dial verb.
    • By default port 5061 will be used for TLS, however, you may specify the port you wish to use in your URI.
  • Secure Media
    • Sending SRTP to Twilio: Twilio supports the following Crypto suites: AES_CM_128_HMAC_SHA1_80 and AES_CM_128_HMAC_SHA1_32. Both may be included in your order of preference.
    • Receiving SRTP from Twilio: Only a single crypto suite will be advertised: AES_CM_128_HMAC_SHA1_80
  • Importing Twilio's Root CA Certificate TLS is used to encrypt SIP signaling between SIP endpoints. In order for this to function properly it is required that certain devices in the network import a CA certificate. Twilio uses certificates from a CA (Certificate Authority). It is important that you add the following root certificate to your communications infrastructure to establish its authenticity. Download Twilio's CA certificate.

    It is important to note that Twilio uses a wildcard certificate which can be used for multiple subdomains of a domain (*.sip.twilio.com). If your network element does not support wildcarded certificates please disable certificate validation.

    Twilios Root CA contains a certificate chain signed by multiple Certificate Authorities. You should import the entire PEM file rather than individual certificates.

    Twilio does not support importing root certificates from a third party at this point in time. In order to use Twilio Voice with TLS, the Twilio Root CA must be used.

Note: Twilio SIP Interface outbound call URI configurations using the sips URI scheme in order to enable end-to-end encryption is NOT supported by Twilio. However, we do support sip URI schemes using transport=tls for point-to-point encryption.

If you configure your SIP Interface URIs to use sips schemes, these sips URIs will be handled as if they were sip URIs using TLS transport. Twilio will effectively adjust the URI internally to instead be routed using the sip scheme and transport=tls on the outbound messages, resulting in point-to-point encryption between Twilio and the customer equipment.

Twilio strongly suggests not using sips schemes in your Twilio SIP configurations, as this could cause possibly unintended behavior, due to how we process such URIs. Instead, we suggest using sip schemes with TLS transport. This method, along with the security of our voice architecture and Super Network, is an effective way of adding encryption to your Twilio SIP connections.

IP addresses

Prepare your communications infrastructure to make sure that your SIP infrastructure has connectivity to the Twilio Cloud and vice versa. To ensure that your communications infrastructure doesn’t block communication, you must update your list of allowed IP addresses. We strongly encourage you to allow all of the following IP address ranges and ports on your firewall for SIP signaling and RTP media traffic.

これは異なる地域の電話番号を使用する場合や、可用性用途(たとえば、北米ヴァージニアのゲートウェイがダウンしたときは、北米オレゴンのゲートウェイが使用されます)に重要です。

北米バージニアゲートウェイ:

シグナリングIP:

54.172.60.0
54.172.60.1
54.172.60.2
54.172.60.3
Ports: 5060 (UDP/TCP), 5061 (TLS)

メディアIP:

54.172.60.0/23
34.203.250.0/23
Port Range: 10,000 to 20,000 (UDP)

北アメリカオレゴンゲートウェイ:

シグナリングIP:

54.244.51.0
54.244.51.1
54.244.51.2
54.244.51.3
Ports: 5060 (UDP/TCP), 5061 (TLS)

メディアIP:

54.244.51.0/24
Port Range: 10,000 to 20,000 (UDP)

欧州アイルランドゲートウェイ:

シグナリングIP:

54.171.127.192
54.171.127.193
54.171.127.194
54.171.127.195
Ports: 5060 (UDP/TCP), 5061 (TLS)

メディアIP:

54.171.127.192/26
52.215.127.0/24 
Port Range: 10,000 to 20,000 (UDP)

欧州フランクフルトゲートウェイ:

シグナリングIP:

35.156.191.128
35.156.191.129
35.156.191.130
35.156.191.131
Ports: 5060 (UDP/TCP), 5061 (TLS)

メディアIP:

35.156.191.128/25 
3.122.181.0/24 Port Range: 10,000 to 20,000 (UDP)

アジア太平洋東京ゲートウェイ:

シグナリングIP:

54.65.63.192
54.65.63.193
54.65.63.194
54.65.63.195
Ports: 5060 (UDP/TCP), 5061 (TLS) 

メディアIP:

54.65.63.192/26
3.112.80.0/24 Port Range: 10,000 to 20,000 (UDP)

アジア太平洋シンガポールゲートウェイ:

シグナリングIP:

54.169.127.128
54.169.127.129
54.169.127.130
54.169.127.131
Ports: 5060 (UDP/TCP), 5061 (TLS)

メディアIP:

54.169.127.128/26
3.1.77.0/24 Port Range: 10,000 to 20,000 (UDP)

アジア太平洋シドニーゲートウェイ:

シグナリングIP:

54.252.254.64
54.252.254.65
54.252.254.66
54.252.254.67
Ports: 5060 (UDP/TCP), 5061 (TLS)

メディアIP:

54.252.254.64/26
3.104.90.0/24 Port Range: 10,000 to 20,000 (UDP)

南アメリカ サンパウロゲートウェイ

シグナリングIP:

177.71.206.192
177.71.206.193
177.71.206.194
177.71.206.195
Ports: 5060 (UDP/TCP), 5061 (TLS) 

メディアIP:

177.71.206.192/26
18.228.249.0/24 Port Range: 10,000 to 20,000 (UDP)

用語集

通信インフラ

A broad term to refer to IP-PBX, SBC, IP-phones, etc...

SIPエンドポイント

ユーザーがVoIP通話を開始するIP電話またはソフトクライアント

SIP URI

SIPにおける電話番号で、次のような形式になります。 sip:username@SIPDomain

Twilio SIP ドメイン

It takes the form {example}.sip.{region}.twilio.com where {example} is specified by the customer and {region}is the data center where the registrar is located. Initially only us1.

ページを評価:

ヘルプが必要ですか?

誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。

        
        
        

        フィードバックくださりありがとうございます!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        ステップ1

        Get link

        Get a free personal referral link here

        ステップ2:

        Give $10

        Your user signs up and upgrade using link

        ステップ3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more