[RFCs/IDs] [Plain Text] [Tracker] [WG] [Email] [Diff1] [Diff2] [Nits]

Versions: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19

MMUSIC                                                      J. Rosenberg
Internet-Draft                                                     Cisco
Obsoletes: 4091 (if approved)                           October 29, 2007
Intended status: Standards Track
Expires: May 1, 2008


  Interactive Connectivity Establishment (ICE): A Protocol for Network
     Address Translator (NAT) Traversal for Offer/Answer Protocols
                        draft-ietf-mmusic-ice-19

Status of this Memo

   By submitting this Internet-Draft, each author represents that any
   applicable patent or other IPR claims of which he or she is aware
   have been or will be disclosed, and any of which he or she becomes
   aware will be disclosed, in accordance with Section 6 of BCP 79.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF), its areas, and its working groups.  Note that
   other groups may also distribute working documents as Internet-
   Drafts.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   The list of current Internet-Drafts can be accessed at
   http://www.ietf.org/ietf/1id-abstracts.txt.

   The list of Internet-Draft Shadow Directories can be accessed at
   http://www.ietf.org/shadow.html.

   This Internet-Draft will expire on May 1, 2008.

Copyright Notice

   Copyright (C) The IETF Trust (2007).

Abstract

   This document describes a protocol for Network Address Translator
   (NAT) traversal for UDP-based multimedia sessions established with
   the offer/answer model.  This protocol is called Interactive
   Connectivity Establishment (ICE).  ICE makes use of the Session
   Traversal Utilities for NAT (STUN) protocol and its extension,
   Traversal Using Relay NAT (TURN).  ICE can be used by any protocol



Rosenberg                  Expires May 1, 2008                  [Page 1]

Internet-Draft                     ICE                      October 2007


   utilizing the offer/answer model, such as the Session Initiation
   Protocol (SIP).


Table of Contents

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   7
   2.  Overview of ICE . . . . . . . . . . . . . . . . . . . . . . .   8
     2.1.  Gathering Candidate Addresses . . . . . . . . . . . . . .  10
     2.2.  Connectivity Checks . . . . . . . . . . . . . . . . . . .  12
     2.3.  Sorting Candidates  . . . . . . . . . . . . . . . . . . .  13
     2.4.  Frozen Candidates . . . . . . . . . . . . . . . . . . . .  14
     2.5.  Security for Checks . . . . . . . . . . . . . . . . . . .  15
     2.6.  Concluding ICE  . . . . . . . . . . . . . . . . . . . . .  15
     2.7.  Lite Implementations  . . . . . . . . . . . . . . . . . .  17
   3.  Terminology . . . . . . . . . . . . . . . . . . . . . . . . .  17
   4.  Sending the Initial Offer . . . . . . . . . . . . . . . . . .  20
     4.1.  Full Implementation Requirements  . . . . . . . . . . . .  20
       4.1.1.  Gathering Candidates  . . . . . . . . . . . . . . . .  20
         4.1.1.1.  Host Candidates . . . . . . . . . . . . . . . . .  21
         4.1.1.2.  Server Reflexive and Relayed Candidates . . . . .  21
         4.1.1.3.  Computing Foundations . . . . . . . . . . . . . .  23
         4.1.1.4.  Keeping Candidates Alive  . . . . . . . . . . . .  23
       4.1.2.  Prioritizing Candidates . . . . . . . . . . . . . . .  23
         4.1.2.1.  Recommended Formula . . . . . . . . . . . . . . .  24
         4.1.2.2.  Guidelines for Choosing Type and Local
                   Preferences . . . . . . . . . . . . . . . . . . .  25
       4.1.3.  Eliminating Redundant Candidates  . . . . . . . . . .  26
       4.1.4.  Choosing Default Candidates . . . . . . . . . . . . .  26
     4.2.  Lite Implementation . . . . . . . . . . . . . . . . . . .  26
     4.3.  Encoding the SDP  . . . . . . . . . . . . . . . . . . . .  27
   5.  Receiving the Initial Offer . . . . . . . . . . . . . . . . .  29
     5.1.  Verifying ICE Support . . . . . . . . . . . . . . . . . .  29
     5.2.  Determining Role  . . . . . . . . . . . . . . . . . . . .  30
     5.3.  Gathering Candidates  . . . . . . . . . . . . . . . . . .  31
     5.4.  Prioritizing Candidates . . . . . . . . . . . . . . . . .  31
     5.5.  Choosing Default Candidates . . . . . . . . . . . . . . .  31
     5.6.  Encoding the SDP  . . . . . . . . . . . . . . . . . . . .  32
     5.7.  Forming the Check Lists . . . . . . . . . . . . . . . . .  32
       5.7.1.  Forming Candidate Pairs . . . . . . . . . . . . . . .  32
       5.7.2.  Computing Pair Priority and Ordering Pairs  . . . . .  35
       5.7.3.  Pruning the Pairs . . . . . . . . . . . . . . . . . .  35
       5.7.4.  Computing States  . . . . . . . . . . . . . . . . . .  35
     5.8.  Scheduling Checks . . . . . . . . . . . . . . . . . . . .  38
   6.  Receipt of the Initial Answer . . . . . . . . . . . . . . . .  40
     6.1.  Verifying ICE Support . . . . . . . . . . . . . . . . . .  40
     6.2.  Determining Role  . . . . . . . . . . . . . . . . . . . .  40
     6.3.  Forming the Check List  . . . . . . . . . . . . . . . . .  41



Rosenberg                  Expires May 1, 2008                  [Page 2]

Internet-Draft                     ICE                      October 2007


     6.4.  Performing Ordinary Checks  . . . . . . . . . . . . . . .  41
   7.  Performing Connectivity Checks  . . . . . . . . . . . . . . .  41
     7.1.  STUN Client Procedures  . . . . . . . . . . . . . . . . .  41
       7.1.1.  Sending the Request . . . . . . . . . . . . . . . . .  41
         7.1.1.1.  PRIORITY and USE-CANDIDATE  . . . . . . . . . . .  42
         7.1.1.2.  ICE-CONTROLLED and ICE-CONTROLLING  . . . . . . .  42
         7.1.1.3.  Forming Credentials . . . . . . . . . . . . . . .  42
         7.1.1.4.  DiffServ Treatment  . . . . . . . . . . . . . . .  42
       7.1.2.  Processing the Response . . . . . . . . . . . . . . .  43
         7.1.2.1.  Failure Cases . . . . . . . . . . . . . . . . . .  43
         7.1.2.2.  Success Cases . . . . . . . . . . . . . . . . . .  43
           7.1.2.2.1.  Discovering Peer Reflexive Candidates . . . .  44
           7.1.2.2.2.  Constructing a Valid Pair . . . . . . . . . .  44
           7.1.2.2.3.  Updating Pair States  . . . . . . . . . . . .  45
           7.1.2.2.4.  Updating the Nominated Flag . . . . . . . . .  46
         7.1.2.3.  Check List and Timer State Updates  . . . . . . .  46
     7.2.  STUN Server Procedures  . . . . . . . . . . . . . . . . .  47
       7.2.1.  Additional Procedures for Full Implementations  . . .  48
         7.2.1.1.  Detecting and Repairing Role Conflicts  . . . . .  48
         7.2.1.2.  Computing Mapped Address  . . . . . . . . . . . .  49
         7.2.1.3.  Learning Peer Reflexive Candidates  . . . . . . .  49
         7.2.1.4.  Triggered Checks  . . . . . . . . . . . . . . . .  50
         7.2.1.5.  Updating the Nominated Flag . . . . . . . . . . .  51
       7.2.2.  Additional Procedures for Lite Implementations  . . .  51
   8.  Concluding ICE Processing . . . . . . . . . . . . . . . . . .  51
     8.1.  Procedures for Full Implementations . . . . . . . . . . .  52
       8.1.1.  Nominating Pairs  . . . . . . . . . . . . . . . . . .  52
         8.1.1.1.  Regular Nomination  . . . . . . . . . . . . . . .  52
         8.1.1.2.  Aggressive Nomination . . . . . . . . . . . . . .  53
       8.1.2.  Updating States . . . . . . . . . . . . . . . . . . .  53
     8.2.  Procedures for Lite Implementations . . . . . . . . . . .  54
       8.2.1.  Peer is Full  . . . . . . . . . . . . . . . . . . . .  55
       8.2.2.  Peer is Lite  . . . . . . . . . . . . . . . . . . . .  55
     8.3.  Freeing Candidates  . . . . . . . . . . . . . . . . . . .  56
       8.3.1.  Full Implementation Procedures  . . . . . . . . . . .  56
       8.3.2.  Lite Implementations  . . . . . . . . . . . . . . . .  56
   9.  Subsequent Offer/Answer Exchanges . . . . . . . . . . . . . .  56
     9.1.  Generating the Offer  . . . . . . . . . . . . . . . . . .  57
       9.1.1.  Procedures for All Implementations  . . . . . . . . .  57
         9.1.1.1.  ICE Restarts  . . . . . . . . . . . . . . . . . .  57
         9.1.1.2.  Removing a Media Stream . . . . . . . . . . . . .  58
         9.1.1.3.  Adding a Media Stream . . . . . . . . . . . . . .  58
       9.1.2.  Procedures for Full Implementations . . . . . . . . .  58
         9.1.2.1.  Existing Media Streams with ICE Running . . . . .  58
         9.1.2.2.  Existing Media Streams with ICE Completed . . . .  59
       9.1.3.  Procedures for Lite Implementations . . . . . . . . .  59
         9.1.3.1.  Existing Media Streams with ICE Running . . . . .  59
         9.1.3.2.  Existing Media Streams with ICE Completed . . . .  60



Rosenberg                  Expires May 1, 2008                  [Page 3]

