SatCat5
eth_sw_log.h File Reference

Detailed Description

Diagnostic logging system for the Ethernet switch.

The classes defined in this file read or write diagnostic logs of packets that reach the switch or router, providing basic information about packet source/destination/type, and where it was directed or why it was dropped.

In low-rate debugging (i.e., only a few packets per second), the log will record every single packet. At higher rates, it will attempt to record packet information on a best-effort basis, with placeholders indicating how many packets were skipped between complete records.

The message format uses the same 24-byte format as "mac_log_core":

  • Timestamp in microseconds (24-bit) Counts up from switch reset, wraparound every 16.7 seconds.
  • Type indicator (3-bit)
    • 0 = Delivered packet
    • 1 = Dropped packet
    • 2 = Skipped packet(s)
    • (3-7 reserved)
  • Source port number (5-bit, all-ones if unknown)
  • Destination MAC address (48-bit, zero if unknown)
  • Source MAC address (48-bit, zero if unknown)
  • EtherType (16-bit, zero if unknown)
  • VLAN tag (16-bit)
  • Metadata for this packet Interpretation depends on the "Type indicator", see above.
    • Type = 0: Destination bit-mask Bit 31-00: Packet delivered to each port with a '1' bit.
    • Type = 1: Reason for packet drop Bit 31-08: Reserved Bit 07-00: Reason code, see "eth_frame_common.vhd"
    • Type = 2: Number of skipped packets Bit 31-16: Packets dropped Bit 15-00: Packets delivered

The eth::SwitchLogMessage struct represents one such message.

For some errors, frame information may not be available. In such cases, the header information is filled in with zeros, marking it as invalid.

The eth::SwitchLogWriter is notified for each individual packet, then writes the stream of log data. At low rates, every packet is logged individually. If the output buffer is nearly full, it instead generates a summary of skipped packets to provide rate-limiting of the log data.

The eth::SwitchLogReader class reads a stream of log data and notifies a callback for each received message. The eth::SwitchLogFormatter class is a child that generates human-readable log::Log messages.

The eth::SwitchLogStats class is an alternative to SwitchLogWriter that counts sent and received packets, rather than reporting the details of each one. Its API is similar to the one provided by cfg::NetworkStats.

Definition in file eth_sw_log.h.

#include <satcat5/cfgbus_core.h>
#include <satcat5/eth_address.h>
#include <satcat5/eth_switch.h>
#include <satcat5/io_writeable.h>
#include <satcat5/pkt_buffer.h>
#include <satcat5/polling.h>
#include <satcat5/udp_core.h>
Include dependency graph for eth_sw_log.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  satcat5::eth::SwitchLogMessage
 A single 24-byte packet-log message. More...
 
class  satcat5::eth::SwitchLogHardware
 Poll a hardware switch or router for log data. More...
 
class  satcat5::eth::SwitchLogStats
 Record packet statistics based on switch log events. More...
 
struct  satcat5::eth::SwitchLogStats::TrafficStats
 Data structure for reporting per-port traffic statistics. More...
 
class  satcat5::eth::SwitchLogStatsStatic< SIZE >
 Static allocation wrapper for eth::SwitchLogStats. More...
 
class  satcat5::eth::SwitchLogWriter
 Record rate-limited packet-logs for a switch or router. More...
 
class  satcat5::eth::SwitchLogBuffer< NPKT >
 Combine a SwitchLogWriter with a built-in output buffer. More...
 
class  satcat5::eth::SwitchLogReader
 Read packet-logs from an input stream or network interface. More...
 
class  satcat5::eth::SwitchLogFormatter
 Read binary packet logs to produce human-readable log messages. More...
 
class  satcat5::eth::SwitchLogToPort
 Forward binary packet logs to a network interface. More...