gem5 v24.0.0.0
Loading...
Searching...
No Matches
gem5::TCPIface Class Reference

#include <tcp_iface.hh>

Inheritance diagram for gem5::TCPIface:
gem5::DistIface gem5::Drainable gem5::Serializable

Classes

struct  NodeInfo
 Compute node info and storage for the very first connection from each node (used by the switch) More...
 

Public Member Functions

 TCPIface (std::string server_name, unsigned server_port, unsigned dist_rank, unsigned dist_size, Tick sync_start, Tick sync_repeat, EventManager *em, bool use_pseudo_op, bool is_switch, int num_nodes)
 The ctor creates and connects the stream socket to the server.
 
 ~TCPIface () override
 
- Public Member Functions inherited from gem5::DistIface
 DistIface (unsigned dist_rank, unsigned dist_size, Tick sync_start, Tick sync_repeat, EventManager *em, bool use_pseudo_op, bool is_switch, int num_nodes)
 ctor
 
virtual ~DistIface ()
 
void packetOut (EthPacketPtr pkt, Tick send_delay)
 Send out an Ethernet packet.
 
EthPacketPtr packetIn ()
 Fetch the packet scheduled to be received next by the simulated network link.
 
DrainState drain () override
 Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are partially executed or are partially in flight.
 
void drainResume () override
 Resume execution after a successful drain.
 
void init (const Event *e, Tick link_delay)
 
void startup ()
 
void serialize (CheckpointOut &cp) const override
 Serialize an object.
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object.
 
- Public Member Functions inherited from gem5::Drainable
DrainState drainState () const
 Return the current drain state of an object.
 
virtual void notifyFork ()
 Notify a child process of a fork.
 
- Public Member Functions inherited from gem5::Serializable
 Serializable ()
 
virtual ~Serializable ()
 
void serializeSection (CheckpointOut &cp, const char *name) const
 Serialize an object into a new section.
 
void serializeSection (CheckpointOut &cp, const std::string &name) const
 
void unserializeSection (CheckpointIn &cp, const char *name)
 Unserialize an a child object.
 
void unserializeSection (CheckpointIn &cp, const std::string &name)
 

Protected Member Functions

void sendPacket (const Header &header, const EthPacketPtr &packet) override
 Send out a data packet to the remote end.
 
void sendCmd (const Header &header) override
 Send out a control command to the remote end.
 
bool recvHeader (Header &header) override
 Receive a header (i.e.
 
void recvPacket (const Header &header, EthPacketPtr &packet) override
 Receive a packet from the remote end.
 
void initTransport () override
 Init hook for the underlaying transport.
 
- Protected Member Functions inherited from gem5::Drainable
 Drainable ()
 
virtual ~Drainable ()
 
void signalDrainDone () const
 Signal that an object is drained.
 

Private Member Functions

void sendTCP (int sock, const void *buf, unsigned length)
 Send out a message through a TCP stream socket.
 
bool recvTCP (int sock, void *buf, unsigned length)
 Receive the next incoming message through a TCP stream socket.
 
bool listen (int port)
 
void accept ()
 
void connect ()
 
int getfdStatic () const
 
bool islistening () const
 
bool anyislistening () const
 
void establishConnection ()
 

Private Attributes

int sock
 The stream socket to connect to the server.
 
std::string serverName
 
int serverPort
 
bool isSwitch
 
bool listening
 

Static Private Attributes

static bool anyListening = false
 
static int fdStatic = -1
 
static std::vector< std::pair< NodeInfo, int > > nodes
 
static std::vector< int > sockRegistry
 Storage for all opened sockets.
 

Additional Inherited Members

- Public Types inherited from gem5::DistIface
typedef DistHeaderPkt::Header Header
 
- Static Public Member Functions inherited from gem5::DistIface
static bool readyToExit (Tick delay)
 Initiate the exit from the simulation.
 
static bool readyToCkpt (Tick delay, Tick period)
 Initiate taking a checkpoint.
 
static uint64_t rankParam ()
 Getter for the dist rank param.
 
static uint64_t sizeParam ()
 Getter for the dist size param.
 
static void toggleSync (ThreadContext *tc)
 Trigger the primary to start/stop synchronization.
 
- Static Public Member Functions inherited from gem5::Serializable
static const std::string & currentSection ()
 Gets the fully-qualified name of the active section.
 
static void generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream)
 Generate a checkpoint file so that the serialization can be routed to it.
 
