## 3 Simulation Setup and Results
### Performance of The Proposed Bi-OCDMA  
A second simulation was conducted to test the proposed Bi-OCDMA under different channel conditions. The simulation was demonstrated using the architecture shown in Figure 3 with two simultaneous users. Some noise sources were implemented in the simulation to closely approximate the real environment of the FSO system. The noise sources included amplified spontaneous emission (ASE) noise, thermal noise, and shot noise with Gaussian distribution, where the total noise effect can be observed as:  
\[\sigma_{total}^{2}=\sigma_{th}^{2}+\sigma_{shot-S}^{2}+\sigma_{shot-ASE}^{2}+ \sigma_{S-ASE}^{2}+\sigma_{ASE-ASE}^{2} \tag{15}\]  
Each noise induced in the simulation can be verified as follows:  
* Thermal noise: \[\sigma_{th}^{2}=\frac{4.k_{B}.T}{R_{L}}.ENB\] (16)
* Shot-Signal Noise: \[\sigma_{shot-S}^{2}=2B_{e}\left(rM^{2}P_{S}+i_{d}\right)\] (17)
* Shot-ASE Noise: \[\sigma_{shot-ASE}^{2}=M^{2}F.2B_{e}.qrP_{ASE}\] (18)
* Signal-ASE Noise: \[\sigma_{S-ASE}^{2}=4B_{e}.r^{2}.M^{2}.PSD_{ASE}P_{s}\] (19)
* ASE-ASE Beat Noise: \[\sigma_{ASE-ASE}^{2}=r^{2}.M^{2}.PSD_{ASE}^{2}\] (20)  
where \(T\) is the absolute temperature of the device, \(R_{L}\) denotes the receiver load resistance, \(k_{B}\) is the Boltzmann constant, \(ENB\) is the receiver equivalent electrical noise bandwidth, \(B_{e}\) denotes the equivalent noise bandwidth of the photodetector, \(r\) is the PIN responsivity, \(M\) is the gain, \(F\) denotes the excess noise factor, \(P_{s}\) is the signal power, \(i_{d}\) denotes the device dark current, \(q\) is the electron charge value, \(P_{ASE}\) is the optical noise power, and \(PSD_{ASE}\) denotes the power spectral density of the optical noise field (spontaneous emission). Two channel conditions were implemented in the second simulation, namely, the AWGN channel and turbulence-induced fading channel. The AWGN channel was created by adding a white light source with a power of \(-130\) dBm to the optical signals before transmission through the FSO channel. Furthermore, the gamma-gamma distribution was applied to model the turbulence-induced fading channel in this simulation. In the gamma-gamma fading model, the probability of intensity \(I\) can be calculated as:  
\[P(I)=\frac{2(\alpha\beta)^{(\alpha+\beta)/2}}{\Gamma(\alpha)\Gamma(\beta)}I^{ (\alpha+\beta)/2-1}K_{\alpha-\beta}\left(2\sqrt{\alpha\beta I}\right) \tag{21}\]  
where \(\Gamma(\ldots)\) is the gamma function, and \(K_{\alpha-\beta}(\ldots)\) is the modified Bessel function of the second kind \(\frac{1}{a}\) and \(\frac{1}{b}\) are the variances of the small- and large-scale eddies, and can be evaluated as follows:  
\[\alpha=\exp\left[\frac{0.49\sigma_{R}^{2}}{\left(1+1.11\sigma_{R}^{12/5} \right)^{5/6}}\right]-1 \tag{22}\]\[\beta=\exp\left[\frac{0.51\sigma_{R}^{2}}{\left(1+0.69\sigma_{R}^{12/5}\right)^{5/6 }}\right]-1 \tag{23}\]  
where \(\sigma_{R}^{2}\) denotes the Rytov variance and is calculated from:  
\[\sigma_{R}^{2}=1.23C_{n}^{2}k^{7/6}z^{11/6} \tag{24}\]  
where \(C_{n}^{2}\) is the parameter index refraction structure with a value varying from \(10^{-13}\) m\({}^{-2/3}\) for intense turbulence to \(10^{-17}\) m\({}^{-2/3}\) for weak turbulence, \(k\) is the optical wavenumber, and \(z\) is the parameter range. First, a second simulation was conducted in the AWGN channel for extreme weather conditions based on the standard of propagation data required for the design of terrestrial free-space optical links from the International Telecommunication Union Radiocommunication Sector (ITU-R) P.1817 [38]. The attenuations under different weather conditions are shown in \[\sigma_{th}^{2}=\frac{4.k_{B}.T}{R_{L}}.ENB\]0  
Four well-known SAC-OCDMA codes, that is, MD code, MQC code, modified M-sequence code, and Walsh-Hadamard code, were applied in the simulation. These four codes satisfy the correlation properties of Equations (5) and (6), revealing the compatibility to be implemented in the proposed Bi-OCDMA structure.