Skip to main content

What is Pion ICE?

Pion ICE is a pure Go implementation of the Interactive Connectivity Establishment (ICE) protocol, as defined in RFC 5245. ICE is a framework used by WebRTC and other peer-to-peer applications to establish network connections between peers, even when they are behind NATs or firewalls.
Pion ICE is part of the larger Pion WebRTC project, which provides a complete WebRTC implementation in Go.

Why ICE?

Establishing direct peer-to-peer connections over the internet is challenging due to:
  • NAT traversal: Most devices sit behind Network Address Translation (NAT), making direct connections difficult
  • Firewall restrictions: Corporate and residential firewalls often block incoming connections
  • Multiple network interfaces: Devices may have several network paths (WiFi, Ethernet, cellular)
  • Connection reliability: Networks may change during a session
ICE solves these problems by:
  1. Gathering multiple candidate addresses (local, server-reflexive, relay)
  2. Exchanging candidates with the remote peer
  3. Testing candidate pairs to find working connections
  4. Selecting the best path based on priority and latency

Key Features

Pion ICE provides a complete ICE implementation with:

Full ICE Support

Complete implementation of RFC 5245 with support for all candidate types: host, server-reflexive, peer-reflexive, and relay

Multiple Transports

Support for UDP, TCP (passive and active), and multiplexing for efficient port usage

STUN & TURN

Built-in support for STUN servers (NAT discovery) and TURN servers (relay) with TLS/DTLS encryption

Continual Gathering

Dynamic candidate gathering that responds to network changes during a session

mDNS Support

Local network discovery using Multicast DNS for privacy-preserving local connections

Lite Mode

Lightweight ICE implementation for servers that only provide host candidates

Use Cases

WebRTC Applications

Pion ICE is the foundation for WebRTC connectivity in Go applications:
  • Video conferencing platforms
  • Real-time collaboration tools
  • Live streaming services
  • Browser-to-server communication

Peer-to-Peer Networking

Build P2P applications without browser constraints:
  • Distributed systems and microservices
  • File sharing and synchronization
  • Gaming backends with direct peer connections
  • IoT device communication

NAT Traversal Solutions

Use ICE for any application requiring NAT traversal:
  • VoIP and telephony systems
  • Remote desktop and control applications
  • Tunneling and proxy services

Connection States

ICE connections progress through several states:
ConnectionStateNew          // Agent is gathering addresses
ConnectionStateChecking     // Testing candidate pairs
ConnectionStateConnected    // Found working pair, still checking others
ConnectionStateCompleted    // Finished checking all pairs
ConnectionStateFailed       // No working connection found
ConnectionStateDisconnected // Lost connection
ConnectionStateClosed       // Agent shut down

Architecture Overview

At the core of Pion ICE is the Agent type, which:
  • Manages candidate gathering from local interfaces
  • Coordinates with STUN/TURN servers
  • Performs connectivity checks with remote candidates
  • Maintains connection state and handles keepalives
  • Provides a net.Conn interface for data transfer

Next Steps

Installation

Get started by installing Pion ICE in your Go project

Quickstart

Build your first ICE connection with a complete example
Pion ICE requires Go 1.24.0 or later for full compatibility with the latest features.

Build docs developers (and LLMs) love