Internet-Draft                     ICE                      October 2007


     9.2.  Receiving the Offer and Generating an Answer  . . . . . .  60
       9.2.1.  Procedures for All Implementations  . . . . . . . . .  60
         9.2.1.1.  Detecting ICE Restart . . . . . . . . . . . . . .  60
         9.2.1.2.  New Media Stream  . . . . . . . . . . . . . . . .  61
         9.2.1.3.  Removed Media Stream  . . . . . . . . . . . . . .  61
       9.2.2.  Procedures for Full Implementations . . . . . . . . .  61
         9.2.2.1.  Existing Media Streams with ICE Running and no
                   remote-candidates . . . . . . . . . . . . . . . .  61
         9.2.2.2.  Existing Media Streams with ICE Completed and
                   no remote-candidates  . . . . . . . . . . . . . .  61
         9.2.2.3.  Existing Media Streams and remote-candidates  . .  61
       9.2.3.  Procedures for Lite Implementations . . . . . . . . .  62
     9.3.  Updating the Check and Valid Lists  . . . . . . . . . . .  63
       9.3.1.  Procedures for Full Implementations . . . . . . . . .  63
         9.3.1.1.  ICE Restarts  . . . . . . . . . . . . . . . . . .  63
         9.3.1.2.  New Media Stream  . . . . . . . . . . . . . . . .  63
         9.3.1.3.  Removed Media Stream  . . . . . . . . . . . . . .  64
         9.3.1.4.  ICE Continuing for Existing Media Stream  . . . .  64
       9.3.2.  Procedures for Lite Implementations . . . . . . . . .  64
   10. Keepalives  . . . . . . . . . . . . . . . . . . . . . . . . .  65
   11. Media Handling  . . . . . . . . . . . . . . . . . . . . . . .  66
     11.1. Sending Media . . . . . . . . . . . . . . . . . . . . . .  66
       11.1.1. Procedures for Full Implementations . . . . . . . . .  66
       11.1.2. Procedures for Lite Implementations . . . . . . . . .  67
       11.1.3. Procedures for All Implementations  . . . . . . . . .  67
     11.2. Receiving Media . . . . . . . . . . . . . . . . . . . . .  67
   12. Usage with SIP  . . . . . . . . . . . . . . . . . . . . . . .  68
     12.1. Latency Guidelines  . . . . . . . . . . . . . . . . . . .  68
       12.1.1. Offer in INVITE . . . . . . . . . . . . . . . . . . .  68
       12.1.2. Offer in Response . . . . . . . . . . . . . . . . . .  69
     12.2. SIP Option Tags and Media Feature Tags  . . . . . . . . .  70
     12.3. Interactions with Forking . . . . . . . . . . . . . . . .  70
     12.4. Interactions with Preconditions . . . . . . . . . . . . .  70
     12.5. Interactions with Third Party Call Control  . . . . . . .  71
   13. Relationship with ANAT  . . . . . . . . . . . . . . . . . . .  71
   14. Extensibility Considerations  . . . . . . . . . . . . . . . .  72
   15. Grammar . . . . . . . . . . . . . . . . . . . . . . . . . . .  73
     15.1. "candidate" Attribute . . . . . . . . . . . . . . . . . .  73
     15.2. "remote-candidates" Attribute . . . . . . . . . . . . . .  75
     15.3. "ice-lite" and "ice-mismatch" Attributes  . . . . . . . .  75
     15.4. "ice-ufrag" and "ice-pwd" Attributes  . . . . . . . . . .  76
     15.5. "ice-options" Attribute . . . . . . . . . . . . . . . . .  76
   16. Setting Ta and RTO  . . . . . . . . . . . . . . . . . . . . .  77
     16.1. RTP Media Streams . . . . . . . . . . . . . . . . . . . .  77
     16.2. Non-RTP Sessions  . . . . . . . . . . . . . . . . . . . .  78
   17. Example . . . . . . . . . . . . . . . . . . . . . . . . . . .  79
   18. Security Considerations . . . . . . . . . . . . . . . . . . .  86
     18.1. Attacks on Connectivity Checks  . . . . . . . . . . . . .  86



Rosenberg                  Expires May 1, 2008                  [Page 4]

Internet-Draft                     ICE                      October 2007


     18.2. Attacks on Server Reflexive Address Gathering . . . . . .  89
     18.3. Attacks on Relayed Candidate Gathering  . . . . . . . . .  89
     18.4. Attacks on the Offer/Answer Exchanges . . . . . . . . . .  90
     18.5. Insider Attacks . . . . . . . . . . . . . . . . . . . . .  90
       18.5.1. The Voice Hammer Attack . . . . . . . . . . . . . . .  90
       18.5.2. STUN Amplification Attack . . . . . . . . . . . . . .  91
     18.6. Interactions with Application Layer Gateways and SIP  . .  92
   19. STUN Extensions . . . . . . . . . . . . . . . . . . . . . . .  93
     19.1. New Attributes  . . . . . . . . . . . . . . . . . . . . .  93
     19.2. New Error Response Codes  . . . . . . . . . . . . . . . .  93
   20. Operational Considerations  . . . . . . . . . . . . . . . . .  94
     20.1. NAT and Firewall Types  . . . . . . . . . . . . . . . . .  94
     20.2. Bandwidth Requirements  . . . . . . . . . . . . . . . . .  94
       20.2.1. STUN and TURN Server Capacity Planning  . . . . . . .  94
       20.2.2. Gathering and Connectivity Checks . . . . . . . . . .  95
       20.2.3. Keepalives  . . . . . . . . . . . . . . . . . . . . .  95
     20.3. ICE and ICE-lite  . . . . . . . . . . . . . . . . . . . .  95
     20.4. Troubleshooting and Performance Management  . . . . . . .  96
     20.5. Endpoint Configuration  . . . . . . . . . . . . . . . . .  96
   21. IANA Considerations . . . . . . . . . . . . . . . . . . . . .  96
     21.1. SDP Attributes  . . . . . . . . . . . . . . . . . . . . .  96
       21.1.1. candidate Attribute . . . . . . . . . . . . . . . . .  97
       21.1.2. remote-candidates Attribute . . . . . . . . . . . . .  97
       21.1.3. ice-lite Attribute  . . . . . . . . . . . . . . . . .  97
       21.1.4. ice-mismatch Attribute  . . . . . . . . . . . . . . .  98
       21.1.5. ice-pwd Attribute . . . . . . . . . . . . . . . . . .  98
       21.1.6. ice-ufrag Attribute . . . . . . . . . . . . . . . . .  99
       21.1.7. ice-options Attribute . . . . . . . . . . . . . . . .  99
     21.2. STUN Attributes . . . . . . . . . . . . . . . . . . . . . 100
     21.3. STUN Error Responses  . . . . . . . . . . . . . . . . . . 100
   22. IAB Considerations  . . . . . . . . . . . . . . . . . . . . . 100
     22.1. Problem Definition  . . . . . . . . . . . . . . . . . . . 100
     22.2. Exit Strategy . . . . . . . . . . . . . . . . . . . . . . 101
     22.3. Brittleness Introduced by ICE . . . . . . . . . . . . . . 101
     22.4. Requirements for a Long Term Solution . . . . . . . . . . 102
     22.5. Issues with Existing NAPT Boxes . . . . . . . . . . . . . 103
   23. Acknowledgements  . . . . . . . . . . . . . . . . . . . . . . 103
   24. References  . . . . . . . . . . . . . . . . . . . . . . . . . 104
     24.1. Normative References  . . . . . . . . . . . . . . . . . . 104
     24.2. Informative References  . . . . . . . . . . . . . . . . . 105
   Appendix A.  Lite and Full Implementations  . . . . . . . . . . . 107
   Appendix B.  Design Motivations . . . . . . . . . . . . . . . . . 108
     B.1.  Pacing of STUN Transactions . . . . . . . . . . . . . . . 108
     B.2.  Candidates with Multiple Bases  . . . . . . . . . . . . . 110
     B.3.  Purpose of the <rel-addr> and <rel-port> Attributes . . . 112
     B.4.  Importance of the STUN Username . . . . . . . . . . . . . 112
     B.5.  The Candidate Pair Priority Formula . . . . . . . . . . . 113
     B.6.  The remote-candidates attribute . . . . . . . . . . . . . 114



Rosenberg                  Expires May 1, 2008                  [Page 5]

Internet-Draft                     ICE                      October 2007


     B.7.  Why are Keepalives Needed?  . . . . . . . . . . . . . . . 115
     B.8.  Why Prefer Peer Reflexive Candidates? . . . . . . . . . . 116
     B.9.  Why Send an Updated Offer?  . . . . . . . . . . . . . . . 116
     B.10. Why are Binding Indications Used for Keepalives?  . . . . 116
     B.11. Why is the Conflict Resolution Mechanism Needed?  . . . . 117
   Author's Address  . . . . . . . . . . . . . . . . . . . . . . . . 118
   Intellectual Property and Copyright Statements  . . . . . . . . . 119












































Rosenberg                  Expires May 1, 2008                  [Page 6]

Internet-Draft                     ICE                      October 2007


1.  Introduction

   RFC 3264 [RFC3264] defines a two-phase exchange of Session
   Description Protocol (SDP) messages [RFC4566] for the purposes of
   establishment of multimedia sessions.  This offer/answer mechanism is
   used by protocols such as the Session Initiation Protocol (SIP)
   [RFC3261].

   Protocols using offer/answer are difficult to operate through Network
   Address Translators (NAT).  Because their purpose is to establish a
   flow of media packets, they tend to carry the IP addresses and ports
   of media sources and sinks within their messages, which is known to
   be problematic through NAT [RFC3235].  The protocols also seek to
   create a media flow directly between participants, so that there is
   no application layer intermediary between them.  This is done to
   reduce media latency, decrease packet loss, and reduce the
   operational costs of deploying the application.  However, this is
   difficult to accomplish through NAT.  A full treatment of the reasons
   for this is beyond the scope of this specification.

   Numerous solutions have been defined for allowing these protocols to
   operate through NAT.  These include Application Layer Gateways
   (ALGs), the Middlebox Control Protocol [RFC3303], the original Simple
   Traversal of UDP Through NAT (STUN) [RFC3489] specification, and
   Realm Specific IP [RFC3102] [RFC3103] along with session description
   extensions needed to make them work, such as the Session Description
   Protocol (SDP) [RFC4566] attribute for the Real Time Control Protocol
   (RTCP) [RFC3605].  Unfortunately, these techniques all have pros and
   cons which make each one optimal in some network topologies, but a
   poor choice in others.  The result is that administrators and
   implementors are making assumptions about the topologies of the
   networks in which their solutions will be deployed.  This introduces
   complexity and brittleness into the system.  What is needed is a
   single solution which is flexible enough to work well in all
   situations.

   This specification defines Interactive Connectivity Establishment
   (ICE) as a technique for NAT traversal for UDP-based media streams
   (though ICE can be extended to handle other transport protocols, such
   as TCP [I-D.ietf-mmusic-ice-tcp]) established by the offer/answer
   model.  ICE is an extension to the offer/answer model, and works by
   including a multiplicity of IP addresses and ports in SDP offers and
   answers, which are then tested for connectivity by peer-to-peer
   connectivity checks.  The IP addresses and ports included in the SDP
   and the connectivity checks are performed using the revised STUN
   specification [I-D.ietf-behave-rfc3489bis], now renamed to Session
   Traversal Utilities for NAT.  The new name and new specification
   reflect its new role as a tool that is used with other NAT traversal



