## 3 SHINe Core Building Blocks
### Routing Switch  
The core elements in a network are naturally the Routing Switches. One of the most critical points in the study and development of the SpaceFibre Network Layer is its interoperability with legacy SpaceWire networks. A realistic scenario in the transition phase between the two technologies foresees the use of SpaceFibre as a high-speed backbone with some of the nodes connected through SpaceFibre and some others through SpaceWire. While the two protocols are compatible from the packet format standpoint, there are no specifications about:  
* how to bridge Broadcast messages with the TimeCodes;
* how to forward packets between the two domains, where in SpaceFibre a packet is always associated to its Virtual Channel while in SpaceWire it is not;  
The Routing Switch available in SHINe allows connecting both SpaceFibre and SpaceWire Endpoints and implements realistic solutions to the open points listed above. An overview of the Routing Switch architecture is shown in Figure 4. A Routing Switch comprises a user defined number of ports of three possible kinds: (i) SpaceFibre Ports; (ii) SpaceWire Adapter Ports; or (iii) FIFO Ports. All of them share the same SpaceFibre interface to the internal Switching Matrix, but they differ in their implementations. In particular, the SpaceWire Adapter Port acts as a wrapper around a normal SpaceWire Port, making it to look like a SpaceFibre Port with only one Virtual Channel. Moreover, this wrapper is responsible for the bridging of Broadcast messages according to the following rule: whenever a TimeCode is received from the underlying SpaceWire port, it is wrapped into a Broadcast message of a specific type and then forwarded to the Switching Matrix to be propagated. Vice-versa, whenever the Switching Matrix tries to propagate a Broadcast message to a SpaceWire Adapter Port, the message is checked for its type: if it contains a TimeCode, the message is unwrapped and the TimeCode is sent, otherwise it is simply dropped. This simple mechanism makes possible for a SpaceFibre backbone to transparently carry TimeCodes. Moreover, the automatic loop prevention foreseen by the SpaceFibre standard guarantees that no multiple copies of the same TimeCode are propagated. The SHINe Routing Switch implements all the features required by the SpaceFibre standards. In particular, it supports:  
* Path and Logical Addressing. When using Path Addressing, the output port of the Routing Switch is directly written in the packet header. When using Logical Addressing, however, a Routing Table is necessary to associate the logical addresses to the output ports. The table can be provided by the user as a comma-separated file or can be built automatically by SHINe using Dijkstra algorithm in order to speed up the setup of the network;
* Virtual Network Mapping. For each Virtual Channel of each port, the user can specify the Virtual Network it belongs to. According to the SpaceFibre standard, packets can flow only through Virtual Channels belonging to the same Virtual Network. Note that, thanks to the Routing Switch implementation in SHINe, the single Virtual Channel of a SpaceWire Adapter Ports can be mapped into any Virtual Network. * Multicast Support. In case the user decides to specify a custom Routing Table, he can define, for a specific logical address, a Multicast set of output ports. When Multicast is used, an NChar is transferred from the input to all the output ports of the set at the same time, provided that they can all accept it. * Group Adaptive Routing Support. Similarly to Multicast, a custom Routing Table can include a set of output ports to be used for Group Adaptive Routing. When an input port requires a new wormhole to be open, only the first output port in the set that is found free is chosen, improving network performances. As already mentioned, the Routing Switch completely supports the Broadcast message mechanism, including the loop prevention and the per-channel timeout.