diff --git a/README.md b/README.md index 54bce5f..abb079d 100644 --- a/README.md +++ b/README.md @@ -10,16 +10,16 @@ It builds on a baseline that simulates the sort of device you might be adding th measures itself: see [docs/baseline.md](docs/baseline.md) for what the baseline is, how the figures are made, and how to run it. -## This stage — File store +## This stage — Origin -Records spool to a block store on the volume the device already mounts — four blocks, one file -each — instead of being held only in memory. The service task drains the ring into the store and -sends from there, so a failed send costs a retry rather than the record. The CRC-16 written with -each record catches corruption at rest, not tampering. +The record carries an `origin` SD-ELEMENT naming the software, its version and the vendor's IANA +enterprise number, so it identifies its sender instead of leaving the collector to infer that from +the source address — which matters once the store replays records hours after the event. The `ip` +PARAM is left out: the address the collector sees is still the one that reached it. -**Cost above baseline: Flash +11,576 B, RAM +7,092 B.** +**Cost above baseline: Flash +11,972 B, RAM +7,136 B.** @@ -44,6 +44,7 @@ committed as [`run-report.md`](run-report.md), and rewritten by every stage. | TCP | records the network retransmits instead of dropping, and a send that fails when the collector is gone | +7,320 | +5,856 | | Time quality | a timestamp the collector knows how far to trust, and an uptime that tells a reboot from a counter wrap | +7,612 | +5,880 | | File store | records that survive a failed send, spooled to disk with a checksum at rest | +11,576 | +7,092 | +| Origin | the device named in the record itself, not inferred from the source address | +11,972 | +7,136 | *Deltas are bytes above the baseline, which is itself Flash 350,308 B, RAM 111,192 B.* diff --git a/app/syslog/Syslog.c b/app/syslog/Syslog.c index 7506d8e..40e1b9d 100644 --- a/app/syslog/Syslog.c +++ b/app/syslog/Syslog.c @@ -24,10 +24,12 @@ #include "SolidSyslogLwipRawResolver.h" #include "SolidSyslogLwipRawTcpStream.h" #include "SolidSyslogMetaSd.h" +#include "SolidSyslogOriginSd.h" #include "SolidSyslogStdAtomicCounter.h" #include "SolidSyslogStreamSender.h" #include "SolidSyslogTimeQuality.h" #include "SolidSyslogTimeQualitySd.h" +#include "SyslogEnterprise.h" #include "SyslogFields.h" #include "lwip/tcpip.h" @@ -53,11 +55,14 @@ #define SYSLOG_STORE_PREFIX "syslog" #define SYSLOG_STORE_BLOCKS 4U +#define SYSLOG_SOFTWARE "solid-syslog-example" +#define SYSLOG_SW_VERSION "0.1.0" + static struct SolidSyslog* s_logger = NULL; static uint8_t s_ring[SOLIDSYSLOG_CIRCULAR_BUFFER_RING_BYTES(SYSLOG_BUFFER_RECORDS)]; /* The logger reads these on every record, so they outlive Syslog_Start. */ -static struct SolidSyslogStructuredData* s_sd[2]; +static struct SolidSyslogStructuredData* s_sd[3]; /* One reading at boot, then free-running on the tick — enough to stamp a record, * not synchronisation. */ @@ -122,6 +127,15 @@ void Syslog_Start(void) s_sd[0] = SolidSyslogMetaSd_Create(&metaConfig); s_sd[1] = SolidSyslogTimeQualitySd_Create(SyslogTimeQuality); + /* No ip: the address the collector sees is the one that reached it, until a + * relay makes that untrue. */ + struct SolidSyslogOriginSdConfig originConfig = { + .Software = SYSLOG_SOFTWARE, + .SwVersion = SYSLOG_SW_VERSION, + .EnterpriseId = SYSLOG_ENTERPRISE_ID, + }; + s_sd[2] = SolidSyslogOriginSd_Create(&originConfig); + /* Oldest discarded when the ceiling is reached: a device that cannot reach its * collector should keep the newest evidence, not stop logging. */ struct SolidSyslogBlockStoreConfig storeConfig = { diff --git a/app/syslog/SyslogEnterprise.h b/app/syslog/SyslogEnterprise.h new file mode 100644 index 0000000..0c48e74 --- /dev/null +++ b/app/syslog/SyslogEnterprise.h @@ -0,0 +1,12 @@ +/* This product's IANA Private Enterprise Number. It identifies the vendor, not + * the logger, so it lives on its own rather than beside any one element that + * carries it. + * + * 32473 is reserved for documentation (RFC 5612). Register your own at + * https://www.iana.org/assignments/enterprise-numbers/ */ +#ifndef APP_SYSLOG_ENTERPRISE_H +#define APP_SYSLOG_ENTERPRISE_H + +#define SYSLOG_ENTERPRISE_ID "32473" + +#endif /* APP_SYSLOG_ENTERPRISE_H */ diff --git a/measurements/origin.csv b/measurements/origin.csv new file mode 100644 index 0000000..c04d7ab --- /dev/null +++ b/measurements/origin.csv @@ -0,0 +1,13 @@ +# origin figures (bytes) — captured by scripts/run.sh (CAPTURE=1). +# The device reads measurements/Baseline.csv as its frozen baseline and reports current-minus-Baseline. +flash_text,361640 +flash_data,640 +static_bss,117688 +heap_used,4440 +mbedtls_peak,21336 +mbedtls_free,11432 +lwip_mem_free,7576 +lwip_pbufs_free,13 +stack_log,568 +stack_service,788 +stack_harness,2848 diff --git a/measurements/stages.tsv b/measurements/stages.tsv index 3a0e2db..e4752e3 100644 --- a/measurements/stages.tsv +++ b/measurements/stages.tsv @@ -21,3 +21,4 @@ buffered Buffered logging that returns immediately, with the send moved off the tcp TCP records the network retransmits instead of dropping, and a send that fails when the collector is gone time-quality Time quality a timestamp the collector knows how far to trust, and an uptime that tells a reboot from a counter wrap file-store File store records that survive a failed send, spooled to disk with a checksum at rest +origin Origin the device named in the record itself, not inferred from the source address diff --git a/run-report.md b/run-report.md index 8d575dc..6b50e16 100644 --- a/run-report.md +++ b/run-report.md @@ -1,4 +1,4 @@ -# solid-syslog-example — run (file-store) +# solid-syslog-example — run (origin) ## Device (self-measured) @@ -10,14 +10,14 @@ [device] first record logged: yes [report] --- SolidSyslog cost above baseline (simulated existing application) --- [report] key,current,baseline,used_above_baseline -[report] flash_text,361252,349992,11260 -[report] flash_data,632,316,316 -[report] static_bss,117652,110876,6776 +[report] flash_text,361640,349992,11648 +[report] flash_data,640,316,324 +[report] static_bss,117688,110876,6812 [report] heap_used,4440,4440,0 -[report] mbedtls_peak,21276,21332,-56 -[report] mbedtls_free,11492,11436,56 +[report] mbedtls_peak,21336,21332,4 +[report] mbedtls_free,11432,11436,-4 [report] lwip_mem_free,7576,7576,0 -[report] lwip_pbufs_free,14,14,0 +[report] lwip_pbufs_free,13,14,-1 [report] stack_log,568,120,448 [report] stack_service,788,52,736 [report] stack_harness,2848,2840,8 @@ -29,7 +29,7 @@ ```text text data bss dec hex filename - 361244 640 117652 479536 75130 /w/build/baseline-cross/baseline.elf + 361632 648 117688 479968 752e0 /w/build/baseline-cross/baseline.elf ``` ## Listeners (proved before the device ran) @@ -47,21 +47,21 @@ ## Collector (syslog-ng) received ```text -wire <134>1 2026-07-29T08:06:15.410000Z 10.0.2.15 solid-syslog-example - BOOT [meta sequenceId="1" sysUpTime="241"][timeQuality tzKnown="1" isSynced="0"] device started -parsed PRIORITY=134 TIMESTAMP=2026-07-29T08:06:15+00:00 HOSTNAME=10.0.2.15 APP_NAME=solid-syslog-example PROCID= MSGID=BOOT STRUCTURED_DATA=[meta sequenceId="1" sysUpTime="241"][timeQuality tzKnown="1" isSynced="0"] MSG=device started +wire <134>1 2026-07-29T08:21:38.360000Z 10.0.2.15 solid-syslog-example - BOOT [meta sequenceId="1" sysUpTime="236"][timeQuality tzKnown="1" isSynced="0"][origin software="solid-syslog-example" swVersion="0.1.0" enterpriseId="32473"] device started +parsed PRIORITY=134 TIMESTAMP=2026-07-29T08:21:38+00:00 HOSTNAME=10.0.2.15 APP_NAME=solid-syslog-example PROCID= MSGID=BOOT STRUCTURED_DATA=[meta sequenceId="1" sysUpTime="236"][timeQuality tzKnown="1" isSynced="0"][origin software="solid-syslog-example" swVersion="0.1.0" enterpriseId="32473"] MSG=device started ``` -## Self-check (vs measurements/file-store.csv) +## Self-check (vs measurements/origin.csv) ```text - OK flash_text: 361252 (expected 361252, Δ0) - OK flash_data: 632 (expected 632, Δ0) - OK static_bss: 117652 (expected 117652, Δ0) + OK flash_text: 361640 (expected 361640, Δ0) + OK flash_data: 640 (expected 640, Δ0) + OK static_bss: 117688 (expected 117688, Δ0) OK heap_used: 4440 (expected 4440, Δ0) - OK mbedtls_peak: 21276 (expected 21276, Δ0) - OK mbedtls_free: 11492 (expected 11492, Δ0) + OK mbedtls_peak: 21336 (expected 21336, Δ0) + OK mbedtls_free: 11432 (expected 11432, Δ0) OK lwip_mem_free: 7576 (expected 7576, Δ0) - OK lwip_pbufs_free: 14 (expected 14, Δ0) + OK lwip_pbufs_free: 13 (expected 13, Δ0) OK stack_log: 568 (expected 568, Δ0) OK stack_service: 788 (expected 788, Δ0) OK stack_harness: 2848 (expected 2848, Δ0)