Design and implementation of a java based virtual laboratory for data communication simulation

Received May 25, 2019 Revised Feb 6, 2020 Accepted May 8, 2020 Students in this modern age find engineering courses taught in the university very abstract and difficult, and cannot relate theoretical calculations to real life scenarios. They consequently lose interest in their coursework and perform poorly in their grades. Simulation of classroom concepts with simulation software like MATLAB, were developed to facilitate learning experience. This paper involves the development of a virtual laboratory simulation package for teaching data communication concepts such as coding schemes, modulation and filtering. Unlike other simulation packages, no prior knowledge of computer programming is required for students to grasp these concepts.


RESEARCH METHOD
The communication process follows the framework of the Master Simulator given in Figure 1. The master simulator is a model that describes the process of communication from the transmitter to the receiver.

Stages of the communication process 2.1.1. Binary input
At the stage, the binary digits to be sent to the receiver are keyed into the communication system by the user or sender of the message. The user is prompted for the message bits to be transmitted in this stage.

The binary encoder
The coding scheme used in this project is the Hamming Code Scheme. The extended hamming code scheme i.e. Hamming (8,4), which can correct one-bit error and detect two-bit errors, is an improvement of Hamming (7,4) which can only detect and correct one-bit error. The code word transmitted in the Hamming Code Scheme is made up of four message or "input" bits and three check bits for the Hamming (7,4) and four check bits for the Hamming (8,4).
The hamming distance is the total number of positions in which two code words differ from each other. The smallest hamming distance of the Hamming (7,4) is 3, while the smallest hamming distance of the Hamming (8,4) is four. This minimum hamming distance is a measure of the error correcting power of the coding scheme. The Generator Matrix (G-MATRIX) is a matrix, such that when it is vector multiplied by the message bits, it gives the information signal with the check-bits appended to it. It is obtained by setting an identity matrix (of order k by k, where k is the number of message bits) to the left side of the matrix, and appending the check bits for the combination of each row, at the right side of the matrix. It is given by: For Hamming (n,4), the G-matrix is given by; The check bits are given by; where "+" signifies modulo-2 addition, represents the check bit, and represents the bit in the generator matrix with respect to each row.
The "input" bits or message bits are modulo-2 vector multiplied with the G-matrix. The result of this multiplication is the input bits with the check bits appended to it. For example, if bits sequence of '1010' are entered by the user, the code word becomes; Following the even parity scheme, one extra parity bit is appended to the code word. If the number of "1"s obtained in the result of the vector multiplication above is an even number, a parity bit of "0" is appended. If it is an odd number, a parity bit of "1" is appended to ensure that the number of bits transmitted is an even number. For the above example, the transmitted code word is 10101010. See Figure 2 for the flow chart.

Baseband signal
The baseband is the frequency range of a signal to be transmitted prior to when it is modulated at transmission. The baseband signal is generated from the result of the encoding process. The encoded bits are formed into a continuous square wave signal with two amplitude levels of 1 and -1. This signal is then sampled x/8 times per bit, where x is the total number of samples in the signal in a period of 1 second. From the formula; where is the sampling frequency, is the number of samples in one full period, and is the period, ( =1). Hence, if x is 2048, the signal is sampled at 256 per bit and the sampling frequency is 2048Hz. The non-return-to-zero transforms zeros '0s' in the sampled bits to amplitude levels of '-1'. The sampled bits become the baseband signal after the NRZ transformation is performed.

Modulation
Modulation is imposing the inherent characteristics of a baseband signal into a carrier signal. In this way, the signal is prepared to be transmitted over a channel that is most likely to impair the signal [14]. The modulation scheme employed is the binary phase shift keying (BPSK). BPSK offers strong resistance to noise across a channel [15]. Binary phase shift keying (BPSK) involves varying the phase of the carrier signal to provide information on the baseband signal. Non-return-to-zero (NRZ) encoding is first applied to the encoded message bits, converting the zeros to negative one (-1) and leaving the ones as 1. This signal is multiplied with the carrier signal. In BPSK, the signal is shifted by 180 degrees for every bit transition [16]. The carrier signal is given by (2 ), BPSK is achieved by multiplication of the carrier signal and the baseband signal such that,

Channel
The channel simulated in this project is an (AWGN) additive white gaussian noise channel, which is characterized by having a noise value present at every frequency in the frequency spectrum. It can be simulated by a method in Java syntax called Random.nextGaussian(), which would generate a sequence of numbers with a mean of 0 and standard deviation of 1 [17]. The process of transmission over the channel is described using a flowchart in Figure 3.

Demodulation
Demodulation is a process that seeks to obtain the baseband signal from the modulated signal. The BPSK demodulator is obtained by generating a carrier signal which is at the same phase and of the same frequency as the carrier signal for modulation at the transmitter and multiplying it with the received signal. In practical, a phase locked loop (PLL) [18] or a costas loop [19] is used to obtain the frequency and phase of the carrier from the received signal but however, designing a PLL is beyond the scope of this project. Hence, a carrier signal is generated, which is at the same phase and known frequency of the carrier signal used for modulation, and used to multiply the modulated signal [20].

