## 2 System Design
### PWDF Versus Ranging Error  
The observation of pseudo-ranging is extracted from the tracking loop, without considering the multiple effects and other sources of interferences, and the ranging results are mainly affected by the thermal noise error and the dynamic stress error, which can be described as  
\[\sigma_{DLL}=\sigma_{tDLL}+\frac{\theta_{e}}{3}, \tag{18}\]  
where \(\sigma_{tDLL}\) represents the bias of tracking caused by thermal noise, and \(\theta_{e}\) represents dynamic stress error of relative motion between the two satellites. In the tracking processing, the dynamic stress error is eliminated with the aid of the carrier loop, and the tracking error can be represented as an empirical formula, calculated approximately as [24; 25]\[=\left\{ \begin{array}{c}\frac{\sigma_{DDL}}{\sqrt{\frac{B_{L}}{2C/N_{0}}D \Big{(}1+\frac{2}{(2-D)T_{coh}\subset C/N_{0}}\Big{)}}}\;\;D\geq\frac{\pi}{B_{fc }T_{c}}\\ \sqrt{\frac{B_{L}}{2C/N_{0}}\Bigg{(}\frac{1}{B_{fc}T_{c}}+\frac{B_{fc}T_{c}}{ \pi-1}\Big{(}D-\frac{1}{B_{fc}T_{c}}\Big{)}^{2}\Bigg{)}\Bigg{(}1+\frac{2}{(2-D) T_{coh}\subset N_{0}}\Bigg{)}}\;\;\frac{1}{B_{fc}T_{c}}<D<\frac{\pi}{B_{fc}T_{c}}\\ \sqrt{\frac{B_{L}}{2C/N_{0}}\frac{1}{B_{fc}T_{c}}\Big{(}1+\frac{2}{T_{coh}\subset N _{0}}\Big{)}}\;\;D\leq\frac{1}{B_{fc}T_{c}}\end{array} \right. \tag{19}\]  
```
Input :PWDF \(\alpha\), communication data \(x^{MS}\) and \(x^{SM}\), total time slots \(N\) Output :Ranging result \(D\), recovered data \(\hat{x}^{MS}\) and \(\hat{x}^{SM}\), and clock offset \(\Delta t\)
1 for\(i=1\):\(N\)do
2 From Master to Slave:
3 Generate the ranging signal \(x^{i}_{i}\) in I branch;
4 Generate the communication signal \(x^{0}\) in Q branch according to \(x_{i}\);
5 Calculate the I branch power \(p^{\prime}\) and Q branch power \(p^{0}\) according to Equations (3) and (4);
6 Generate the transmitting signal based on UQPSK: \(x^{\prime}=p^{\prime}x^{\prime}_{i}+p^{0}x^{0}_{i}\);
7 FLAG_acquisition_success = 0;
8 While FLAG_acquisition_success = 0 do
9 Execute the acquisition section;
10 If success, obtain the coarse carrier phase \(f^{\prime}_{i}\), code phase \(\tau^{\prime}_{i}\), and set FLAG_acquisition_success = 1;
11 end if
12 ifFLAG_acquisition_success = 1 then
13 Execute the tracking section, obtain the refined carrier phase \(\hat{f}\), and code phase \(\tau\), ranging result \(\rho^{\prime\alpha}_{i}\);
14 Recover the communication data \(\hat{x}^{MS}_{i}\) according to the joint Costas loop and Gardner loop in Section 2;
15 end if
16 From Slave to Master:
17 Similar to From Master to Slave in Line 3-15, obtain ranging result \(\rho^{\prime\alpha}_{i}\), and recover the communication data \(\hat{x}^{SM}_{i}\);
18 end if
19 Measurements fusion:
20 Calculate the ranging result \(D\) according to Equation (7);
21 Calculate the clock offset \(\Delta t\) according to Equation (8). ```  
**Algorithm 1**Joint ranging and communication algorithm in distributed spacecraft networks  
The parameters in Equation (19) are defined as follows. \(B_{fc}\) and \(B_{L}\) are RF front-end bandwidth and loop noise bandwidth, respectively. \(T_{c}\) is the chip width of pseudo-code and \(T_{coh}\) is the coherent integration time. \(D\) is correlator spacing and \(C/N_{0}\) is the CNR. In our designed system, \(B_{L}\), \(D\) and \(T_{coh}\) are set as 5 Hz, 1 chip and 1 ms, respectively, in both uplink and downlink, and \(T_{c}\) is different in uplink and downlink. \(T_{c}\) is 1/10,230 ms in uplink, and 1/20,460 ms in downlink. \(B_{fc}\) of two links are set as 20.46 and 40.92 MHz, respectively. Based on these parameters, the theoretical ranging error can be calculated according to the middle formula in Equation (19). Therefore, the ranging error under the effect of the PWDF can be derived by substituting Equations (3) and (4) into the middle of Equation (19).