Rosenberg                  Expires May 1, 2008                  [Page 7]

Internet-Draft                     ICE                      October 2007


   techniques (namely ICE) rather than a standalone NAT traversal
   solution, as the original STUN specification was.  ICE also makes use
   of Traversal Using Relay NAT (TURN) [I-D.ietf-behave-turn], an
   extension to STUN.  Because ICE exchanges a multiplicity of IP
   addresses and ports for each media stream, it also allows for address
   selection for multi-homed and dual-stack hosts, and for this reason
   it deprecates RFC 4091 [RFC4091].


2.  Overview of ICE

   In a typical ICE deployment, we have two endpoints (known as AGENTS
   in RFC 3264 terminology) which want to communicate.  They are able to
   communicate indirectly via some signaling protocol (such as SIP), by
   which they can perform an offer/answer exchange of SDP [RFC3264]
   messages.  Note that ICE is not intended for NAT traversal for SIP,
   which is assumed to be provided via another mechanism
   [I-D.ietf-sip-outbound].  At the beginning of the ICE process, the
   agents are ignorant of their own topologies.  In particular, they
   might or might not be behind a NAT (or multiple tiers of NATs).  ICE
   allows the agents to discover enough information about their
   topologies to potentially find one or more paths by which they can
   communicate.

   Figure 1 shows a typical environment for ICE deployment.  The two
   endpoints are labelled L and R (for left and right, which helps
   visualize call flows).  Both L and R are behind their own respective
   NATs though they may not be aware of it.  The type of NAT and its
   properties are also unknown.  Agents L and R are capable of engaging
   in an offer/answer exchange by which they can exchange SDP messages,
   whose purpose is to set up a media session between L and R.
   Typically, this exchange will occur through a SIP server.

   In addition to the agents, a SIP server and NATs, ICE is typically
   used in concert with STUN or TURN servers in the network.  Each agent
   can have its own STUN or TURN server, or they can be the same.















Rosenberg                  Expires May 1, 2008                  [Page 8]

