Description
The Link Block module represents a connection between a Receiver and a Transmitter. It is used for transferring Telemetry Packets from the Transmitter component to the Receiver component. Link Blocks are created and managed by the Telemetry System as either an Optical Link Block or a Radio Link Block, depending on the Transmission Type of the Transmitter/Receiver connection being represented.
Example Use Cases
- Representing a connection between compatible Antennae: The Link Block class is used alongside the Data Subsystem and Receiver/Transmitter components to simulate the transmission of packets from one object to another. Telemetry packets can be created by the Transmitter and sent to a Receiver through the Link Block. The Link Block will allow the Receiver to access the Telemetry Packet once enough time has passed for the packet to have been successfully transmitted over the distance between the two objects, provided that there is a valid connection between the Transmitter and the Receiver.
Module Implementation
Each Link Block contains a reference to the Receiver and Transmitter that it is connecting, as well as an ID that is used to distinguish it from other Link Blocks. The Telemetry Packets transmitted by the Transmitter are stored by the Link Block and are transferred to a separate queue for the Receiver to access once the packet has successfully been transmitted between the two Antennae.
Determining Connection Validity:
During each tick, the Link Block will assess if the connection between the Antennae
is valid. For a connection to be valid, a Receiver must be connected. If a Transmitter and a Receiver are both connected, access can be determined by validating that there are no bodies that obstruct the line of sight between the transmission origin and destination. This can be done by treating any potentially obstructing bodies as spheres, and checking for an intersection between the sphere and a line between the Transmitter and the Receiver. is the Receiver’s position relative to the Inertial Frame, and is the Transmitter’s position relative to the inertial frame:
is the position of the potentially obstructing body’s origin:
A sphere, representing the potentially obstructing body, where is the radius of the sphere, can be represented as such:
A point on the line between the Receiver and Transmitter can be represented by the following equations:
Where u is a value between 0 and 1. Substituting the equation above into the equation for the sphere will result in a quadratic equation of the form:
where:
The quadratic equation can then be solved using:
If the discriminant is positive, or either solution to the equation is between 0 and 1, the connection between the Receiver and the Transmitter is invalid due to the sphere intersecting the line between the Antennae at least one point. The above process is repeated for all planets or bodies that could intersect a line drawn between the Receiver and Transmitter. If any planet obstructs the Line of Sight, the connection is invalid. To skip this check, and allow for transmissions even when the connection is obstructed by a body, the OverrideGroundAccess
flag may be set to true. If the connection is invalid, there are no other valid connections for the Transmitter, and the Transmitter’s Clear If Inaccessible
flag is set, the Transmitter’s TelemetryMsgArray
will be cleared. This means that any data that attempts transmission while the connection is invalid will be lost.
Transmission / Reception:
When a packet is transmitted, the Transmitter will store it in a list called Out_TelemetryMsgQueue
. For each update, the Link Block will create a copy of this list, transfer any new packets from the Transmitter into the Link Block (Stored in a list called In_TelemetryMsgArray
), and clear the packets from the list on the Transmitter. Each Telemetry Packet has a time value, which is the timestamp for when the message was transmitted. The Link Block will calculate how long it would take for a message to travel from the Transmitter to the Receiver based on the distance between the two Antennae and the speed of light in a vacuum:
Where is the Receiver’s position relative to the Inertial Frame, is the Transmitter’s position relative to the inertial frame, and is the speed of light in a vacuum. If the timestamped value plus the travel time is greater than or equal to the current time, then the packet has arrived at the Receiver and is thus transferred from the Link Block’s In_TelemetryMsgArray
to its Out_TelemetryMsgQueue
, where it can be accessed by a Receiver component. Additionally, packet corruption may be simulated at this stage. If the Transmitter’s Packet Corruption Fraction
value is above zero, the telemetry packet may have random bytes set to the maximum value (11111111) or experience bit flipping (10100101 → 01011010).
Optical Link Blocks:
The Optical Link Block class is a child of the base Link Block class. It is used to represent optical laser transmissions and contains an additional Line Of Sight
flag that must be set to true for the transmission to succeed. This value must be calculated by another class, and will not update itself automatically.
Radio Link Blocks:
The Radio Link Block class is a child of the base Link Block class. It is used to represent radio transmissions by accounting for a variety of factors including antenna gain, pointing loss, free-space path loss, atmospheric loss, and transmitter line loss when determining if the connection is valid:
Where refers to the Transmitter, refers to the Receiver, and is the Boltzmann constant. If the calculated Signal-to-Noise (dB) value is greater than the Receiver’s Signal-to-Noise Threshold value, the connection is valid and is able to transmit data.
References
[1] Bourke, P. (1992, November). The intersection of a Line and a Sphere (or circle). Retrieved from http://paulbourke.net/: http://paulbourke.net/geometry/circlesphere/index.html#linesphere