Skip to content

This code simulates a Quantum Key Distribution Protocol (specifically, BB84) using a popular network visualizer Mininet.

Notifications You must be signed in to change notification settings

elliotsyun/qkd-simulation-mininet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

README

Project: Quantum Key Distribution Simulation with Mininet

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.

Table of Contents

Introduction

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.

Requirements

  • Python 3.x
  • Mininet
  • Random module (included in Python standard library)

Setup Instructions

  1. Install Mininet: Follow the official Mininet installation guide: Mininet Installation

  2. Clone the Repository:

    git clone <repository_url>
    cd <repository_directory>
  3. Run the Simulation: Ensure you have the necessary permissions to run Mininet commands, typically requiring sudo.

    sudo python3 qkd_simulation.py

Usage

  1. Execute the script:

    sudo python3 qkd_simulation.py
  2. 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.

  3. Exit Mininet CLI: To exit the Mininet CLI, type exit or press Ctrl+D.

BB84 Protocol

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.

Step 1: Generate Bits and Bases

Alice generates a random sequence of bits and selects random bases (rectilinear + or diagonal x) for each bit.

Step 2: Encode Bits

Alice encodes her bits according to the chosen bases.

Step 3: Intercept and Measure

Eve intercepts the encoded bits and guesses bases to measure the bits. She may not always guess the correct bases, leading to potential errors.

Step 4: Measure Bits

Bob measures the received bits using his randomly chosen bases.

Step 5: Key Sifting

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.

Network Topology

The simulated network topology includes:

  • Two hosts: Alice and Bob.
  • One switch connecting Alice and Bob.
   alice ---- s1 ---- bob

Simulation Execution

The simulation script (qkd_simulation.py) performs the following actions:

  1. Sets up the Mininet topology with one switch and two hosts (Alice and Bob).
  2. Runs the BB84 QKD simulation to generate keys for Alice and Bob, and simulate Eve's interception.
  3. Prints the resulting keys and intercepted bits.
  4. 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.

About

This code simulates a Quantum Key Distribution Protocol (specifically, BB84) using a popular network visualizer Mininet.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages