continual-gathering

command
v4.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 10 Imported by: 0

README

Continual Gathering Example

This example demonstrates the ContinualGatheringPolicy feature in Pion ICE, which allows agents to continuously discover network candidates throughout a connection's lifetime.

Overview

Traditional ICE gathering (GatherOnce) collects candidates once at startup and stops. This can be problematic when:

  • Users switch between WiFi and cellular networks
  • Network interfaces are added/removed
  • Moving between access points ("walk-out-the-door" problem)

With GatherContinually, the agent monitors for network changes and automatically discovers new candidates, enabling seamless connectivity transitions.

Usage

# Traditional gathering (stops after initial collection)
go run main.go -mode once

# Continual gathering (monitors for network changes)
go run main.go -mode continually -interval 2s

Testing

While running in continual mode, try:

  • Connecting/disconnecting WiFi
  • Enabling/disabling network adapters
  • Switching between networks

New candidates will be discovered and reported automatically!

Testing with Virtual Network Adapters (Linux)

You can easily test the continual gathering by creating/removing virtual network adapters:

# Create a virtual network adapter with an IP address
sudo ip link add veth0 type veth peer name veth1
sudo ip addr add 10.0.0.1/24 dev veth0
sudo ip link set veth0 up

# Wait a few seconds, then check the example output
# You should see new candidates for 10.0.0.1

# Remove the virtual adapter
sudo ip link delete veth0

# The removed interface will be detected and logged

Alternative using dummy interface:

# Create a dummy interface (simpler, no peer needed)
sudo ip link add dummy0 type dummy
sudo ip addr add 192.168.100.1/24 dev dummy0
sudo ip link set dummy0 up

# Remove it
sudo ip link delete dummy0

You can also change IP addresses on existing interfaces:

# Add a secondary IP to an existing interface
sudo ip addr add 172.16.0.1/24 dev eth0

# Remove it
sudo ip addr del 172.16.0.1/24 dev eth0

Documentation

Overview

Package main demonstrates the ContinualGatheringPolicy feature

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL