NAME

STUN::Client - Session Traversal Utilities for NAT (STUN) client. (RFC 5389)

SYNOPSIS

    use STUN::Client;
    use Data::Dumper;

    $stun_client = STUN::Client->new;

    $stun_client->stun_server('stun.server.org');

    ($r_old, $r_new) = $stun_client->get;

    print Dumper($r_old);
    print Dumper($r_new);

DESCRIPTION

Session Traversal Utilities for NAT (STUN) is a protocol that serves as a tool for other protocols in dealing with Network Address Translator (NAT) traversal. It can be used by an endpoint to determine the IP address and port allocated to it by a NAT. It can also be used to check connectivity between two endpoints, and as a keep-alive protocol to maintain NAT bindings. STUN works with many existing NATs, and does not require any special behavior from them.

STUN is not a NAT traversal solution by itself. Rather, it is a tool to be used in the context of a NAT traversal solution.

ATTRIBUTES

stun_server

Hostname of STUN server.

proto

Protocol to use for connect, 'udp' or 'tcp'.

Default: udp.

port

Port number of STUN server.

Default: 3478

local_address

Local Internet address.

local_port

Local port number, but it is necessary that local_address is explicity.

retries

The client retries the request, this time including its username and the realm, and echoing the nonce provided by the server. The client also includes a message-integrity, which provides an HMAC over the entire request, including the nonce. The server validates the nonce and checks the message integrity. If they match, the request is authenticated. If the nonce is no longer valid, it is considered "stale", and the server rejects the request, providing a new nonce.

Default: 5

timeout

Retransmit a STUN request message starting with an interval of RTO ("Retransmission TimeOut"), doubling after each retransmission.

Default: 2

method

STUN methods in the range 0x000 - 0x7FF are assigned by IETF Review [RFC5226]. STUN methods in the range 0x800 - 0xFFF are assigned by Designated Expert [RFC5226].

data

Data to send in package.

METHODS

get

Connect to a stun_server and receive the answer. The first argument returned is a hash reference in the format retuned by the versions previous to 0.04. The second argument is a hash reference as returned by STUN::RFC_5389.

STUN Servers

    * stun.ekiga.net
    * stun.fwdnet.net
    * stun.ideasip.com
    * stun01.sipphone.com (no DNS SRV record)
    * stun.softjoys.com (no DNS SRV record)
    * stun.voipbuster.com (no DNS SRV record)
    * stun.voxgratia.org (no DNS SRV record)
    * stun.xten.com
    * stunserver.org see their usage policy
    * stun.sipgate.net:10000 

SEE ALSO

STUN::RFC_5389

CONTRIBUTORS

Detlef Pilzecker

AUTHOR

Thiago Rondon, <thiago@aware.com.br>

http://www.aware.com.br/

LICENSE

Perl license.