UDPshell

From Albatross

Jump to: navigation, search

Introduction

UDPshell is a fairly simple but quite powerful tool for experimenting with UDP communications (multicasting in particular) for interprocess communication. The basics:

UDP> help()
UDP> help(some_command_name)

To create the payload (tuples etc.):

UDP> alba_payload_pack([(0, "B", 15), (1, "H", 0x4321)])

To create a packet (with header, checksums etc.):

UDP> alba_create(42, 0xab, alba_payload_pack([(0, "B", 15), (1, "H", 0x4321)]))

To create/send a packet:

send(alba_create(42, 0xab, alba_payload_pack([(0, "B", 15), (1, "H", 0x4321)])))

or

send(test_dgram)

In a new instance, for listening:

UDP> filters.append(alba_decode)
UDP> listen()
...
***Albatross IPC Datagram Received.***
SYNC bytes: 0x50 0xa CORRECT
Destination Bit-mask: 0000000000101010
Command: 0xab
Size of Payload: 9 CORRECT
Header Checksum: 0xd2 CORRECT
Payload contents:
        Addr: 0x0 = 0f
        Addr: 0x1 = 21
        Addr: 0x2 = 43
Datagram Checksum: 0x84c8 CORRECT

Or for a simpler regexp filter, just:

UDP> add_filter("some regexp as a string")

New filters can be defined quite easily, either in the init script or in the shell interactively, e.g.:

UDP> def my_filter(data):
...      print to_hex(data[0:5]) # Prints the first five bytes of the packet in hex.
....
UDP> filters.append(my_filter)