This project demonstrates a basic Quantum Key Distribution (QKD) simulation using the BB84 protocol within a Mininet network. Mininet is used to simulate the network topology, and Python is used to handle the QKD simulation.
- Introduction
- Requirements
- Setup Instructions
- Usage
- BB84 Protocol
- Network Topology
- Simulation Execution
Quantum Key Distribution (QKD) is a secure communication method that uses quantum mechanics to generate a shared, random secret key between two parties. This project simulates the BB84 protocol, a QKD scheme, using Mininet to emulate the network environment.
- Python 3.x
- Mininet
- Random module (included in Python standard library)
-
Install Mininet: Follow the official Mininet installation guide: Mininet Installation
-
Clone the Repository:
git clone <repository_url> cd <repository_directory>
-
Run the Simulation: Ensure you have the necessary permissions to run Mininet commands, typically requiring
sudo
.sudo python3 qkd_simulation.py
-
Execute the script:
sudo python3 qkd_simulation.py
-
Interacting with Mininet CLI: The script will launch Mininet and print the keys generated by Alice and Bob, as well as the bits intercepted by Eve.
-
Exit Mininet CLI: To exit the Mininet CLI, type
exit
or pressCtrl+D
.
The BB84 protocol involves several steps to securely distribute a key between two parties, Alice and Bob, with a potential eavesdropper, Eve, intercepting the communication.
Alice generates a random sequence of bits and selects random bases (rectilinear +
or diagonal x
) for each bit.
Alice encodes her bits according to the chosen bases.
Eve intercepts the encoded bits and guesses bases to measure the bits. She may not always guess the correct bases, leading to potential errors.
Bob measures the received bits using his randomly chosen bases.
Alice and Bob compare their bases over a public channel and keep only the bits where their bases match. This forms the final secret key.
The simulated network topology includes:
- Two hosts: Alice and Bob.
- One switch connecting Alice and Bob.
alice ---- s1 ---- bob
The simulation script (qkd_simulation.py
) performs the following actions:
- Sets up the Mininet topology with one switch and two hosts (Alice and Bob).
- Runs the BB84 QKD simulation to generate keys for Alice and Bob, and simulate Eve's interception.
- Prints the resulting keys and intercepted bits.
- Launches the Mininet CLI for further interaction.
To start the simulation, simply run:
sudo python3 qkd_simulation.py
This will initialize the network, perform the QKD simulation, and open the Mininet CLI for additional commands or inspection.