- Protected Types inherited from gem5::DistIface
typedef DistHeaderPkt::MsgType MsgType
 
typedef DistHeaderPkt::ReqType ReqType
 
- Protected Attributes inherited from gem5::DistIface
unsigned rank
 The rank of this process among the gem5 peers.
 
unsigned size
 The number of gem5 processes comprising this dist simulation.
 
unsigned distIfaceId
 Unique id for the dist link.
 
bool isPrimary
 
- Static Protected Attributes inherited from gem5::DistIface
static unsigned distIfaceNum = 0
 Number of DistIface objects (i.e.
 

Detailed Description

Definition at line 62 of file tcp_iface.hh.

Constructor & Destructor Documentation

◆ TCPIface()

gem5::TCPIface::TCPIface ( std::string server_name,
unsigned server_port,
unsigned dist_rank,
unsigned dist_size,
Tick sync_start,
Tick sync_repeat,
EventManager * em,
bool use_pseudo_op,
bool is_switch,
int num_nodes )

The ctor creates and connects the stream socket to the server.

Parameters
server_nameThe name (or IP address) of the host running the server process.
server_portThe port number the server listening for new connections.
sync_startThe tick for the first dist synchronisation.
sync_repeatThe frequency of dist synchronisation.
emThe EventManager object associated with the simulated Ethernet link.

Definition at line 82 of file tcp_iface.cc.

References accept(), DPRINTF, gem5::ArmISA::i, inform, gem5::DistIface::isPrimary, listen(), gem5::PowerISA::ni, nodes, panic, recvTCP(), serverPort, gem5::DistIface::size, and sock.

◆ ~TCPIface()

gem5::TCPIface::~TCPIface ( )
override

Definition at line 255 of file tcp_iface.cc.

References sock.

Member Function Documentation

◆ accept()

void gem5::TCPIface::accept ( )
private

Definition at line 208 of file tcp_iface.cc.

References accept(), fdStatic, gem5::ArmISA::i, sock, and warn.

Referenced by accept(), establishConnection(), and TCPIface().

◆ anyislistening()

bool gem5::TCPIface::anyislistening ( ) const
inlineprivate

Definition at line 120 of file tcp_iface.hh.

References anyListening.

◆ connect()

void gem5::TCPIface::connect ( )
private

Definition at line 222 of file tcp_iface.cc.

References connect(), DPRINTF, panic_if, serverName, serverPort, sock, and warn.

Referenced by connect(), and establishConnection().

◆ establishConnection()

void gem5::TCPIface::establishConnection ( )
private

◆ getfdStatic()

int gem5::TCPIface::getfdStatic ( ) const
inlineprivate

Definition at line 118 of file tcp_iface.hh.

References fdStatic.

◆ initTransport()

void gem5::TCPIface::initTransport ( )
overrideprotectedvirtual

Init hook for the underlaying transport.

Implements gem5::DistIface.

Definition at line 338 of file tcp_iface.cc.

References establishConnection().

◆ islistening()

bool gem5::TCPIface::islistening ( ) const
inlineprivate

Definition at line 119 of file tcp_iface.hh.

References listening.

◆ listen()

bool gem5::TCPIface::listen ( int port)
private

Definition at line 115 of file tcp_iface.cc.

References anyListening, fdStatic, listen(), listening, panic, and panic_if.

Referenced by listen(), and TCPIface().

◆ recvHeader()

bool gem5::TCPIface::recvHeader ( Header & header)
overrideprotectedvirtual

Receive a header (i.e.

meta info describing a data packet or a control command) from the remote end.

Parameters
headerThe meta info structure to store the incoming header.

Implements gem5::DistIface.

Definition at line 319 of file tcp_iface.cc.

References DPRINTF, header, recvTCP(), and sock.

◆ recvPacket()

void gem5::TCPIface::recvPacket ( const Header & header,
EthPacketPtr & packet )
overrideprotectedvirtual

Receive a packet from the remote end.

Parameters
headerMeta info about the incoming packet (obtanied by a previous call to the recvHedaer() method).
Pointerto packet received.

Implements gem5::DistIface.

Definition at line 328 of file tcp_iface.cc.

References header, panic_if, recvTCP(), and sock.

◆ recvTCP()

bool gem5::TCPIface::recvTCP ( int sock,
void * buf,
unsigned length )
private

Receive the next incoming message through a TCP stream socket.

Parameters
sockTCP stream socket.
bufStart address of buffer to store the message.
lengthExact size of the expected message in bytes.

Definition at line 281 of file tcp_iface.cc.

References inform, panic, and sock.

Referenced by establishConnection(), recvHeader(), recvPacket(), and TCPIface().

◆ sendCmd()

void gem5::TCPIface::sendCmd ( const Header & header)
overrideprotectedvirtual

Send out a control command to the remote end.

Parameters
headerMeta info describing the command (e.g. sync request)

Implements gem5::DistIface.

Definition at line 307 of file tcp_iface.cc.

References DPRINTF, header, gem5::ArmISA::s, sendTCP(), and sockRegistry.

◆ sendPacket()

void gem5::TCPIface::sendPacket ( const Header & header,
const EthPacketPtr & packet )
overrideprotectedvirtual

Send out a data packet to the remote end.

Parameters
headerMeta info about the packet (which needs to be transferred to the destination alongside the packet).
packetPointer to the packet to send.

Implements gem5::DistIface.

Definition at line 300 of file tcp_iface.cc.

References header, sendTCP(), and sock.

◆ sendTCP()

void gem5::TCPIface::sendTCP ( int sock,
const void * buf,
unsigned length )
private

Send out a message through a TCP stream socket.

Parameters
sockTCP stream socket.
bufStart address of the message.
lengthSize of the message in bytes.

Definition at line 264 of file tcp_iface.cc.

References gem5::exitSimLoop(), panic, panic_if, and sock.

Referenced by establishConnection(), sendCmd(), and sendPacket().

Member Data Documentation

◆ anyListening

bool gem5::TCPIface::anyListening = false
staticprivate

Definition at line 76 of file tcp_iface.hh.

Referenced by anyislistening(), and listen().

◆ fdStatic

int gem5::TCPIface::fdStatic = -1
staticprivate

Definition at line 77 of file tcp_iface.hh.

Referenced by accept(), getfdStatic(), and listen().

◆ isSwitch

bool gem5::TCPIface::isSwitch
private

Definition at line 73 of file tcp_iface.hh.

Referenced by establishConnection().

◆ listening

bool gem5::TCPIface::listening
private

Definition at line 75 of file tcp_iface.hh.

Referenced by islistening(), and listen().

◆ nodes

std::vector< std::pair< TCPIface::NodeInfo, int > > gem5::TCPIface::nodes
staticprivate

Definition at line 89 of file tcp_iface.hh.

Referenced by establishConnection(), and TCPIface().

◆ serverName

std::string gem5::TCPIface::serverName
private

Definition at line 70 of file tcp_iface.hh.

Referenced by connect().

◆ serverPort

int gem5::TCPIface::serverPort
private

Definition at line 71 of file tcp_iface.hh.

Referenced by connect(), and TCPIface().

◆ sock

int gem5::TCPIface::sock
private

The stream socket to connect to the server.

Definition at line 68 of file tcp_iface.hh.

Referenced by accept(), connect(), establishConnection(), recvHeader(), recvPacket(), recvTCP(), sendPacket(), sendTCP(), TCPIface(), and ~TCPIface().

◆ sockRegistry

std::vector< int > gem5::TCPIface::sockRegistry
staticprivate

Storage for all opened sockets.

Definition at line 93 of file tcp_iface.hh.

Referenced by establishConnection(), and sendCmd().


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

Generated on Tue Jun 18 2024 16:24:15 for gem5 by doxygen 1.11.0