## 3 SHINe Core Building Blocks
### SpaceFibre Endpoint  
The SpaceFibre Endpoint module is the core building block in SHINe to instantiate a fully-functional SpaceFibre port. As shown in Figure 2, it provides two input/output gates for the connection with the upper layer application and one input/output gate representing the physical SpaceFibre connector. Note that there are two gates towards the upper layer, one for the NChar transmission (_appPacket_) and one for the Broadcast messages transmission (_appBroadcast_), allowing using two different applications in case the user prefers to model the two interfaces separately. In order to be connected to a SpaceFibre Endpoint, an application must extend the _ToSpfApplication_ C++ abstract class. This class represents the interface that the Endpoint can use to notify about the availability of new NChars or Broadcast  
Figure 1: Interaction between User Application and SpaceFibre or SpaceWire Endpoint.  
messages to read. A SpaceFibre Endpoint automatically collects several metrics about network usage, such as: (i) packet latency; (ii) packet inter-arrival time; (iii) packet inter-transmission time; and (iv) broadcast message latency.  
The SpaceFibre Endpoint is a versatile module and it can include either a SpaceFibre Port or a First In Firt Out (FIFO) Port, as specified in the standard, depending on a user defined parameter. The FIFO Port does not implement any specific transfer protocol and it is only capable of transferring NChars between the two far-ends, simulating a generic FIFO-like protocol but offering the same interface to the application of a SpaceFibre Port. Note that it does not provide a way to transmit Broadcast messages as well as a flow control mechanism, so data may be lost. When the SpaceFibre Port is chosen, the whole SpaceFibre protocol as described in the standard is used. In particular, the following features are supported:  
* Fault Detection Isolation and Recovery (FDIR) mechanism, with retransmission in case of (injected) errors;
* Flow Control Mechanism (FCT);
* IDLE words, IDLE Frames and SKIP words insertion (See [4] for details on SpFi control words);
* Multilane layer support;
* Upper lane layer support, excluding 8b/10b encoding and serialisation. The OMNeT++ messages exchanged between SpaceFibre Endpoints represent an abstraction of the 40-bits SpaceFibre words. The choice to simulate at \"word level\" instead of at \"bit level\" has been taken because, from a networking standpoint, the simulation of the physical layer does not add any additional value to the results but it greatly affects the simulation time;  
Both the Lane and the Multilane Layers can be bypassed to save additional simulation time if the user is not interested in simulating their behaviour and the overhead they add to the protocol. Each deployed SpaceFibre Endpoint can be independently configured through all the parameters foreseen by the standard, such as the Expected Bandwidth, the Priority levels, the Assigned Timeslots, etc., plus additional parameters such as buffers size and number of lanes. It is also possible to define a transmission and reception delay at the interface with the link to simulate internal buffers or pipeline stages in the data-path.  
Figure 2: Internal architecture of a SpaceFibre Endpoint.