Internet-Draft                     ICE                      October 2007


                              +-------+
                              | SIP   |
           +-------+          | Srvr  |          +-------+
           | STUN  |          |       |          | STUN  |
           | Srvr  |          +-------+          | Srvr  |
           |       |         /         \         |       |
           +-------+        /           \        +-------+
                           /             \
                          /               \
                         /                 \
                        /                   \
                       /  <-  Signalling ->  \
                      /                       \
                     /                         \
               +--------+                   +--------+
               |  NAT   |                   |  NAT   |
               +--------+                   +--------+
                 /                                \
                /                                  \
               /                                    \
           +-------+                             +-------+
           | Agent |                             | Agent |
           |   L   |                             |   R   |
           |       |                             |       |
           +-------+                             +-------+

                     Figure 1: ICE Deployment Scenario

   The basic idea behind ICE is as follows: each agent has a variety of
   candidate TRANSPORT ADDRESSES (combination of IP address and port for
   a particular transport protocol, which is always UDP in this
   specification)) it could use to communicate with the other agent.
   These might include:

   o  A transport address on a directly attached network interface

   o  A translated transport address on the public side of a NAT (a
      "server reflexive" address)

   o  The transport address allocated from a TURN server(a "relayed
      address".

   Potentially, any of L's candidate transport addresses can be used to
   communicate with any of R's candidate transport addresses.  In
   practice, however, many combinations will not work.  For instance, if
   L and R are both behind NATs, their directly attached interface
   addresses are unlikely to be able to communicate directly (this is
   why ICE is needed, after all!).  The purpose of ICE is to discover



Rosenberg                  Expires May 1, 2008                  [Page 9]

Internet-Draft                     ICE                      October 2007


   which pairs of addresses will work.  The way that ICE does this is to
   systematically try all possible pairs (in a carefully sorted order)
   until it finds one or more that works.

2.1.  Gathering Candidate Addresses

   In order to execute ICE, an agent has to identify all of its address
   candidates.  A CANDIDATE is a transport address - a combination of IP
   address and port for a particular transport protocol (with only UDP
   specified here).  This document defines three types of candidates,
   some derived from physical or logical network interfaces, others
   discoverable via STUN and TURN.  Naturally, one viable candidate is a
   transport address obtained directly from a local interface.  Such a
   candidate is called a HOST CANDIDATE.  The local interface could be
   ethernet or WiFi, or it could be one that is obtained through a
   tunnel mechanism, such as a Virtual Private Network (VPN) or Mobile
   IP (MIP).  In all cases, such a network interface appears to the
   agent as a local interface from which ports (and thus candidates) can
   be allocated.

   If an agent is multihomed, it obtains a candidate from each IP
   address.  Depending on the location of the PEER (the other agent in
   the session) on the IP network relative to the agent, the agent may
   be reachable by the peer through one or more of those IP addresses.
   Consider, for example, an agent which has a local IP address on a
   private net 10 network (I1), and a second connected to the public
   Internet (I2).  A candidate from I1 will be directly reachable when
   communicating with a peer on the same private net 10 network, while a
   candidate from I2 will be directly reachable when communicating with
   a peer on the public Internet.  Rather than trying to guess which IP
   address will work prior to sending an offer, the offering agent
   includes both candidates in its offer.

   Next, the agent uses STUN or TURN to obtain additional candidates.
   These come in two flavors: translated addresses on the public side of
   a NAT (SERVER REFLEXIVE CANDIDATES) and addresses on TURN servers
   (RELAYED CANDIDATES).  When TURN servers are utilized, both types of
   candidates are obtained from the TURN server.  If only STUN servers
   are utilized, only server reflexive candidates are obtained from
   them.  The relationship of these candidates to the host candidate is
   shown in Figure 2.  In this figure, both types of candidates are
   discovered using TURN.  In the figure, the notation X:x means IP
   address X and UDP port x.








Rosenberg                  Expires May 1, 2008                 [Page 10]

Internet-Draft                     ICE                      October 2007


                 To Internet

                     |
                     |
                     |  /------------  Relayed
                 Y:y | /               Address
                 +--------+
                 |        |
                 |  TURN  |
                 | Server |
                 |        |
                 +--------+
                     |
                     |
                     | /------------  Server
              X1':x1'|/               Reflexive
               +------------+         Address
               |    NAT     |
               +------------+
                     |
                     | /------------  Local
                 X:x |/               Address
                 +--------+
                 |        |
                 | Agent  |
                 |        |
                 +--------+


                     Figure 2: Candidate Relationships

   When the agent sends the TURN Allocate Request from IP address and
   port X:x, the NAT (assuming there is one) will create a binding
   X1':x1', mapping this server reflexive candidate to the host
   candidate X:x.  Outgoing packets sent from the host candidate will be
   translated by the NAT to the server reflexive candidate.  Incoming
   packets sent to the server reflexive candidate will be translated by
   the NAT to the host candidate and forwarded to the agent.  We call
   the host candidate associated with a given server reflexive candidate
   the BASE.

      NOTE: "Base" refers to the address an agent sends from for a
      particular candidate.  Thus, as a degenerate case host candidates
      also have a base, but it's the same as the host candidate.

   When there are multiple NATs between the agent and the TURN server,
   the TURN request will create a binding on each NAT, but only the
   outermost server reflexive candidate (the one nearest the TURN



Rosenberg                  Expires May 1, 2008                 [Page 11]

Internet-Draft                     ICE                      October 2007


   server) will be discovered by the agent.  If the agent is not behind
   a NAT, then the base candidate will be the same as the server
   reflexive candidate and the server reflexive candidate is redundant
   and will be eliminated.

   The Allocate request then arrives at the TURN server.  The TURN
   server allocates a port y from its local IP address Y, and generates
   an Allocate response, informing the agent of this relayed candidate.
   The TURN server also informs the agent of the server reflexive
   candidate, X1':x1' by copying the source transport address of the
   Allocate request into the Allocate response.  The TURN server acts as
   a packet relay, forwarding traffic between L and R. In order to send
   traffic to L, R sends traffic to the TURN server at Y:y, and the TURN
   server forwards that to X1':x1', which passes through the NAT where
   it is mapped to X:x and delivered to L.

   When only STUN servers are utilized, the agent sends a STUN Binding
   Request [I-D.ietf-behave-rfc3489bis] to its STUN server.  The STUN
   server will inform the agent of the server reflexive candidate
   X1':x1' by copying the source transport address of the Binding
   request into the Binding response.

2.2.  Connectivity Checks

   Once L has gathered all of its candidates, it orders them in highest
   to lowest priority and sends them to R over the signalling channel.
   The candidates are carried in attributes in the SDP offer.  When R
   receives the offer, it performs the same gathering process and
   responds with its own list of candidates.  At the end of this
   process, each agent has a complete list of both its candidates and
   its peer's candidates.  It pairs them up, resulting in CANDIDATE
   PAIRS.  To see which pairs work, each agent schedules a series of
   CHECKS.  Each check is a STUN request/response transaction that the
   client will perform on a particular candidate pair by sending a STUN
   request from the local candidate to the remote candidate.

   The basic principle of the connectivity checks is simple:

   1.  Sort the candidate pairs in priority order.

   2.  Send checks on each candidate pair in priority order.

   3.  Acknowledge checks received from the other agent.

   With both agents performing a check on a candidate pair, the result
   is a 4-way handshake:





Rosenberg                  Expires May 1, 2008                 [Page 12]

Internet-Draft                     ICE                      October 2007


   L                        R
   -                        -
   STUN request ->             \  L's
             <- STUN response  /  check

              <- STUN request  \  R's
   STUN response ->            /  check

                    Figure 3: Basic Connectivity Check

   It is important to note that the STUN requests are sent to and from
   the exact same IP addresses and ports that will be used for media
   (e.g., RTP and RTCP).  Consequently, agents demultiplex STUN and RTP/
   RTCP using contents of the packets, rather than the port on which
   they are received.  Fortunately, this demultiplexing is easy to do,
   especially for RTP and RTCP.

   Because a STUN Binding Request is used for the connectivity check,
   the STUN Binding response will contain the agent's translated
   transport address on the public side any NATs between the agent and
   its peer.  If this transport address is different from other
   candidates the agent already learned, it represents a new candidate,
   called a PEER REFLEXIVE CANDIDATE, which then gets tested by ICE just
   the same as any other candidate.

   As an optimization, as soon as R gets L's check message, R schedules
   a connectivity check message to be sent to L on the same candidate
   pair.  This accelerates the process of finding a valid candidate, and
   is called a TRIGGERED CHECK.

   At the end of this handshake, both L and R know that they can send
   (and receive) messages end-to-end in both directions.

2.3.  Sorting Candidates

   Because the algorithm above searches all candidate pairs, if a
   working pair exists it will eventually find it no matter what order
   the candidates are tried in.  In order to produce faster (and better)
   results, the candidates are sorted in a specified order.  The
   resulting list of sorted candidate pairs is called the CHECK LIST.
   The algorithm is described in Section 4.1.2 but follows two general
   principles:

   o  Each agent gives its candidates a numeric priority which is sent
      along with the candidate to the peer

   o  The local and remote priorities are combined so that each agent
      has the same ordering for the candidate pairs.



Rosenberg                  Expires May 1, 2008                 [Page 13]

Internet-Draft                     ICE                      October 2007


   The second property is important for getting ICE to work when there
   are NATs in front of L and R. Frequently, NATs will not allow packets
   in from a host until the agent behind the NAT has sent a packet
   towards that host.  Consequently, ICE checks in each direction will
   not succeed until both sides have sent a check through their
   respective NATs.

   The agent works through this check list by sending a STUN request for
   the next candidate pair on the list periodically.  These are called
   ORDINARY CHECKS.

   In general the priority algorithm is designed so that candidates of
   similar type get similar priorities and so that more direct routes
   (that is, through fewer media relays and through fewer NATs) are
   preferred over indirect ones (ones with more media relays and more
   NATs).  Within those guidelines, however, agents have a fair amount
   of discretion about how to tune their algorithms.

2.4.  Frozen Candidates

   The previous description only addresses the case where the agents
   wish to establish a media session with one COMPONENT (a piece of a
   media stream requiring a single transport address; a media stream may
   require multiple components, each of which has to work for the media
   stream as a whole to be work).  Typically, (e.g., with RTP and RTCP)
   the agents actually need to establish connectivity for more than one
   flow.

   The network properties are likely to be very similar for each
   component (especially because RTP and RTCP are sent and received from
   the same IP address).  It is usually possible to leverage information
   from one media component in order to determine the best candidates
   for another.  ICE does this with a mechanism called "frozen
   candidates."

   Each candidate is associated with a property called its FOUNDATION.
   Two candidates have the same foundation when they are "similar" - of
   the same type and obtained from the same host candidate and STUN
   server using the same protocol.  Otherwise, their foundation is
   different.  A candidate pair has a foundation too, which is just the
   concatenation of the foundations of its two candidates.  Initially,
   only the candidate pairs with unique foundations are tested.  The
   other candidate pairs are marked "frozen".  When the connectivity
   checks for a candidate pair succeed, the other candidate pairs with
   the same foundation are unfrozen.  This avoids repeated checking of
   components which are superficially more attractive but in fact are
   likely to fail.




Rosenberg                  Expires May 1, 2008                 [Page 14]

Internet-Draft                     ICE                      October 2007


   While we've described "frozen" here as a separate mechanism for
   expository purposes, in fact it is an integral part of ICE and the
   the ICE prioritization algorithm automatically ensures that the right
   candidates are unfrozen and checked in the right order.

2.5.  Security for Checks

   Because ICE is used to discover which addresses can be used to send
   media between two agents, it is important to ensure that the process
   cannot be hijacked to send media to the wrong location.  Each STUN
   connectivity check is covered by a message authentication code (MAC)
   computed using a key exchanged in the signalling channel.  This MAC
   provides message integrity and data origin authentication, thus
   stopping an attacker from forging or modifying connectivity check
   messages.  Furthermore, if the SIP [RFC3261] caller is using ICE, and
   their call forks, the ICE exchanges happen independently with each
   forked recipient.  In such a case, the keys exchanged in the
   signaling help associate each ICE exchange with each forked
   recipient.

2.6.  Concluding ICE

   ICE checks are performed in a specific sequence, so that high
   priority candidate pairs are checked first, followed by lower
   priority ones.  One way to conclude ICE is to declare victory as soon
   as a check for each component of each media stream completes
   successfully.  Indeed, this is a reasonable algorithm, and details
   for it are provided below.  However, it is possible that a packet
   loss will cause a higher priority check to take longer to complete.
   In that case, allowing ICE to run a little longer might produce
   better results.  More fundamentally, however, the prioritization
   defined by this specification may not yield "optimal" results.  As an
   example, if the aim is to select low latency media paths, usage of a
   relay is a hint that latencies may be higher, but it is nothing more
   than a hint.  An actual RTT measurement could be made, and it might
   demonstrate that a pair with lower priority is actually better than
   one with higher priority.

   Consequently, ICE assigns one of the agents in the role of the
   CONTROLLING AGENT, and the other of the CONTROLLED AGENT.  The
   controlling agent gets to nominate which candidate pairs will get
   used for media amongst the ones that are valid.  It can do this in
   one of two ways - using REGULAR NOMINATION or AGGRESSIVE NOMINATION.

   With regular nomination, the controlling agent lets the checks
   continue until at least one valid candidate pair for each media
   stream is found.  Then, it picks amongst those that are valid, and
   sends a second STUN request on its NOMINATED candidate pair, but this



Rosenberg                  Expires May 1, 2008                 [Page 15]

Internet-Draft                     ICE                      October 2007


   time with a flag set to tell the peer that this pair has been
   nominated for use.  This is shown in Figure 4.


   L                        R
   -                        -
   STUN request ->             \  L's
             <- STUN response  /  check

              <- STUN request  \  R's
   STUN response ->            /  check

   STUN request + flag ->      \  L's
             <- STUN response  /  check


                       Figure 4: Regular Nomination

   Once the STUN transaction with the flag completes, both sides cancel
   any future checks for that media stream.  ICE will now send media
   using this pair.  The pair an ICE agent is using for media is called
   the SELECTED PAIR.

   In aggressive nomination, the controlling agent puts the flag in
   every STUN request it sends.  This way, once the first check
   succeeds, ICE processing is complete for that media stream and the
   controlling agent doesn't have to send a second STUN request.  The
   selected pair will be the highest priority valid pair whose check
   succeeded.  Aggressive nomination is faster than regular nomination,
   but gives less flexibility.  Aggressive nomination is shown in
   Figure 5.


   L                        R
   -                        -
   STUN request + flag ->      \  L's
             <- STUN response  /  check

              <- STUN request  \  R's
   STUN response ->            /  check


                      Figure 5: Aggressive Nomination

   Once all of the media streams are completed, the controlling endpoint
   sends an updated offer if the candidates in the m and c lines for the
   media stream (called the DEFAULT CANDIDATES) don't match ICE's
   SELECTED CANDIDATES.



Rosenberg                  Expires May 1, 2008                 [Page 16]

Internet-Draft                     ICE                      October 2007


   Once ICE is concluded, it can be restarted at any time for one or all
   of the media streams by either agent.  This is done by sending an
   updated offer indicating a restart.

2.7.  Lite Implementations

   In order for ICE to be used in a call, both agents need to support
   it.  However, certain agents will always be connected to the public
   Internet and have a public IP address at which it can receive packets
   from any correspondent.  To make it easier for these devices to
   support ICE, ICE defines a special type of implementation called LITE
   (in contrast to the normal FULL implementation).  A lite
   implementation doesn't gather candidates; it includes only host
   candidates for any media stream.  Lite agents do not generate
   connectivity checks or run the state machines, though they need to be
   able to respond to connectivity checks.  When a lite implementation
   connects with a full implementation, the full agent takes the role of
   the controlling agent, and the lite agent takes on the controlled
   role.  When two lite implementations connect, no checks are sent.

   For guidance on when a lite implementation is appropriate, see the
   discussion in Appendix A.

   It is important to note that the lite implementation was added to
   this specification to provide a stepping stone to full
   implementation.  Even for devices that are always connected to the
   public Internet, a full implementation is preferable if achievable.


3.  Terminology

   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
   document are to be interpreted as described in RFC 2119 [RFC2119].

   Readers should be familiar with the terminology defined in the offer/
   answer model [RFC3264], STUN [I-D.ietf-behave-rfc3489bis] and NAT
   Behavioral requirements for UDP [RFC4787]

   This specification makes use of the following additional terminology:

   Agent:  As defined in RFC 3264, an agent is the protocol
      implementation involved in the offer/answer exchange.  There are
      two agents involved in an offer/answer exchange.







Rosenberg                  Expires May 1, 2008                 [Page 17]

Internet-Draft                     ICE                      October 2007


   Peer:  From the perspective of one of the agents in a session, its
      peer is the other agent.  Specifically, from the perspective of
      the offerer, the peer is the answerer.  From the perspective of
      the answerer, the peer is the offerer.

   Transport Address:  The combination of an IP address and transport
      protocol (such as UDP or TCP) port.

   Candidate:  A transport address that is a potential point of contact
      for receipt of media.  Candidates also have properties - their
      type (server reflexive, relayed or host), priority, foundation,
      and base.

   Component:  A component is a piece of a media stream requiring a
      single transport address; a media stream may require multiple
      components, each of which has to work for the media stream as a
      whole to work.  For media streams based on RTP, there are two
      components per media stream - one for RTP, and one for RTCP.

   Host Candidate:  A candidate obtained by binding to a specific port
      from an IP address on the host.  This includes IP addresses on
      physical interfaces and logical ones, such as ones obtained
      through Virtual Private Networks (VPNs) and Realm Specific IP
      (RSIP) [RFC3102] (which lives at the operating system level).

   Server Reflexive Candidate:  A candidate whose IP address and port
      are a binding allocated by a NAT for an agent when it sent a
      packet through the NAT to a server.  Server reflexive candidates
      can be learned by STUN servers using the Binding Request, or TURN
      servers, which provides both a Relayed and Server Reflexive
      candidate.

   Peer Reflexive Candidate:  A candidate whose IP address and port are
      a binding allocated by a NAT for an agent when it sent a STUN
      Binding Request through the NAT to its peer.

   Relayed Candidate:  A candidate obtained by sending a TURN Allocate
      request from a host candidate to a TURN server.  The relayed
      candidate is resident on the TURN server, and the TURN server
      relays packets back towards the agent.

   Base:  The base of a server reflexive candidate is the host candidate
      from which it was derived.  A host candidate is also said to have
      a base, equal to that candidate itself.  Similarly, the base of a
      relayed candidate is that candidate itself.






Rosenberg                  Expires May 1, 2008                 [Page 18]

Internet-Draft                     ICE                      October 2007


   Foundation:  An arbitrary string that is the same for two candidates
      that have the same type, base IP address, protocol (UDP, TCP,
      etc.) and STUN or TURN server.  If any of these are different then
      the foundation will be different.  Two candidate pairs with the
      same foundation pairs are likely to have similar network
      characteristics.  Foundations are used in the frozen algorithm.

   Local Candidate:  A candidate that an agent has obtained and included
      in an offer or answer it sent.

   Remote Candidate:  A candidate that an agent received in an offer or
      answer from its peer.

   Default Destination/Candidate:  The default destination for a
      component of a media stream is the transport address that would be
      used by an agent that is not ICE aware.  For the RTP component,
      the default IP address is in the c line of the SDP, and the port
      in the m line.  For the RTCP component it is in the rtcp attribute
      when present, and when not present, the IP address in the c line
      and 1 plus the port in the m line.  A default candidate for a
      component is one whose transport address matches the default
      destination for that component.

   Candidate Pair:  A pairing containing a local candidate and a remote
      candidate.

   Check, Connectivity Check, STUN Check:  A STUN Binding Request
      transaction for the purposes of verifying connectivity.  A check
      is sent from the local candidate to the remote candidate of a
      candidate pair.

   Check List:  An ordered set of candidate pairs that an agent will use
      to generate checks.

   Ordinary Check:  A connectivity check generated by an agent as a
      consequence of a timer that fires periodically, instructing it to
      send a check.

   Triggered Check:  A connectivity check generated as a consequence of
      the receipt of a connectivity check from the peer.

   Valid List:  An ordered set of candidate pairs for a media stream
      that have been validated by a successful STUN transaction.

   Full:  An ICE implementation that performs the complete set of
      functionality defined by this specification.





Rosenberg                  Expires May 1, 2008                 [Page 19]

Internet-Draft                     ICE                      October 2007


   Lite:  An ICE implementation that omits certain functions,
      implementing only as much as is necessary for a peer
      implementation that is full to gain the benefits of ICE.  Lite
      implementations do not maintain any of the state machines and do
      not generate connectivity checks.

   Controlling Agent:  The ICE agent which is responsible for selecting
      the final choice of candidate pairs and signaling them through
      STUN and an updated offer, if needed.  In any session, one agent
      is always controlling.  The other is the controlled agent.

   Controlled Agent:  An ICE agent which waits for the controlling agent
      to select the final choice of candidate pairs.

   Regular Nomination:  The process of picking a valid candidate pair
      for media traffic by validating the pair with one STUN request,
      and then picking it by sending a second STUN request with a flag
      indicating its nomination.

   Aggressive Nomination:  The process of picking a valid candidate pair
      for media traffic by including a flag in every STUN request, such
      that the first one to produce a valid candidate pair is used for
      media.

   Nominated:  If a valid candidate pair has its nominated flag set, it
      means that it may be selected by ICE for sending and receiving
      media.

   Selected Pair, Selected Candidate:  The candidate pair selected by
      ICE for sending and receiving media is called the selected pair,
      and each of its candidates is called the selected candidate.


4.  Sending the Initial Offer

   In order to send the initial offer in an offer/answer exchange, an
   agent must (1) gather candidates, (2) prioritize them, (3) choose
   default candidates, and then (4) formulate and send the SDP offer.
   All but the last of these four steps differ for full and lite
   implementations.

4.1.  Full Implementation Requirements

4.1.1.  Gathering Candidates

   An agent gathers candidates when it believes that communications is
   imminent.  An offerer can do this based on a user interface cue, or
   based on an explicit request to initiate a session.  Every candidate



Rosenberg                  Expires May 1, 2008                 [Page 20]

Internet-Draft                     ICE                      October 2007


   is a transport address.  It also has a type and a base.  Four types
   are defined and gathered by this specification - host candidates,
   server reflexive candidates, peer reflexive candidates, and relayed
   candidates.  The server reflexive and relayed candidates are gathered
   using STUN or TURN, and relayed candidates are obtained through TURN.
   Peer reflexive candidates are obtained in later phases of ICE, as a
   consequence of connectivity checks.  The base of a candidate is the
   candidate that an agent must send from when using that candidate.

4.1.1.1.  Host Candidates

   The first step is to gather host candidates.  Host candidates are
   obtained by binding to ports (typically ephemeral) on a IP address
   attached to an interface (physical or virtual, including VPN
   interfaces) on the host.

   For each UDP media stream the agent wishes to use, the agent SHOULD
   obtain a candidate for each component of the media stream on each IP
   address that the host has.  It obtains each candidate by binding to a
   UDP port on the specific IP address.  A host candidate (and indeed
   every candidate) is always associated with a specific component for
   which it is a candidate.  Each component has an ID assigned to it,
   called the component ID.  For RTP-based media streams, the RTP itself
   has a component ID of 1, and RTCP a component ID of 2.  If an agent
   is using RTCP it MUST obtain a candidate for it.  If an agent is
   using both RTP and RTCP, it would end up with 2*K host candidates if
   an agent has K IP addresses.

   The base for each host candidate is set to the candidate itself.

4.1.1.2.  Server Reflexive and Relayed Candidates

   Agents SHOULD obtain relayed candidates and SHOULD obtain server
   reflexive candidates.  These requirements are at SHOULD strength to
   allow for provider variation.  Use of STUN and TURN servers may be
   unnecessary in closed networks where agents are never connected to
   the public Internet or to endpoints outside of the closed network.
   In such cases, a full implementation would be used for agents that
   are dual-stack or multi-homed, to select a host candidate.  Use of
   TURN servers is expensive, and when ICE is being used, they will only
   be utilized when both endpoints are behind NATs that perform address
   and port dependent mapping.  Consequently, some deployments might
   consider this use case to be marginal, and elect not to use TURN
   servers.  If an agent does not gather server reflexive or relayed
   candidates, it is RECOMMENDED that the functionality be implemented
   and just disabled through configuration, so that it can re-enabled
   through configuration if conditions change in the future.




Rosenberg                  Expires May 1, 2008                 [Page 21]

Internet-Draft                     ICE                      October 2007


   If an agent is gathering both relayed and server reflexive
   candidates, it uses a TURN server.  If it is gathering just server
   reflexive candidates, it uses a STUN server.

   The agent next pairs each host candidate with the STUN or TURN server
   with which it is configured or has discovered by some means.  If a
   STUN or TURN server is configured, it is RECOMMENDED that a domain
   name be configured, and the DNS procedures in
   [I-D.ietf-behave-rfc3489bis] (using SRV records with the "stun"
   service) be used to discover the STUN server, and the DNS procedures
   in [I-D.ietf-behave-turn] (using SRV records with the "turn" service)
   be used to discover the TURN server.

   This specification only considers usage of a single STUN or TURN
   server.  When there are multiple choices for that single STUN or TURN
   server (when, for example, they are learned through DNS records and
   multiple results are returned), an agent SHOULD use a single STUN or
   TURN server (based on its IP address) for all candidates for a
   particular session.  This improves the performance of ICE.  The
   result is a set of pairs of host candidates with STUN or TURN
   servers.  The agent then chooses one pair, and sends a Binding or
   Allocate request to the server from that host candidate.  Binding
   Requests to a STUN server are not authenticated, and any ALTERNATE-
   SERVER attribute in a response is ignored.  Agents MUST support the
   backwards compatibility mode for the Binding Request defined in
   [I-D.ietf-behave-rfc3489bis].  Allocate requests SHOULD be
   authenticated using a long-term credential obtained by the client
   through some other means.

   Every Ta milliseconds thereafter, the agent can generate another new
   STUN or TURN transaction.  This transaction can either be a retry of
   a previous transaction which failed with a recoverable error (such as
   authentication failure), or a transaction for a new host candidate
   and STUN or TURN server pair.  The agent SHOULD NOT generate
   transactions more frequently than one every Ta milliseconds.  See
   Section 16 for guidance on how to set Ta and the STUN retransmit
   timer, RTO.

   The agent will receive a Binding or Allocate response.  A successful
   Allocate Response will provide the agent with a server reflexive
   candidate (obtained from the mapped address) and a relayed candidate
   in the RELAY-ADDRESS attribute.  If the Allocate request is rejected
   because the server lacks resources to fulfill it, the agent SHOULD
   instead send a Binding Request to obtain a server reflexive
   candidate.  A Binding Response will provide the agent with only a
   server reflexive candidate (also obtained from the mapped address).
   The base of the server reflexive candidate is the host candidate from
   which the Allocate or Binding request was sent.  The base of a



Rosenberg                  Expires May 1, 2008                 [Page 22]

Internet-Draft                     ICE                      October 2007


   relayed candidate is that candidate itself.  If a relayed candidate
   is identical to a host candidate (which can happen in rare cases),
   the relayed candidate MUST be discarded.

4.1.1.3.  Computing Foundations

   Finally, the agent assigns each candidate a foundation.  The
   foundation is an identifier, scoped within a session.  Two candidates
   MUST have the same foundation ID when all of the following are true:

   o  they are of the same type (host, relayed, server reflexive, or
      peer reflexive)

   o  their bases have the same IP address (the ports can be different)

   o  for reflexive and relayed candidates, the STUN or TURN servers
      used to obtain them have the same IP address.

   o  they were obtained using the same transport protocol (TCP, UDP,
      etc.)

   Similarly, two candidates MUST have different foundations if their
   types are different, their bases have different IP addresses, the
   STUN or TURN servers used to obtain them have different IP addresses,
   or their transport protocols are different.

4.1.1.4.  Keeping Candidates Alive

   Once server reflexive and relayed candidates are allocated, they MUST
   be kept alive until ICE processing has completed, as described in
   Section 8.3.  For server reflexive candidates learned through a
   Binding request, the bindings MUST be kept alive by additional
   Binding Requests to the server.  For relayed candidates learned
   through an Allocate request, the keepalive MUST be new Allocate
   requests.  The Allocate requests will also refresh the server
   reflexive candidate.

4.1.2.  Prioritizing Candidates

   The prioritization process results in the assignment of a priority to
   each candidate.  Each candidate for a media stream MUST have a unique
   priority that MUST be a positive integer between 1 and (2**31 - 1).
   This priority will be used by ICE to determine the order of the
   connectivity checks and the relative preference for candidates.

   An agent SHOULD compute this priority using the formula in
   Section 4.1.2.1 and choose its parameters using the guidelines in
   Section 4.1.2.2.  If an agent elects to use a different formula, ICE



Rosenberg                  Expires May 1, 2008                 [Page 23]

Internet-Draft                     ICE                      October 2007


   will take longer to converge since both agents will not be
   coordinated in their checks.

4.1.2.1.  Recommended Formula

   When using the formula, an agent computes the priority by determining
   a preference for each type of candidate (server reflexive, peer
   reflexive, relayed and host), and, when the agent is multihomed,
   choosing a preference for its IP addresses.  These two preferences
   are then combined to compute the priority for a candidate.  That
   priority is computed using the following formula:


   priority = (2^24)*(type preference) +
              (2^8)*(local preference) +
              (2^0)*(256 - component ID)


   The type preference MUST be an integer from 0 to 126 inclusive, and
   represents the preference for the type of the candidate (where the
   types are local, server reflexive, peer reflexive and relayed).  A
   126 is the highest preference, and a 0 is the lowest.  Setting the
   value to a 0 means that candidates of this type will only be used as
   a last resort.  The type preference MUST be identical for all
   candidates of the same type and MUST be different for candidates of
   different types.  The type preference for peer reflexive candidates
   MUST be higher than that of server reflexive candidates.  Note that
   candidates gathered based on the procedures of Section 4.1.1 will
   never be peer reflexive candidates; candidates of these type are
   learned from the connectivity checks performed by ICE.

   The local preference MUST be an integer from 0 to 65535 inclusive.
   It represents a preference for the particular IP address from which
   the candidate was obtained, in cases where an agent is multihomed.
   65535 represents the highest preference, and a zero, the lowest.
   When there is only a single IP address, this value SHOULD be set to
   65535.  More generally, if there are multiple candidates for a
   particular component for a particular media stream which have the
   same type, the local preference MUST be unique for each one.  In this
   specification, this only happens for multi-homed hosts.  If a host is
   multi-homed because it is dual stacked, the local preference SHOULD
   be set equal to the precedence value for IP addresses described in
   RFC 3484 [RFC3484].

   The component ID is the component ID for the candidate, and MUST be
   between 1 and 256 inclusive.





Rosenberg                  Expires May 1, 2008                 [Page 24]

Internet-Draft                     ICE                      October 2007


4.1.2.2.  Guidelines for Choosing Type and Local Preferences

   One criteria for selection of the type and local preference values is
   the use of a media intermediary, such as a TURN server, VPN server or
   NAT.  With a media intermediary, if media is sent to that candidate,
   it will first transit the media intermediary before being received.
   Relayed candidates are one type of candidate that involves a media
   intermediary.  Another are host candidates obtained from a VPN
   interface.  When media is transited through a media intermediary, it
   can increase the latency between transmission and reception.  It can
   increase the packet losses, because of the additional router hops
   that may be taken.  It may increase the cost of providing service,
   since media will be routed in and right back out of a media
   intermediary run by a provider.  If these concerns are important, the
   type preference for relayed candidates SHOULD be lower than host
   candidates.  The RECOMMENDED values are 126 for host candidates, 100
   for server reflexive candidates, 110 for peer reflexive candidates,
   and 0 for relayed candidates.  Furthermore, if an agent is multi-
   homed and has multiple IP addresses, the local preference for host
   candidates from a VPN interface SHOULD have a priority of 0.

   Another criteria for selection of preferences is IP address family.
   ICE works with both IPv4 and IPv6.  It therefore provides a
   transition mechanism that allows dual-stack hosts to prefer
   connectivity over IPv6, but to fall back to IPv4 in case the v6
   networks are disconnected (due, for example, to a failure in a 6to4
   relay) [RFC3056].  It can also help with hosts that have both a
   native IPv6 address and a 6to4 address.  In such a case, higher local
   preferences could be assigned to the v6 addresses, followed by the
   6to4 addresses, followed by the v4 addresses.  This allows a site to
   obtain and begin using native v6 addresses immediately, yet still
   fallback to 6to4 addresses when communicating with agents in other
   sites that do not yet have native v6 connectivity.

   Another criteria for selecting preferences is security.  If a user is
   a telecommuter, and therefore connected to their corporate network
   and a local home network, they may prefer their voice traffic to be
   routed over the VPN in order to keep it on the corporate network when
   communicating within the enterprise, but use the local network when
   communicating with users outside of the enterprise.  In such a case,
   a VPN address would have a higher local preference than any other
   address.

   Another criteria for selecting preferences is topological awareness.
   This is most useful for candidates that make use of intermediaries.
   In those cases, if an agent has preconfigured or dynamically
   discovered knowledge of the topological proximity of the
   intermediaries to itself, it can use that to assign higher local



Rosenberg                  Expires May 1, 2008                 [Page 25]

Internet-Draft                     ICE                      October 2007


   preferences to candidates obtained from closer intermediaries.

4.1.3.  Eliminating Redundant Candidates

   Next, the agent eliminates redundant candidates.  A candidate is
   redundant if its transport address equals another candidate, and its
   base equals the base of that other candidate.  Note that two
   candidates can have the same transport address yet have different
   bases, and these would not be considered redundant.  Frequently, a
   server reflexive candidate and a host candidate will be redundant
   when the agent is not behind a NAT.  The agent SHOULD eliminate the
   redundant candididate with the lower priority.

4.1.4.  Choosing Default Candidates

   A candidate is said to be default if it would be the target of media
   from a non-ICE peer; that target being called the DEFAULT
   DESTINATION.  If the default candidates are not selected by the ICE
   algorithm when communicating with an ICE-aware peer, an updated
   offer/answer will be required after ICE processing completes in order
   to "fix-up" the SDP so that the default destination for media matches
   the candidates selected by ICE.  If ICE happens to select the default
   candidates, no updated offer/answer is required.

   An agent MUST choose a set of candidates, one for each component of
   each in-use media stream, to be default.  A media stream is in-use if
   it does not have a port of zero (which is used in RFC 3264 to reject
   a media stream).  Consequently, a media stream is in-use even if it
   is marked as a=inactive [RFC4566] or has a bandwidth value of zero.

   It is RECOMMENDED that default candidates be chosen based on the
   likelihood of those candidates to work with the peer that is being
   contacted.  It is RECOMMENDED that the default candidates are the
   relayed candidates (if relayed candidates are available), server
   reflexive candidates (if server reflexive candidates are available),
   and finally host candidates.

4.2.  Lite Implementation

   Lite implementations only utilize host candidates.  A lite
   implementation MUST, for each component of each media stream,
   allocate zero or one IPv4 candidates.  It MAY allocate zero or more
   IPv6 candidates, but no more than one per each IPv6 address utilized
   by the host.  Since there can be no more than one IPv4 candidate per
   component of each media stream, if an agent has multiple IPv4
   addresses, it MUST choose one for allocating the candidate.  If a
   host is dual-stack, it is RECOMMENDED that it allocate one IPv4
   candidate and one global IPv6 address.  With the lite implementation,



Rosenberg                  Expires May 1, 2008                 [Page 26]

Internet-Draft                     ICE                      October 2007


   ICE cannot be used to dynamically choose amongst candidates.
   Therefore, including more than one candidate from a particular scope
   is NOT RECOMMENDED, since only a connectivity check can truly
   determine whether to use one address or the other.

   Each component has an ID assigned to it, called the component ID.
   For RTP-based media streams the RTP itself has a component ID of 1,
   and RTCP a component ID of 2.  If an agent is using RTCP it MUST
   obtain candidates for it.

   Each candidate is assigned a foundation.  The foundation MUST be
   different for two candidates allocated from different IP addresses,
   and MUST be the same otherwise.  A simple integer that increments for
   each IP address will suffice.  In addition, each candidate MUST be
   assigned a unique priority amongst all candidates for the same media
   stream.  This priority SHOULD be equal to:


   priority = (2^24)*(126) +
              (2^8)*(IP precedence) +
              (2^0)*(256 - component ID)


   If a host is v4-only, it SHOULD set the IP precedence to 65535.  If a
   host is v6 or dual-stack, the IP precedence SHOULD be the precedence
   value for IP addresses described in RFC 3484 [RFC3484].

   Next, an agent chooses a default candidate for each component of each
   media stream.  If a host is IPv4 only, there would only be one
   candidate for each component of each media stream, and therefore that
   candidate is the default.  If a host is IPv6 or dual stack, the
   selection of default is a matter of local policy.  This default
   SHOULD be chosen, such that, it is the candidate most likely to be
   used with a peer.  For IPv6-only hosts, this would typically by a
   globally scoped IPv6 address.  For dual-stack hosts, the IPv4 address
   is RECOMMENDED.

4.3.  Encoding the SDP

   The process of encoding the SDP is identical between full and lite
   implementations.

   The agent will include an m-line for each media stream it wishes to
   use.  The ordering of media streams in the SDP is relevant for ICE.
   ICE will perform its connectivity checks for the first m-line first,
   and consequently media will be able to flow for that stream first.
   Agents SHOULD place their most important media stream, if there is
   one, first in the SDP.



Rosenberg                  Expires May 1, 2008                 [Page 27]

Internet-Draft                     ICE                      October 2007


   There will be a candidate attribute for each candidate for a
   particular media stream.  Section 15 provides detailed rules for
   constructing this attribute.  The attribute carries the IP address,
   port and transport protocol for the candidate, in addition to its
   properties that need to be signaled to the peer for ICE to work: the
   priority, foundation, and component ID.  The candidate attribute also
   carries information about the candidate that is useful for
   diagnostics and other functions: its type and related transport
   addresses.

   STUN connectivity checks between agents are authenticated using the
   short term credential mechanism defined for STUN
   [I-D.ietf-behave-rfc3489bis].  This mechanism relies on a username
   and password that are exchanged through protocol machinery between
   the client and server.  With ICE, the offer/answer exchange is used
   to exchange them.  The username part of this credential is formed by
   concatenating a username fragment from each agent, separated by a
   colon.  Each agent also provides a password, used to compute the
   message integrity for requests it receives.  The username fragment
   and password are exchanged in the ice-ufrag and ice-pwd attributes,
   respectively.  In addition to providing security, the username
   provides disambiguation and correlation of checks to media streams.
   See Appendix B.4 for motivation.

   If an agent is a lite implementation, it MUST include an "a=ice-lite"
   session level attribute in its SDP.  If an agent is a full
   implementation, it MUST NOT include this attribute.

   The default candidates are added to the SDP as the default
   destination for media.  For streams based on RTP, this is done by
   placing the IP address and port of the RTP candidate into the c and m
   lines, respectively.  If the agent is utilizing RTCP, it MUST encode
   the RTCP candidate using the a=rtcp attribute as defined in RFC 3605
   [RFC3605].  If RTCP is not in use, the agent MUST signal that using
   b=RS:0 and b=RR:0 as defined in RFC 3556 [RFC3556].

   The transport addresses that will be the default destination for
   media when communicating with non-ICE peers MUST also be present as
   candidates in one or more a=candidate lines.

   ICE provides for extensibility by allowing an offer or answer to
   contain a series of tokens which identify the ICE extensions used by
   that agent.  If an agent supports an ICE extension, it MUST include
   the token defined for that extension in the ice-options attribute.

   The following is an example SDP message that includes ICE attributes
   (lines folded for readability):




Rosenberg                  Expires May 1, 2008                 [Page 28]

Internet-Draft                     ICE                      October 2007


       v=0
       o=jdoe 2890844526 2890842807 IN IP4 10.0.1.1
       s=
       c=IN IP4 192.0.2.3
       t=0 0
       a=ice-pwd:asd88fgpdd777uzjYhagZg
       a=ice-ufrag:8hhY
       m=audio 45664 RTP/AVP 0
       b=RS:0
       b=RR:0
       a=rtpmap:0 PCMU/8000
       a=candidate:1 1 UDP 2130706431 10.0.1.1 8998 typ host
       a=candidate:2 1 UDP 1694498815 192.0.2.3 45664 typ srflx raddr
   10.0.1.1 rport 8998

   Once an agent has sent its offer or sent its answer, that agent MUST
   be prepared to receive both STUN and media packets on each candidate.
   As discussed in Section 11.1, media packets can be sent to a
   candidate prior to its appearance as the default destination for
   media in an offer or answer.


5.  Receiving the Initial Offer

   When an agent receives an initial offer, it will check if the offerer
   supports ICE, determine its own role, gather candidates, prioritize
   them, choose default candidates, encode and send an answer, and for
   full implementations, form the check lists and begin connectivity
   checks.

5.1.  Verifying ICE Support

   The agent will proceed with the ICE procedures defined in this
   specification if, for each media stream in the SDP it received, the
   default destination for each component of that media stream appears
   in a candidate attribute.  For example, in the case of RTP, the IP
   address and port in the c and m line, respectively, appears in a
   candidate attribute and the value in the rtcp attribute appears in a
   candidate attribute.

   If this condition is not met, the agent MUST process the SDP based on
   normal RFC 3264 procedures, without using any of the ICE mechanisms
   described in the remainder of this specification with the following
   exceptions:

   1.  The agent MUST follow the rules of Section 10, which describe
       keepalive procedures for all agents.




Rosenberg                  Expires May 1, 2008                 [Page 29]

Internet-Draft                     ICE                      October 2007


   2.  If the agent is not proceeding with ICE because there were
       a=candidate attributes, but none that matched the default
       destination of the media stream, the agent MUST include an a=ice-
       mismatch attribute in its answer.

   3.  If the default candidates were relayed candidates learned through
       a TURN server, the agent MUST create permissions in the TURN
       server for the IP addresses learned from its peer in the SDP it
       just received.  If this is not done, initial packets in the media
       stream from the peer may be lost.

5.2.  Determining Role

   For each session, each agent takes on a role.  There are two roles -
   controlling, and controlled.  The controlling agent is responsible
   for the choice of the final candidate pairs used for communications.
   For a full agent, this means nominating the candidate pairs that can
   be used by ICE for each media stream, and for generating the updated
   offer based on ICE's selection, when needed.  For a lite
   implementation, being the controlling agent means selecting a
   candidate pair based on the ones in the offer and answer (for IPv4,
   there is only ever one pair), and then generating an updated offer
   reflecting that selection, when needed (it is never needed for an
   IPv4 only host).  The controlled agent is told which candidate pairs
   to use for each media stream, and does not generate an updated offer
   to signal this information.  The sections below describe in detail
   the actual procedures following by controlling and controlled nodes.

   The rules for determining the role and the impact on behavior are as
   follows:

   Both agents are full:  The agent which generated the offer which
      started the ICE processing MUST take the controlling role, and the
      other MUST take the controlled role.  Both agents will form check
      lists, run the ICE state machines, and generate connectivity
      checks.  The controlling agent will execute the logic in
      Section 8.1 to nominate pairs that will be selected by ICE, and
      then both agents end ICE as described in Section 8.1.2.  In
      unusual cases, described in Appendix B.11, it is possible for both
      agents to mistakenly believe they are controlled or controlling.
      To resolve this, each agent MUST select a random number, called
      the tie-breaker, uniformly distributed between 0 and (2**64) - 1
      (that is, a 64 bit positive integer).  This number is used in
      connectivity checks to detect and repair this case, as described
      in Section 7.1.1.2.






Rosenberg                  Expires May 1, 2008                 [Page 30]

Internet-Draft                     ICE                      October 2007


   One agent Full, one Lite:  The full agent MUST take the controlling
      role, and the lite agent MUST take the controlled role.  The full
      agent will form check lists, run the ICE state machines, and
      generate connectivity checks.  That agent will execute the logic
      in Section 8.1 to nominate pairs that will be selected by ICE, and
      use the logic in Section 8.1.2 to end ICE.  The lite
      implementation will just listen for connectivity checks, receive
      them and respond to them, and then conclude ICE as described in
      Section 8.2.  For the lite implementation, the state of ICE
      processing for each media stream is considered to be Running, and
      the state of ICE overall is Running.

   Both Lite:  The agent which generated the offer which started the ICE
      processing MUST take the controlling role, and the other MUST take
      the controlled role.  In this case, no connectivity checks are
      ever sent.  Rather, once the offer/answer exchange completes, each
      agent performs the processing described in Section 8 without
      connectivity checks.  It is possible that both agents will believe
      they are controlled or controlling.  In the latter case, the
      conflict is resolved through glare detection capabilities in the
      signaling protocol carrying the offer/answer exchange.  The state
      of ICE processing for each media stream is considered to be
      Running, and the state of ICE overall is Running.

   Once roles are determined for a session, they persist unless ICE is
   restarted.  A ICE restart (Section 9.1) causes a new selection of
   roles and tie-breakers.

5.3.  Gathering Candidates

   The process for gathering candidates at the answerer is identical to
   the process for the offerer as described in Section 4.1.1 for full
   implementations and Section 4.2 for lite implementations.  It is
   RECOMMENDED that this process begin immediately on receipt of the
   offer, prior to alerting the user.  Such gathering MAY begin when an
   agent starts.

5.4.  Prioritizing Candidates

   The process for prioritizing candidates at the answerer is identical
   to the process followed by the offerer, as described in Section 4.1.2
   for full implementations and Section 4.2 for lite implementations.

5.5.  Choosing Default Candidates

   The process for selecting default candidates at the answerer is
   identical to the process followed by the offerer, as described in
   Section 4.1.4 for full implementations and Section 4.2 for lite



Rosenberg                  Expires May 1, 2008                 [Page 31]

Internet-Draft                     ICE                      October 2007


   implementations.

5.6.  Encoding the SDP

   The process for encoding the SDP at the answerer is identical to the
   process followed by the offerer for both full and lite
   implementations, as described in Section 4.3.

5.7.  Forming the Check Lists

   Forming check lists is done only by full implementations.  Lite
   implementations MUST skip the steps defined in this section.

   There is one check list per in-use media stream resulting from the
   offer/answer exchange.  To form the check list for a media stream,
   the agent forms candidate pairs, computes a candidate pair priority,
   orders the pairs by priority, prunes them, and sets their states.
   These steps are described in this section.

5.7.1.  Forming Candidate Pairs

   First, the agent takes each of its candidates for a media stream
   (called LOCAL CANDIDATES) and pairs them with the candidates it
   received from its peer (called REMOTE CANDIDATES) for that media
   stream.  In order to prevent the attacks described in Section 18.5.2,
   agents MAY limit the number of candidates they'll accept in an offer
   or answer.  A local candidate is paired with a remote candidate if
   and only if the two candidates have the same component ID and have
   the same IP address version.  It is possible that some of the local
   candidates don't get paired with a remote candidate, and some of the
   remote candidates don't get paired with local candidates.  This can
   happen if one agent didn't include candidates for the all of the
   components for a media stream.  If this happens, the number of
   components for that media stream is effectively reduced, and
   considered to be equal to the minimum across both agents of the
   maximum component ID provided by each agent across all components for
   the media stream.

   In the case of RTP, this would happen when one agent provided
   candidates for RTCP, and the other did not.  As another example, the
   offerer can multiplex RTP and RTCP on the same port and signals it
   can do that in the SDP through an SDP attribute
   [I-D.ietf-avt-rtp-and-rtcp-mux].  However, since the offerer doesn't
   know if the answerer can perform such multiplexing, the offerer
   includes candidates for RTP and RTCP on separate ports, so that the
   offer has two components per media stream.  If the answerer can
   perform such multiplexing, it would include just a single component
   for each candidate - for the combined RTP/RTCP mux.  ICE would end up



Rosenberg                  Expires May 1, 2008                 [Page 32]

Internet-Draft                     ICE                      October 2007


   acting as if there was just a single component for this candidate.

   The candidate pairs whose local and remote candidates were both the
   default candidates for a particular component is called,
   unsurprisingly, the default candidate pair for that component.  This
   is the pair that would be used to transmit media if both agents had
   not been ICE aware.

   In order to aid understanding, Figure 9 shows the relationships
   between several key concepts - transport addresses, candidates,
   candidate pairs, and check lists, in addition to indicating the main
   properties of candidates and candidate pairs.







































Rosenberg                  Expires May 1, 2008                 [Page 33]

Internet-Draft                     ICE                      October 2007


       +------------------------------------------+
       |                                          |
       | +---------------------+                  |
       | |+----+ +----+ +----+ |   +Type          |
       | || IP | |Port| |Tran| |   +Priority      |
       | ||Addr| |    | |    | |   +Foundation    |
       | |+----+ +----+ +----+ |   +ComponentiD   |
       | |      Transport      |   +RelatedAddr   |
       | |        Addr         |                  |
       | +---------------------+   +Base          |
       |             Candidate                    |
       +------------------------------------------+
       *                                         *
       *    *************************************
       *    *
     +-------------------------------+
    .|                               |
     | Local     Remote              |
     | +----+    +----+   +default?  |
     | |Cand|    |Cand|   +valid?    |
     | +----+    +----+   +nominated?|
     |                    +State     |
     |                               |
     |                               |
     |          Candidate Pair       |
     +-------------------------------+
     *                              *
     *                  ************
     *                  *
     +------------------+
     |  Candidate Pair  |
     +------------------+
     +------------------+
     |  Candidate Pair  |
     +------------------+
     +------------------+
     |  Candidate Pair  |
     +------------------+


            Check
            List


               Figure 9: Conceptual Diagram of a Check List






Rosenberg                  Expires May 1, 2008                 [Page 34]

Internet-Draft                     ICE                      October 2007


5.7.2.  Computing Pair Priority and Ordering Pairs

   Once the pairs are formed, a candidate pair priority is computed.
   Let G be the priority for the candidate provided by the controlling
   agent.  Let D be the priority for the candidate provided by the
   controlled agent.  The priority for a pair is computed as:

      pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0)

   Where G>D?1:0 is an expression whose value is 1 if G is greater than
   D, and 0 otherwise.  Once the priority is assigned, the agent sorts
   the candidate pairs in decreasing order of priority.  If two pairs
   have identical priority, the ordering amongst them is arbitrary.

