How ankraft/coapthon3-acme-cse works
Project’s nature and purpose
– It’s a protocol library (not a monolithic app).
– Core purpose: send/receive CoAP messages, support proxies (forward/reverse/HTTP), caching, blockwise transfers, and extensibility for oneM2M CSE.
File structure to find main components
– “coapthon” package is the heart, with subpackages:
• layers (blocklayer, cachelayer, forwardLayer, messagelayer, observelayer, requestlayer, resourcelayer)
• client (CoAP client logic)
• server (CoAP server logic)
• forward_proxy, reverse_proxy, http_proxy
• caching (cache implementations)
• messages (message/option/request/response models)
• resources (Resource abstraction)
• serializer, transaction, utils
– Top-level scripts wire everything up: coapclient.py, coapserver.py, coapforwardproxy.py, coapreverseproxy.py, collect*.py, plugtest.py, etc.
Pull architecture hints from the README
– It’s a Python3 port with oneM2M CSE forks: custom options, blockwise fixes, plug-in request layers, type hints.
a. Main components:
• Application scripts (CLI tools): coapclient, coapserver, proxies, example servers/clients.
• Library core: layers stack, message serializer, transaction manager, resource manager.
• Caching subsystem.
• Network I/O (UDP socket layer) and optional Twisted reactor.
• External entities: CoAP devices/endpoints, HTTP clients (for HTTP→CoAP proxy), oneM2M CSE backend.
b. Relationships & interactions:
– Client script → invokes client layer → builds CoAP Request → passes through message layer → block/cache/observe layers as needed → UDP socket → remote CoAP server.
– Server script → listens on UDP → passes incoming bytes → serializer → message layer → resource layer → custom RequestLayer (oneM2M logic) → response flows back.
– Proxies sit between client & server paths, reusing the same layers but altering flows (forward vs. reverse).
– Caching layer intercepts GET requests/responses.
c. Architectural patterns/design principles:
– Layered pipeline (chain of responsibility) for message processing.
– Plug-in extensibility: new RequestLayer implementations, custom options.
– Separation of concerns: messaging, transport, caching, resource dispatch.
– Transaction management for reliability.
d. Key technologies/frameworks:
– Python3 (type hints).
– Optional Twisted support.
– Standard UDP sockets.
– XML mapping file for reverse proxy (reverse_proxy_mapping.xml).
Detail
– Show how scripts instantiate and wire these modules.