MATLAB simulation of a cooperative wireless system implementing Network Coding (XOR in the Air).
The project compares Simple Forwarding vs Network Coding (XOR) under IEEE 802.11g-like settings, and reports transmission time and packet loss.
Wireless links often suffer from collisions and losses when multiple nodes transmit. In a classic three-node setup (Alice β Relay β Bob), the relay can operate in two ways:
- The relay retransmits each packet separately (AβR then RβB; and BβR then RβA).
- Pros: straightforward, robust.
- Cons: 4 transmissions per bidirectional exchange β lower spectral efficiency.
- The relay combines packets from Alice and Bob using bitwise XOR:
Pxor = PA β PB. - It broadcasts one coded packet instead of two.
- Alice and Bob decode the otherβs data by XOR-ing with their own packet.
- Effect: reduces transmissions from 4 β 3 per full exchange β higher efficiency.
- Trade-off: if either of the two upstream packets is lost, the coded transmission cannot proceed.
- Each link may lose packets with probability p (here 10%).
- Every failed transmission is retried up to 3 times; after that the packet is counted as lost.
- Standard: IEEE 802.11g-like channel
- Channel capacity: 54 Mbps
- Packet size: 1024 bits
- Trials: 100 bidirectional exchanges
- Loss probability: 10% per link attempt
- Max retries: 3 per hop
| Metric | Simple Forwarding | Network Coding |
|---|---|---|
| Total transmissions | 447 | 322 |
| Lost packets | 0 | 31 |
| Transmission time (sec.) | 0.008476 | 0.006106 |
Takeaways
- XOR coding reduces transmissions and lowers time.
- It may experience higher losses.
- Choice depends on efficiency vs robustness requirements.
xor-in-the-air/
ββ src/Proiect_CasuneanuDiana.mlx # MATLAB Live Script
ββ results/ # optional: export plots/tables
ββ README.md
ββ .gitignore
- Open MATLAB (R2020+ recommended).
- Load
src/Proiect_CasuneanuDiana.mlx. - Run the Live Script to simulate both modes.
- Export plots/tables into
results/if needed.
matlab, network-coding, xor-in-the-air, wireless-networks, simulation, computer-networks