5.7.3.  Pruning the Pairs

   This sorted list of candidate pairs is used to determine a sequence
   of connectivity checks that will be performed.  Each check involves
   sending a request from a local candidate to a remote candidate.
   Since an agent cannot send requests directly from a reflexive
   candidate, but only from its base, the agent next goes through the
   sorted list of candidate pairs.  For each pair where the local
   candidate is server reflexive, the server reflexive candidate MUST be
   replaced by its base.  Once this has been done, the agent MUST prune
   the list.  This is done by removing a pair if its local and remote
   candidates are identical to the local and remote candidates of a pair
   higher up on the priority list.  The result is a sequence of ordered
   candidate pairs, called the check list for that media stream.

   In addition, in order to limit the attacks described in
   Section 18.5.2, an agent MUST limit the total number of connectivity
   checks they perform across all check lists to a specific value, adn
   this value MUST be configurable.  A default of 100 is RECOMMENDED.
   This limit is enforced by discarding the lower priority candidate
   pairs until there are less than 100.  It is RECOMMENDED that a lower
   value be utilized when possible, set to the maximum number of
   plausible checks that might be seen in an actual deployment
   configuration.  The requirement for configuration is meant to
   provided a tool for fixing this value in the field if, once deployed,
   it is found to be problematic.

5.7.4.  Computing States

   Each candidate pair in the check list has a foundation and a state.
   The foundation is the combination of the foundations of the local and
   remote candidates in the pair.  The state is assigned once the check
   list for each media stream has been computed.  There are five
   potential values that the state can have:



