Q2NS dev
ns-3 module
Loading...
Searching...
No Matches
q2ns-teleportation-helper.h
Go to the documentation of this file.
1/*-----------------------------------------------------------------------------
2 * Q2NS - Quantum Network Simulator
3 * Copyright (c) 2026 quantuminternet.it
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *---------------------------------------------------------------------------*/
9
10#ifndef Q2NS_TELEPORTATION_HELPER_H
11#define Q2NS_TELEPORTATION_HELPER_H
12
13#include "ns3/q2ns-netcontroller.h"
14#include "ns3/q2ns-qnode.h"
15
16#include "ns3/node.h"
17#include "ns3/ptr.h"
18
19#include <cstddef>
20#include <cstdint>
21#include <string>
22#include <unordered_map>
23#include <vector>
24
25namespace q2ns {
26
28 std::string src;
29 std::string dst;
30 double start_s{0.0};
31 uint64_t sessionId{0};
32 uint16_t ctrlPort{0}; // 0 => auto-assign
33 std::string protocol; // optional per-session override ("" => use link/default)
34};
35
36struct LinkSpec {
37 std::string u, v; // node names
38 double mbps{1.0};
39 std::string protocol{"udp"}; // "udp" | "tcp" (used for ctrl + bg defaults)
40 double delayNsPerKm{5000};
41 double distanceKm{0};
42 std::string queueMax{"128kB"};
43};
44
45struct NodeSpec {
46 std::string name;
47};
48
50 std::vector<NodeSpec> nodes;
51 std::vector<LinkSpec> classicalEdges;
52 std::vector<LinkSpec> quantumEdges; // delay only (ideal noise for now)
53 std::vector<SessionSpec> sessions;
54 std::string backend{"ket"};
55};
56
58public:
59 TeleportationHelper& UseBackend(std::string backend);
60 TeleportationHelper& SetDefaultQueue(std::string max);
61 TeleportationHelper& SetPortBase(uint16_t base);
62
63 // Provide the central orchestrator (non-owning pointer).
65
66 // Provide the 1-qubit state to be teleported (used by both Alice & Bob apps)
67 TeleportationHelper& SetTeleportState(const std::shared_ptr<q2ns::QState>& tpl);
68
69 // Main entry: build nodes/links, install apps/background, set addresses/queues
70 void Install(const TopologySpec& spec);
71
72private:
73 uint16_t m_portBase{7000};
74 std::string m_defaultQueue{"128kB"};
75 std::string m_backend{"ket"};
76
77 // Central orchestrator (required for node creation & quantum wiring)
79
80
81 std::unordered_map<std::string, ns3::Ptr<ns3::Node>> m_name2node;
82
83 std::shared_ptr<q2ns::QState> m_teleportState{nullptr};
84
85 uint16_t AllocatePort(uint64_t sessionId) const;
86
87 void BuildNodes(const TopologySpec& spec);
88 void BuildClassical(const TopologySpec& spec); // p2p devices + IP + queues
89 void BuildQuantum(const TopologySpec& spec); // delay only, ideal channel
90 void InstallSessionApps(const TopologySpec& spec);
91};
92
93} // namespace q2ns
94
95#endif // Q2NS_TELEPORTATION_HELPER_H
Main user-facing facade for creating and configuring a quantum network.
TeleportationHelper & SetNetController(NetController *nc)
void BuildClassical(const TopologySpec &spec)
TeleportationHelper & UseBackend(std::string backend)
TeleportationHelper & SetDefaultQueue(std::string max)
void InstallSessionApps(const TopologySpec &spec)
TeleportationHelper & SetTeleportState(const std::shared_ptr< q2ns::QState > &tpl)
void BuildQuantum(const TopologySpec &spec)
void Install(const TopologySpec &spec)
TeleportationHelper & SetPortBase(uint16_t base)
uint16_t AllocatePort(uint64_t sessionId) const
std::unordered_map< std::string, ns3::Ptr< ns3::Node > > m_name2node
std::shared_ptr< q2ns::QState > m_teleportState
void BuildNodes(const TopologySpec &spec)
std::string protocol
std::string queueMax
std::vector< LinkSpec > quantumEdges
std::vector< NodeSpec > nodes
std::vector< SessionSpec > sessions
std::vector< LinkSpec > classicalEdges