SNAP Addresses

Each SNAP device has a unique SNAP address, defined by the last three bytes of the device’s MAC address. Thus, a SNAP device with the MAC address 001C2C1E8600669B would have a SNAP address of 00669B. Typically, people will add “dots” to the address when printing it to make it easier to read: 00.66.9B. SNAP devices reference each other (to send procedure calls) using these addresses, both for directed multicasts and for unicast RPC calls.

In such calls, the address is specified as a three-character string. The above address would be specified as \x00\x66\x9b. Of these three characters, only the \x66 is directly printable (it displays as an f).

This can make it difficult to present a human-readable indication of a device’s address if you have some function indicating from where a message was received. A function like the following will decode the address to human-readable form:

def decodeSnapAddress(address):
    key = "01234567889ABCDEF"
    returnValue = ""

    for character in address:
        byte = ord(character)
        returnValue += key[byte / 16]
        returnValue += key[byte % 16]
        returnValue += "."
        returnValue = returnValue[:-1]

    return returnValue

When using the directed Multicast functions (dmcastRpc() and dmCallout()), you will often want to address more than one device. Simply concatenate multiple SNAP addresses into a longer string. A value of \x00\x66\x9b\x05\x47\x56\x5f\xe6\x23 would be acted on by devices 00.66.9B, 05.47.56, and 5F.E6.23, assuming all three of those devices are reachable by the network, within the specified TTL, and belong to the execution groups that match the multicast groups specified in the call.