Rosenberg                  Expires May 1, 2008                 [Page 35]

Internet-Draft                     ICE                      October 2007


   Waiting:  A check has not been performed for this pair, and can be
      performed as soon as it is the highest priority Waiting pair on
      the check list.

   In-Progress:  A check has been sent for this pair, but the
      transaction is in progress.

   Succeeded:  A check for this pair was already done and produced a
      successful result.

   Failed:  A check for this pair was already done and failed, either
      never producing any response or producing an unrecoverable failure
      response.

   Frozen:  A check for this pair hasn't been performed, and it can't
      yet be performed until some other check succeeds, allowing this
      pair to unfreeze and move into the Waiting state.

   As ICE runs, the pairs will move between states as shown in
   Figure 10.































Rosenberg                  Expires May 1, 2008                 [Page 36]

Internet-Draft                     ICE                      October 2007


      +-----------+
      |           |
      |           |
      |  Frozen   |
      |           |
      |           |
      +-----------+
            |
            |unfreeze
            |
            V
      +-----------+         +-----------+
      |           |         |           |
      |           | perform |           |
      |  Waiting  |-------->|In-Progress|
      |           |         |           |
      |           |         |           |
      +-----------+         +-----------+
                                  / |
                                //  |
                              //    |
                            //      |
                           /        |
                         //         |
               failure //           |success
                     //             |
                    /               |
                  //                |
                //                  |
              //                    |
             V                      V
      +-----------+         +-----------+
      |           |         |           |
      |           |         |           |
      |   Failed  |         | Succeeded |
      |           |         |           |
      |           |         |           |
      +-----------+         +-----------+

                         Figure 10: Pair State FSM

   The initial states for each pair in a check list are computed by
   performing the following sequence of steps:

   1.  The agent sets all of the pairs in each check list to the Frozen
       state.





