COMP4336/9336 Mobile Data Networking Lab 2
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
COMP4336/9336 Mobile Data Networking
Lab 2: Wireless Signal Strength and SNR – Simulation vs Real Wi-Fi Measurements
Objectives
By the end of this lab, you will be able to:
1. Use the Friis free-space model to simulate how wireless signal strength changes with distance.
2. Compute SNR from simulation and interpret SNR values from both simulated and real data.
3. Analyze a real Wi-Fi trace and compare it with simulation results.
4. Reflect on why theoretical predictions and real-world measurements differ.
Part I – MATLAB Simulation of Free-Space Path Loss (2 Marks)
In this part, you’ll simulate signal strength and SNR using the Friis equation. The user equipment (UE) is modeled as moving toward and away from an access point in four stages:
• 1→20 m (UE moves away)
• 20→ 1 m (UE comes closer)
• 1→20 m (UE moves away again)
• 20→ 1 m (UE returns)
Task 1 – Friis Model and Parameter Exploration (1 Mark)
The Friis equation is implemented in the MATLAB template provided. Your tasks are:
• Complete the code by setting the transmitter and receiver antenna gains (assume isotropic antennas).
• Run the code to generate Free-Space Path Loss (FSPL), Pr (received signal strength), and SNR values
• Verify that FSPL increases by about 6 dB each time the distance doubles.
Experiment by varying parameters (frequency, transmit power, noise floor, antenna gains) and
• Observe how signal strength and SNR change and comment briefly on the affects you observe.
Note on Parameter Exploration:
In your MATLAB (i.e., `.mlx`) submission, include at least two additional runs where you vary parameters (e.g., frequency, transmit power, noise floor). For each variation:
• Add extra code cells with the modified parameter values and show the corresponding FSPL, signal strength, and SNR.
• Write a short text comment (2–3 sentences) under each cell explaining what effect you observed.
This ensures your parameter exploration is visible in the single `.mlx` file you submit.
• Note on Fluctuations:
In reality, wireless signals are never perfectly stable. Even if the UE stays still, the measured signal strength varies slightly due to various factors. To mimic this, the MATLAB code adds small random fluctuations:
• Transmit power varies by about [0-2] dB.
• Noise floor varies by about [0-1] dB.
This makes the simulated plots look closer to real Wi-Fi measurements and prepares you for comparison with the real trace in Part II.
Task 2 – Plot Signal Strength and SNR (1 Mark)
Generate plots for Signal Strength and SNR versus packet index using the provided MATLAB template.
After generating the plots, answer briefly:
• How does signal strength change as the UE moves away from and closer to the AP?
• How does SNR behave compared to signal strength?
• What do the fluctuations in the plots represent?
Part II – Real Wi-Fi Trace Analysis (2 Marks)
Note on Wi-Fi Beacons and the Trace File:
In Wi-Fi networks, access points (APs) regularly transmit beacon frames to announce their presence and network parameters. These beacons are sent at fixed intervals (typically every 100 ms) and can be captured using tools such as Wireshark.
For this lab, you are provided with a Wi-Fi trace file containing beacon frames from a single AP with SSID `COMP4336`. Each beacon in the trace includes:
• Signal Strength (dBm) measured at the receiver,
• Signal-to-Noise Ratio (SNR, dB).
Since beacons are broadcast at regular intervals, they provide a convenient way to study how received signal strength and SNR vary as the UE (user equipment) moves away from and back toward the AP.
Now we’ll analyze a Wi-Fi trace collected in a real experiment where a laptop moved away from and toward a WiFi hotspot in the same pattern as in Part I.
Task 1 – Extract Signal Strength and SNR from Beacon Data to CSV (0.5 Marks)
First, use Wireshark to filter beacon frames and export the signal strength and SNR into a CSV file ('COMP4336_lab2.csv'). You will then run the MATLAB code in the provided template to perform a sanity check, ensuring that the data has been correctly extracted from Wireshark.
The MATLAB code essentially loads the Wireshark-exported CSV file, into a table, checks that the required columns ('Signal strength (dBm)' and 'Signal/noise ratio (dB)') are present and displays the first few rows. If the file is missing or in the wrong format, the code provides an error message. This step is a sanity check to ensure the data was exported correctly before moving on to numeric conversion in Task 2.
Task 2 – Convert Signal Strength and SNR into Numeric Values (0.5 Marks)
The exported CSV file contains values such as '-65 dBm' and '25 dB' stored as text. To perform calculations, these units must be removed and the values converted into numbers.
Your task is to learn and implement the MATLAB code to achieve this. You can use the following two MATLAB functions:
• erase(str, match) removes the units.
• str2double(str) converts the cleaned strings into numeric values.
The result is two numeric arrays: signalStrength and snrValues, which can now be plotted and analyzed.
Task 3 – Compare Simulation with Real Data (1 Mark)
Plot the simulated data and the data from the real trace on the same graph.
Answer the following questions briefly:
• What similarities do you observe between the simulated and real data?
• What differences stand out in the plots?
• Based on your observations, what real-world factors could explain these differences?
Submission Instructions (Total 4 Marks)
You must submit the following on Moodle/Canvas:
1. Your completed MATLAB Live Script (.mlx) containing:
- All completed code (no missing TODOs).
- Plots generated for Part I and Part II.
- Answers to reflection questions written as text cells in the `.mlx` file.
- Evidence of parameter exploration (at least two variations with plots and short explanations).
2. A PDF export of your Live Script (use File → Export As → PDF in MATLAB Live Editor).
- This ensures markers can view your plots and answers without running your code.
Marking:
- Part I (2 Marks): Simulation setup, formulas, plots, and parameter exploration.
- Part II (2 Marks): Real trace analysis, numeric conversion, comparison plots.
- Reflection questions are included in Part II marking.
Important: Only `.mlx` and PDF submissions are accepted. Screenshots or Word files are not sufficient.
2025-09-26