# A Realistic, Flexible and Extendible Network Emulation Platform for Space Networks
## 4 Designs
### Link
#### 4.2.2 Implementation of a Time-Varying Connection Relationship
The line crossing point GS means the tangent plane to Earth's surface at point GS, which by definition is in fact the ideal horizon plane. The angle formed between the ideal horizon plane and the slant range is elevation angle \(\epsilon_{0}\). Figure 5(b) is the plane form of the triangle from Figure 5(a). Two sides of this triangle are usually known as the distance from the ground station to the Earth's center \(R_{E}\), and the distance from the satellite to the Earth's center-orbital radius. The angle under which the satellite sees the ground station is called the nadir angle. There are four variables in this triangle: \(\epsilon_{0}\) is the elevation angle, \(\alpha_{0}\) is the nadir angle, \(\beta_{0}\) is the central angle and \(d\) is the slant range. As soon as two quantities are known, the others can be found with the following equations:  
\[\epsilon_{0}+\alpha_{0}+\beta_{0}=90 \tag{10}\]  
\[d\cos(\epsilon_{0})=r\sin(\beta_{0}) \tag{11}\]  
\[d\sin(\alpha_{0})=R_{E}\sin(\beta_{0}) \tag{12}\]  
The most important parameter is the slant range \(d\) which represents the distance from the ground station to the satellite. It is expressed through the elevation angle \(\epsilon_{0}\). Applying the cosines law for the triangle at Figure 6 yields:  
\[r^{2}=R_{E}^{2}+d^{2}-2R_{E}d\cos(90+\epsilon_{0}) \tag{13}\]  
Solving Equation (5) by \(d\) yields:  
\[d=R_{E}\Bigg{[}\sqrt{\left(\frac{r}{R_{E}}\right)^{2}-\cos^{2}\epsilon_{0}- \sin\epsilon_{0}}\Bigg{]} \tag{14}\]  
Substituting, \(r=H+R_{E}\) at Equation (14), finally we will obtain the slant range as function of elevation angle \(\epsilon_{0}\):  
\[d=R_{E}\Bigg{[}\sqrt{\left(\frac{H+R_{E}}{R_{E}}\right)^{2}-\cos^{2}\epsilon_ {0}-\sin\epsilon_{0}}\Bigg{]} \tag{15}\]  
Figure 6: Geometry of the ground station. or elevation \(\varepsilon_{0}\) expressed for a known slant range \(d\) as:  
\[\sin\varepsilon_{0}=\frac{H(H+2R_{E})-d^{2}}{2 dR_{E}} \tag{16}\]  
When \(\sin\varepsilon_{0}=0\Rightarrow\varepsilon_{0}=0\), the maximum slant range \(d\) is found:  
\[r=R_{E}+H \tag{9}\]0  
If the distance between the Sat and the GS is outside of the maximum value of \(d\), the two nodes are considered invisible. Finally, on the basis of link establishment strategies set by researchers, these mutual visibilities are filtered to obtain connection relationships in a specific scenario. (2) Implementation Method  
Connection relationships are stored in databases, which are formulated as follows. Link_id is the link name. Srcnode_port and dstnode_port represent the connection port of the source node and destination node on virtual switches separately. The scrnode field in srcnode_port means the host name of the emulation node. It is the same for dstnode_port. Start_time and end_time represent the beginning and ending times of a link connection, respectively. Emulation nodes use virtual ethernet (veth) devices [30] to access the virtual switch on the server where it is located. Each veth represents an antenna or a communication channel in the network scenario. Veth devices are created in pairs. One device in the pair is assigned to the emulation node as a network interface and the other is assigned to the virtual programmable switch as a port. When either device is down, the link state of the pair is down. So, the variation of connection relationships between pair-wise nodes equates to deleting/adding corresponding flow entries on virtual switches to control the port up and down. However, a port-based flow entry can only control the one-way link. Thus, two flow entries are needed to control a link connection, which is two-way, on or off. The main controller later allocates corresponding network parameters for network interfaces at the emulation node, including IP addresses, MAC addresses, interface names, etc. The neighboring veths which are connected with each other in one hop have the same subnetwork segment. Whenever corresponding forwarding rules between these veths are deployed, the links between neighboring emulation nodes are working.