Rosenberg                  Expires May 1, 2008                 [Page 37]

Internet-Draft                     ICE                      October 2007


   2.  The agent examines the check list for the first media stream (a
       media stream is the first media stream when it is described by
       the first m-line in the SDP offer and answer).  For that media
       stream:

       *  For all pairs with the same foundation, it sets the state of
          the pair with the lowest component ID to Waiting.  If there is
          more than one such pair, the one with the highest priority is
          used.

   One of the check lists will have some number of pairs in the Waiting
   state, and the other check lists will have all of their pairs in the
   Frozen state.  A check list with at least one pair that is Waiting is
   called an active check list, and a check list with all pairs frozen
   is called a frozen check list.

   The check list itself is associated with a state, which captures the
   state of ICE checks for that media stream.  There are three states:

   Running:  In this state, ICE checks are still in progress for this
      media stream.

   Completed:  In this state, ICE checks have produced nominated pairs
      for each component of the media stream.  Consequently, ICE has
      succeeded and media can be sent.

   Failed:  In this state, the ICE checks have not completed
      successfully for this media stream.

   When a check list is first constructed as the consequence of an
   offer/answer exchange, it is placed in the Running state.

   ICE processing across all media streams also has a state associated
   with it.  This state is equal to Running while ICE processing is
   underway.  The state is Completed when ICE processing is complete and
   Failed if it failed without success.  Rules for transitioning between
   states are described below.

