PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
profinet::sim::InMemoryEthernetBus Class Reference

Small virtual Ethernet switch suitable for deterministic tests and demos. More...

#include <in_memory_ethernet.h>

+ Collaboration diagram for profinet::sim::InMemoryEthernetBus:

Public Member Functions

 InMemoryEthernetBus ()=default
 Construct an empty bus.
 
 ~InMemoryEthernetBus ()=default
 
 InMemoryEthernetBus (const InMemoryEthernetBus &)=delete
 
InMemoryEthernetBus & operator= (const InMemoryEthernetBus &)=delete
 
std::unique_ptr< InMemoryEthernetSocket > CreateSocket (MacAddress localMac)
 Create one virtual raw-Ethernet endpoint.
 
std::size_t EndpointCount () const
 Return the number of currently connected socket endpoints.
 
void ClearQueues ()
 Remove all queued frames without disconnecting endpoints.
 

Private Member Functions

void Attach (InMemoryEthernetSocket *socket)
 Attach one socket.
 
void Detach (InMemoryEthernetSocket *socket)
 Detach one socket.
 
void Transmit (InMemoryEthernetSocket &sender, const std::vector< std::uint8_t > &frame)
 Route a frame to matching endpoints.
 

Private Attributes

std::mutex mutex
 
std::vector< InMemoryEthernetSocket * > endpoints
 

Friends

class InMemoryEthernetSocket
 

Detailed Description

Small virtual Ethernet switch suitable for deterministic tests and demos.

Unicast frames are delivered to endpoints with a matching destination MAC. Broadcast and multicast frames are flooded to all other MAC endpoints. A frame is never reflected into another socket belonging to the same MAC address as its source. This is important because one virtual controller intentionally owns separate TX and RX sockets with the same MAC address.

Definition at line 91 of file in_memory_ethernet.h.

Constructor & Destructor Documentation

◆ InMemoryEthernetBus() [1/2]

profinet::sim::InMemoryEthernetBus::InMemoryEthernetBus ( )
default

Construct an empty bus.

◆ ~InMemoryEthernetBus()

profinet::sim::InMemoryEthernetBus::~InMemoryEthernetBus ( )
default

◆ InMemoryEthernetBus() [2/2]

profinet::sim::InMemoryEthernetBus::InMemoryEthernetBus ( const InMemoryEthernetBus &  )
delete

Member Function Documentation

◆ Attach()

void profinet::sim::InMemoryEthernetBus::Attach ( InMemoryEthernetSocket *  socket)
private

Attach one socket.

Definition at line 143 of file in_memory_ethernet.cpp.

References endpoints, and mutex.

Referenced by profinet::sim::InMemoryEthernetSocket::InMemoryEthernetSocket().

+ Here is the caller graph for this function:

◆ ClearQueues()

void profinet::sim::InMemoryEthernetBus::ClearQueues ( )

Remove all queued frames without disconnecting endpoints.

Definition at line 223 of file in_memory_ethernet.cpp.

References endpoints, and mutex.

Referenced by profinet::sim::TEST().

+ Here is the caller graph for this function:

◆ CreateSocket()

std::unique_ptr< InMemoryEthernetSocket > profinet::sim::InMemoryEthernetBus::CreateSocket ( MacAddress  localMac)

Create one virtual raw-Ethernet endpoint.

Parameters
localMacMAC address represented by the endpoint.
Returns
Owned endpoint detached automatically on destruction.

Definition at line 212 of file in_memory_ethernet.cpp.

Referenced by profinet::sim::VirtualPhoenixPlc::Connect(), profinet::sim::VirtualAumaValve::Start(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), profinet::sim::TEST(), and profinet::sim::TEST().

+ Here is the caller graph for this function:

◆ Detach()

void profinet::sim::InMemoryEthernetBus::Detach ( InMemoryEthernetSocket *  socket)
private

Detach one socket.

Definition at line 155 of file in_memory_ethernet.cpp.

References profinet::sim::InMemoryEthernetSocket::condition, profinet::sim::InMemoryEthernetSocket::connected, endpoints, profinet::sim::InMemoryEthernetSocket::mutex, mutex, and profinet::sim::InMemoryEthernetSocket::receiveQueue.

Referenced by profinet::sim::InMemoryEthernetSocket::~InMemoryEthernetSocket().

+ Here is the caller graph for this function:

◆ EndpointCount()

std::size_t profinet::sim::InMemoryEthernetBus::EndpointCount ( ) const

Return the number of currently connected socket endpoints.

Definition at line 217 of file in_memory_ethernet.cpp.

References endpoints, and mutex.

Referenced by profinet::sim::VirtualProfinetLab::StatusReport(), profinet::sim::TEST(), profinet::sim::TEST(), and profinet::sim::TEST().

+ Here is the caller graph for this function:

◆ operator=()

InMemoryEthernetBus & profinet::sim::InMemoryEthernetBus::operator= ( const InMemoryEthernetBus &  )
delete

◆ Transmit()

void profinet::sim::InMemoryEthernetBus::Transmit ( InMemoryEthernetSocket &  sender,
const std::vector< std::uint8_t > &  frame 
)
private

Route a frame to matching endpoints.

Definition at line 174 of file in_memory_ethernet.cpp.

References endpoints, frame, and mutex.

Referenced by profinet::sim::InMemoryEthernetSocket::Send().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ InMemoryEthernetSocket

friend class InMemoryEthernetSocket
friend

Definition at line 113 of file in_memory_ethernet.h.

Member Data Documentation

◆ endpoints

std::vector<InMemoryEthernetSocket*> profinet::sim::InMemoryEthernetBus::endpoints
private

Definition at line 126 of file in_memory_ethernet.h.

Referenced by Attach(), ClearQueues(), Detach(), EndpointCount(), and Transmit().

◆ mutex

std::mutex profinet::sim::InMemoryEthernetBus::mutex
mutableprivate

Definition at line 125 of file in_memory_ethernet.h.

Referenced by Attach(), ClearQueues(), Detach(), EndpointCount(), and Transmit().


The documentation for this class was generated from the following files: