Subject: Re: [Anima-signaling] Draft message on proposed change to GRASP

From: "jmh.direct" <[email-masked]>
Date: Wed, 20 Apr 2016 14:04:35 -0700

How common is the case of an ASAP wanting to use both TCP and UDP?  If it is not rare, the requirement to get the same ephemeral port in both stacks seems tricky to meet in an operational system.
Yours,Joel

Sent via the Samsung Galaxy S® 6, an AT&T 4G LTE smartphone-------- Original message --------From: Brian E Carpenter <[email-masked]> Date: 4/20/2016  1:50 PM  (GMT-08:00) To: Anima signaling DT <[email-masked]>, "Joel M. Halpern" <[email-masked]> Subject: Draft message on proposed change to GRASP 
Hi,

Design team, and Joel,

Some of us have been discussing a GRASP design issue raised by Toerless.
There was quite a long off-list thread (nothing secret, so if people are
interested we could make it available). But here is a draft of a proposal
to the WG. Please comment - especially, does the text make sense? The actual
decision belongs to the WG, of course.

Short version:

We propose that when an ASA listens for negotiation or synchronization requests,
it should do so on its own port number rather than sharing the generic GRASP
port number as currently defined. The consequence for the protocol is that
discovery responses must include a complete transport address (locator+port)
instead of just the locator.

Long version:

We want ASAs to run as separate modules in user address space, as applications,
rather than being bundled with the GRASP engine in kernel space. To achieve this
with all ASAs listening on the same port number would require quite complicated
inter-process communication between the GRASP kernel and the indvidual ASAs.
The details of this would be different in every operating system. If we
allow each ASA to have its own port this can be avoided, and each ASA can have
its own copy of the GRASP API library if required. This will make the systems
engineering of portable ASAs much easier, and will make the adaptation of
the GRASP API library and the GRASP kernel to various operating systems easier
too.

We propose to redefine the locator returned by GRASP discovery accordingly. For
the IPv6 case that would give:

locator-option /= [ipv6-locator-option, port-number]
ipv6-locator-option = bytes .size 16
port-number = 0..65535

We did consider making this optional, but that would raise interoperability
issues. If an implementation does choose to use the GRASP_LISTEN_PORT
for all ASAs, that could simply be returned as the port-number.
(Alternatively, we could define that port-number==0 means GRASP_LISTEN_PORT,
but that seems like optimisation of a corner case.)

Implementation note:

An ASA will obtain an ephemeral port number when it starts up and that
will be used in discovery responses. If more than one transport protocol
is to be used, it will need to secure the same port number for each protocol.
For example, if it gets port X when binding to a TCP socket, it must then
bind to port X on a UDP socket.

Note:

Toerless Eckert brought up this problem and outlined the proposed solution.

---

From: Toerless Eckert <[email-masked]>
Date: Wed, 20 Apr 2016 14:46:41 -0700

Joel: Would definitely be safest if ASAs would have separate UDP and
TCP transport addresses. On the other hand, you can search for a port
free on both TCP/UDP. But probably thats not considered architecturally clean.

> _______________________________________________
> Anima-signaling mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/anima-signaling

-- 
---
Toerless Eckert, [email-masked]

---

From: Brian E Carpenter <[email-masked]>
Date: Thu, 21 Apr 2016 14:07:34 +1200

> free on both TCP/UDP. But probably thats not considered architecturally clean.

It isn't, but it can be done (Python code fragment below).
We can certainly avoid this by tagging the port number with the
transport protocol, which adds a few more bytes to the discovery
response. It's a matter of what we think is least bad - different
ports for each transport protocol, or some messy code.

  Brian

        # Set up TCP and UDP listening sockets on a free port

        for i in range(10):
            listen_sock=socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
            listen_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            listen_sock.bind(('',0))
            listen_port = listen_sock.getsockname()[1]

            # try to grab the same port for UDP
            ulisten_sock=socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
            try:
                ulisten_sock.bind(('',listen_port))
                break # we're done
            except:
                # could not get the same port
                if i==9:
                    # failed 10 times, give up
                    raise RuntimeError("Ten successive port clashes")
                listen_sock.close()
                ulisten_sock.close()
                continue # try again