Filtering
The purpose of filters in a communication system is to remove unwanted frequency components of a signal, implemented to remove noise or extract certain components of the signal. The filter used in this project is a finite impulse response (FIR), low pass filter. The demodulated signal is passed through the filter which would allow frequencies lower than the cut-off frequency and attenuate signals higher than the cut-off frequency, with the assurance of stability in its operation. Filtering in the time domain is a process of convolution of the filter coefficients and the demodulated signal [21]. If the length or number of taps of a filter is given by 2 + 1, the impulse response of a finite impulse response low pass filter whose terms are truncated to the length of the filter, is given by; The filter coefficients is obtained by shifting the impulse response of the filter by M samples: The filtered signal is finally given by: which is the convolution of the filter coefficients and the input signal. Due to the truncation of the filter coefficients during FIR filter designing, Gibbs oscillations are formed on the pass band of the filter [22]. A window function is multiplied with the filter coefficients to produce a filter with fewer oscillations. The window functions used in this paper are; -The rectangular window [23] ( ) = 1, − ≤ ≤ -The bartlett window [23] ( ) = 1 -| | , − ≤ ≤ -The hanning window [23] ( ) = 0.5 (1 + ) , − ≤ ≤ -The hamming window [23] ( ) = 0.54 − 0.46 * 2 2 , 0 ≤ ≤ 2

Threshold detection
The filtered signal is sampled at the midpoint for each set of bits used to represent an input. For example, if the signal was sampled at 2048 bits, the number of bits used to represent an input bit is 2048/8=256 bits. Hence, each set of 256 bits is sampled at midpoints, which could be 127, in this case. If the sampled amplitude is greater than 0, it is converted to '1', and if it is less than 0, i.e. near '-1', it is converted to '0'.

Decoder
On receiving the bits at the receiver, the bits are checked for errors first by checking the parity bit. For an even-parity system, the number of "1"s are an odd number, it means that at least one bit is in error. The hamming decoder utilizes the check matrix (H-matrix) to detect for the error in the received bit sequence by modulo-2 vector multiplication with the received bits to obtain a syndrome matrix (S). Assuming a received bit sequence of 10101010, after removal of the parity bit, the syndrome become, The syndrome sequence is compared with the H-matrix, and the column that corresponds with the syndrome matrix is the position with error in the received bit sequence. If the syndrome gives a sequence of zeroes, it means that there is no error in the received bits sequence, and that the error indicated is in the parity bit. The bit in the indicated error position is corrected. The received bit sequence is now ready to be decoded. The corrected received bit sequence is modulo-2 vector multiplied with the decoding matrix, denoted here as the R-matrix, to decode the signal. The original input bits and the decoded bits are compared, and if there are any differences, the number of differences is the bits in error.

Time and frequency analysis
The signal at each stage of the communication process would be analyzed by a virtual oscilloscope that would display a two-dimensional plot of the signal as a function of time, and a virtual spectrum analyzer that displays the magnitude frequency response of the signal. The frequency domain or spectrum of a signal can be obtained by the Fourier transform of the signal. The Fourier transform of a signal gives the complete description of the signal [24,25]. Signals are easier analyzed and synthesized in their frequency domains. For discrete time systems, the frequency spectra which is a function of continuous frequencies is obtained by the discrete time Fourier transform (DTFT). The discrete spectra are obtained by sampling the DTFT in a process known as obtaining the discrete fourier transform (DFT). The fast Fourier transform is used to obtain the DFT of a sampled signal. The Radix-2 Decimation-in-Time Cooley-Tukey algorithm for obtaining FFT of a signal was employed in this paper.

IMPLEMENTATION 3.1. Graphical user interface (GUI)
The GUI of the virtual laboratory shown in Figure 4 was built using Java Swing Forms, developed in NetBeans, an integrated development environment (IDE) for Java. It is user friendly, and tasks can be performed with just a click of buttons.

Performance of communication system using the virtual laboratory
The performance is obtained by plotting a graph of bit error rate (BER) on the y-axis, against the ratio of the energy per bit to noise spectral density (Eb/No) on the x-axis. Eb/No is usually measured in decibels (dB). Figure 5 gives a comparison of the simulated BPSK BER performance with and without the use of coding schemes and the theoretical BPSK BER performance.
It was observed in Figure 5 that Hamming Code scheme has better BER performance, when compared to the uncoded scheme. It shows that the communication system is less prone to errors when the Hamming Code scheme is used before transmission, compared to when it is uncoded. This confirms with the theory that there is a higher chance of receiving bits in errors when a coding scheme is not used before communication over an AWGN channel.
It was also observed that the simulated BER performance with the Hamming Code scheme was very similar to the theoretical BER performance. This is because the efficiency of the modulation scheme is enhanced with the introduction of an error checking and correction mechanism. Hence, the Hamming Code can be used to check and correct errors in the communication system, thereby increasing the reliability and efficiency. As shown in Figure 6, the use of window functions makes the channel more prone to errors as the Bit Error Rate is larger when window functions such as Hamming are used. This is because window functions introduce a wider transition band in the frequency response of the demodulated signal. The transition band is the band between the pass-band and the stop-band. The wider transition introduces more errors in the system.

CONCLUSION
In this paper, a virtual laboratory software package for simulation of key data communication concepts has been presented. It models a typical communication systems laboratory, which teaches key communication concepts such as modulation, filtering and information coding. The system is easy to use, with a user-friendly graphical user interface, and the simulation results show that errors can be combated using coding schemes, which confirms with theoretical concepts. This package would facilitate the understanding of students taking courses in Communication Systems in tertiary institutions and other interested users. This virtual laboratory is also available at the convenience of learners and interested participants