SrpV3Emulation

rogue::protocols::srp::SrpV3Emulation is a software emulation of a hardware SRPv3 endpoint. It accepts SRPv3 request frames and sends SRPv3 response frames backed by an internal memory store. This module is used for CI regression testing of the SrpV3 client module without hardware.

For conceptual guidance, see SRP Protocol Version 3 Emulation.

Threading and locking summary

  • acceptFrame() may run from any stream transport thread.

  • Internal memory access is protected by a mutex.

Python binding

This C++ class is also exported into Python as rogue.protocols.srp.SrpV3Emulation.

Python API page: - SrpV3Emulation

objects in C++ are referenced by the following shared pointer typedef:

typedef std::shared_ptr<rogue::protocols::srp::SrpV3Emulation> rogue::protocols::srp::SrpV3EmulationPtr
[header]

The class description is shown below:

class SrpV3Emulation : public rogue::interfaces::stream::Master, public rogue::interfaces::stream::Slave
[header] [source]

Software SRPv3 server that emulates a hardware SRP endpoint.

SrpV3Emulation acts as the remote endpoint of the SRPv3 protocol, receiving SRPv3 request frames and producing SRPv3 response frames. It maintains an internal memory space, enabling full software-only testing of the SRPv3 protocol path without FPGA or ASIC hardware.

Typical CI/test usage connects SrpV3 (the client/master) to SrpV3Emulation via a bidirectional stream path:

SrpV3 (client) == SrpV3Emulation (server)

When a request frame arrives via acceptFrame(), the server queues the frame for processing on an internal worker thread. The worker:

  1. Decodes the SRPv3 header (version, opcode, transaction ID, address, size).

  2. For write/post requests: copies payload data into internal memory.

  3. For read requests: copies data from internal memory into the response.

  4. Builds and sends a response frame with the original header and a zero status tail (indicating success).

  5. For posted writes, no response frame is sent.

The worker thread avoids a deadlock that would occur if response frames were sent synchronously inside acceptFrame(), since SrpV3 holds a transaction lock during its doTransaction() call chain.

Memory is allocated on demand in 4 KiB pages, similar to rogue::interfaces::memory::Emulate.

Threading/locking model:

  • acceptFrame() queues frames and returns immediately.

  • A dedicated worker thread dequeues and processes frames serially.

  • Internal memory map access is protected by a mutex.

Protocol reference: https://confluence.slac.stanford.edu/x/cRmVD

Public Functions

SrpV3Emulation()
[header] [impl]

Constructs an SRP v3 server instance.

Constructor.

This constructor is a low-level C++ allocation path. Prefer create() when shared ownership or Python exposure is required. Starts an internal worker thread for processing queued request frames.

~SrpV3Emulation()
[header] [impl]

Destroys the SRP v3 server instance and frees allocated memory.

Destructor.

virtual void stop()
[header] [impl]

Stops the worker thread.

Stop the worker thread.

Called during shutdown to cleanly stop the processing thread.

virtual void acceptFrame(std::shared_ptr<rogue::interfaces::stream::Frame> frame)
[header] [impl]

Queues an incoming SRP v3 request frame for processing.

Queue an incoming frame for processing.

The frame is added to an internal queue and processed asynchronously by the worker thread. This avoids the deadlock that would occur from sending a response synchronously inside the calling thread’s transaction lock scope.

Parameters:

frame – Received SRP request stream frame.

Public Static Functions

static std::shared_ptr<rogue::protocols::srp::SrpV3Emulation> create()
[header] [impl]

Creates an SRP v3 server instance.

Class creation.

This static factory is the preferred construction path when the object is shared across Rogue graph connections or exposed to Python. It returns std::shared_ptr ownership compatible with Rogue pointer typedefs.

Company : SLAC National Accelerator Laboratory

Description : SRP protocol emulation, 3

This file is part of the rogue software platform. It is subject to the license terms in the LICENSE.txt file found in the top-level directory of this distribution and at: https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. No part of the rogue software platform, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE.txt file.

Returns:

Shared pointer to the created SrpV3Emulation.

static void setup_python()
[header] [impl]

Registers Python bindings for this class.

Setup class in python.