nutss - NATs, URIs, Tunneling, SIP, and STUN[T]


#include "nutss.h"

int nutss_bind(SOCKET s, const struct sockaddr * addr, socklen_t size);

int nutss_connect(SOCKET s, const struct sockaddr * addr, socklen_t size);

SOCKET nutss_accept(SOCKET s, struct sockaddr *addr, socklen_t * size);


NUTSS is a novel internet architecture, incorporating on signaling and NAT traversal. NUTSS applications, since they do not use IP addresses for naming hosts, cope much better with NATs and firewalls than existing legacy applications.   Libnutss is a library facilitating NUTSS applications, by taking care of signaling, naming, and NAT traversal. 

There are three ways of accessing NUTSS; via the NUTSS API, via the Java API and via socket interposition.  The first two will work on any platform, the latter is Unix specific, because it relies on the Dante SOCKS library.


The NUTSS API is a supplement to ordinary sockets.  Use Nutss_bind instead of bind, Nutss_connect instead of connect, and Nuss_accept instead of accept. These functions all use a "struct sockaddr_ns" to represent endpoints.  Be sure to pass TCP sockets to bind and connect.

A sockaddr_ns is defined as follows: 

struct sockaddr_ns {

    int  family;                    // AF_NUTSS

    char user [NUTSSMAXNAMELEN];

    char domain [NUTSSMAXNAMELEN];

    char service [NUTSSMAXNAMELEN];

    char uuid [NUTSSMAXNAMELEN];


The field 'family' should be set to AF_NUTSS.  The fields 'user' and domain represent the SIP user ID of the connection endpoint: a user would be represented with user = "test" and domain="".   The service field identifies the application, and uuid is a globally unique identifier for this particular instance of the application.

For more information, see

The only header file you should need to include is nutss.h


The sockets passed to and from nutss_ functions are bound locally; the actual socket or sockets that are bound to the remote host are internal to NUTSS, to allow automatic failover.  As a result, manipulating options on those sockets needs to be done with care; most such options won't actually work properly.


#include "nutss.h"

struct sockaddr_ns nutss_endpoint; = AF_NUTSS;

strncpy(nutss_endpoint.user, user, sizeof(nutss_endpoint.user));

strncpy(nutss_endpoint.domain, "", sizeof(nutss_endpoint.domain));

strncpy(nutss_endpoint.service, "nutss_testapp", sizeof(nutss_endpoint.service));

int size = sizeof(endpoint);


nutss_bind(s, (struct sockaddr *)&endpoint, sizeof(endpoint) );

nutss_connect(s2, (struct sockaddr *)&endpoint, sizeof(endpoint));

SOCKET s3 = nutss_accept(s, &endpoint, &size);

Socket Interposition

On Linux, you can also use NUTSS via socket interposition.  With socket interposition, socket calls and DNS lookups are rerouted through NUTSS.  You can pass a NUTSS endpoint (username@host) instead of a hostname.  


. ./util/

launch nutssd [the server]

wrap ttcp -rs 

wrap ttcp -ts


It is also possible to use Libnutss from Java programs. Libnutss for Java has two components; the java class files, and the native library. The java classes will attempt to load the native library; be sure that it's on your library search path, or in the working directory of the java program. The Libnutss Java bindings define three key classes, which are drop-in replacements for the standard Java Sockets.   NUTSSSocket (extends Socket), NUTSSServerSocket (extends ServerSocket), and NUTSSSocketAddress (extends SocketAddress).  The class NUTSS has a number of static methods used to configure Libnutss.

Limitations and bugs

As mentioned above, most socket options won't behave usefully with the Nutss API.


Saikat Guha, Ari Rabkin


Saikat Guha, Ari Rabkin, Tyler Steele

See also

bind(2), connect(2), accept(2) ip (4 or 7)