aiocoap.dump module

class aiocoap.dump.TextDumper(outfile, protocol=None)

Bases: aiocoap.util.asyncio.RecvmsgDatagramProtocol

Plain text network data dumper

A TextDumper can be used to log network traffic into a file that can be converted to a PCAP-NG file as described in its header.

Currently, this discards information like addresses; it is unknown how that information can be transferred into a dump reader easily while simultaneously staying at application level and staying ignorant of particular underlying protocols’ data structures.

It could previously be used stand-alone (outside of the asyncio transport/protocol mechanisms) when instanciated only with an output file (the datagram_received() and sendto() were used), but with the datagram_msg_received() substitute method, this is probably impractical now.

To use it between an asyncio transport and protocol, use the :meth:endpointfactory method.

classmethod endpointfactory(outfile, actual_protocol)

This method returns a function suitable for passing to an asyncio loop’s .create_datagram_endpoint method. It will place the TextDumper between the object and the transport, transparently dumping network traffic and passing it on together with other methods defined in the protocol/transport interface.

If you need the actual protocol after generating the endpoint (which when using this method returns a TextDumper instead of an actual_protocol), you can access it using the protocol property.

protocol
datagram_msg_received(data, ancdata, flags, address)
sendmsg(data, ancdata, flags, address)
connection_made(transport)
close()
connection_lost(exc)