5.8.  Scheduling Checks

   Checks are generated only by full implementations.  Lite
   implementations MUST skip the steps described in this section.

   An agent performs ordinary checks and triggered checks.  The
   generation of both checks is governed by a timer which fires
   periodically for each media stream.  The agent maintains a FIFO
   queue, called the triggered check queue, which contains candidate
   pairs for which checks are to be sent at the next available



Rosenberg                  Expires May 1, 2008                 [Page 38]

Internet-Draft                     ICE                      October 2007


   opportunity.  When the timer fires, the agent removes the top pair
   from triggered check queue, performs a connectivity check on that
   pair, and sets the state of the candidate pair to In-Progress.  If
   there are no pairs in the triggered check queue, an ordinary check is
   sent.

   Once the agent has computed the check lists as described in
   Section 5.7, it sets a timer for each active check list.  The timer
   fires every Ta*N seconds, where N is the number of active check lists
   (initially, there is only one active check list).  Implementations
   MAY set the timer to fire less frequently than this.  Implementations
   SHOULD take care to spread out these timers so that they do not fire
   at the same time for each media stream.  Ta and the retransmit timer
   RTO are computed as described in Section 16.  Multiplying by N allows
   this aggregate check throughput to be split between all active check
   lists.  The first timer fires immediately, so that the agent performs
   a connectivity check the moment the offer/answer exchange has been
   done, followed by the next check Ta seconds later (since there is
   only one active check list).

   When the timer fires, and there is no triggered check to be sent, the
   agent MUST choose an ordinary check as follows:

   o  Find the highest priority pair in that check list that is in the
      Waiting state.

   o  If there is such a pair:

      *  Send a STUN check from the local candidate of that pair to the
         remote candidate of that pair.  The procedures for forming the
         STUN request for this purpose are described in Section 7.1.1.

      *  Set the state of the candidate pair to In-Progress.

   o  If there is no such pair:

      *  Find the highest priority pair in that check list that is in
         the Frozen state.

      *  If there is such a pair:

         +  Unfreeze the pair.

         +  Perform a check for that pair, causing its state to
            transition to In-Progress.






Rosenberg                  Expires May 1, 2008                 [Page 39]

Internet-Draft                     ICE                      October 2007


      *  If there is no such pair:

         +  Terminate the timer for that check list.

   To compute the message integrity for the check, the agent uses the
   remote username fragment and password learned from the SDP from its
   peer.  The local username fragment is known directly by the agent for
   its own candidate.


6.  Receipt of the Initial Answer

   This section describes the procedures that an agent follows when it
   receives the answer from the peer.  It verifies that its peer
   supports ICE, determines its role, and for full implementations,
   forms the check list and begins performing ordinary checks.

   When ICE is used with SIP, forking may result in a single offer
   generating a multiplicity of answers.  In that each, ICE proceeds
   completely in parallel and independently for each answer, treating
   the combination of its offer and each answer as an independent offer/
   answer exchange, with its own set of pairs, check lists, states, and
   so on.  The only case in which processing of one pair impacts another
   is freeing of candidates, discussed below in Section 8.3.

6.1.  Verifying ICE Support

   The logic at the offerer is identical to that of the answerer as
   described in Section 5.1, with the exception that an offerer would
   not ever generate a=ice-mismatch attributes in an SDP.

   In some cases, the answer may omit a=candidate attributes for the
   media streams, and instead include an a=ice-mismatch attribute for
   one or more of the media streams in the SDP.  This signals to the
   offerer that the answerer supports ICE, but that ICE processing was
   not used for the session because a signaling intermediary modified
   the default destination for media components without modifying the
   corresponding candidate attributes.  See Section 18 for a discussion
   of cases where this can happen.  This specification provides no
   guidance on how an agent should proceed in such a failure case.

6.2.  Determining Role

   The offerer follows the same procedures described for the answerer in
   Section 5.2.






Rosenberg                  Expires May 1, 2008                 [Page 40]

Internet-Draft                     ICE                      October 2007


6.3.  Forming the Check List

   Formation of check lists is performed only by full implementations.
   The offerer follows the same procedures described for the answerer in
   Section 5.7.

6.4.  Performing Ordinary Checks

   Ordinary checks are performed only by full implementations.  The
   offerer follows the same procedures described for the answerer in
   Section 5.8.


7.  Performing Connectivity Checks

   This section describes how connectivity checks are performed.  All
   ICE implementations are required to be compliant to
   [I-D.ietf-behave-rfc3489bis], as opposed to the older [RFC3489].
   However, whereas a full implementation will both generate checks
   (acting as a STUN client) and receive them (acting as a STUN server),
   a lite implementation will only ever receive checks, and thus will
   only act as a STUN server.

7.1.  STUN Client Procedures

   These procedures define how an agent sends a connectivity check,
   whether it is an ordinary or a triggered check.  These procedures are
   only applicable to full implementations.

7.1.1.  Sending the Request

   The check is generated by sending a Binding Request from a local
   candidate, to a remote candidate.  [I-D.ietf-behave-rfc3489bis]
   describes how Binding Requests are constructed and generated.  A
   connectivity check MUST utilize the STUN short term credential
   mechanism.  Support for backwards compatibility with RFC 3489 MUST
   NOT be used or assumed with connectivity checks.  The FINGERPRINT
   mechanism MUST be used for connectivity checks.

   ICE extends STUN