[PD] IP address of local machine

Lucas Cordiviola lucarda27 at hotmail.com
Sun Dec 17 02:54:23 CET 2017

Hi Roman,

I'm not sure but may be these two croos-platform apps will help sending and analyzing received packets:




Mensaje telepatico asistido por maquinas.

On 12/16/2017 9:41 PM, Roman Haefeli wrote:

On Sam, 2017-12-16 at 21:26 +0100, Jack wrote:

Your router has a public and local IP. So, i guess your local machine
has only a local IP. Then, your local machine need to pass through
router to access remote server. Your router has NAT rules to know
local machine to route the content from the remote server.
I don't really understand what exactly you are looking for

Sorry for not being more clear. I try to rephrase. I like to know what
local IP address a [tcpclient] or [udpclient] connection is using. So,
if my wifi interface is configured to and this interface
is used for communicating to the outside world, how can I get that IP
from within Pd? Your suggestions may work by using [shell], but still
they show all kinds of interfaces and IP addresses and its not trivial
to determine the one that is used to talk to the default gateway (or by
specific connection).

I would like to implement a technique called UDP hole punching[1] in
Pd. Before two clients talk to each other directly, they exchange some
information by talking to a server with a public IP address that acts
as a man-in-the-middle. As a result, the clients know the public IP
address and the bind port of their peer. This works well so far, even
in my patch. However, if both clients are in the same local network,
they can't establish a connection because they try to connect to the
public IP address of their own router. So, in order to overcome this
limitation, my idea was to check if my router's public IP address is
the same as the one of my peer. If they are, it means both clients are
part of the same local network. In that case, they would use the public
server to exchange each other's local IP addresses. However,
[tcpclient] seems to have no notion of the local IP address of an
established connection. So the patch actually doesn't know what IP
address it is using and thus cannot tell its peer.

Using [shell] and a script based on 'ip addr show' seems tedious and
not very reliable, considering the information needed is part of every
packet sent and received by [tcpclient].

If there's no easy way, I might turn that into a feature request for
iemnet's [udpclient] and [tcpclient] to print the src IP address and
src port on the status outlet. Does that make sense?


[1] https://en.wikipedia.org/wiki/UDP_hole_punching

, but here
some possible answer (on linux) :

to get your ip address (local)
$ ip addr
to get the IP address (local) of the router :
$ ip route
to get the public address of the router :
$ curl -s http://whatismyip.akamai.com/
$ netcat -w 5 4.ifcfg.me 23
$ nc -w 5 4.ifcfg.me 23

There is also other command lines (ifconfig (instead of ip addr),
-n (instead ip route), etc.).


Le 16/12/2017 à 17:35, Roman Haefeli a écrit :

Hey all

Is there a simple cross-platform way for a patch to know the main
address of the local machine? Assume the patch is connected to a
server and is able to request its public IP address. What I like to
find out is if the local patch is communicating through NAT or
to the remote server.

An incoming IP packet from the remote server would contain that
information in the destination IP address field of the IP header,
the network objects I'm using ([tcpclient] and [udpclient]) don't
expose that information.

Maybe there are other ways?


Pd-list at lists.iem.at<mailto:Pd-list at lists.iem.at> mailing list
UNSUBSCRIBE and account-management -> https://lists.puredata.info/l

Pd-list at lists.iem.at<mailto:Pd-list at lists.iem.at> mailing list
UNSUBSCRIBE and account-management -> https://lists.puredata.info/lis

Pd-list at lists.iem.at<mailto:Pd-list at lists.iem.at> mailing list
UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20171217/5a4e5996/attachment.html>

More information about the Pd-list mailing list