15#include "ns3/application.h"
16#include "ns3/ipv4-address.h"
17#include "ns3/ipv6-address.h"
18#include "ns3/packet-sink.h"
20#include "ns3/traced-callback.h"
25#include <unordered_map>
40class SwapApp final :
public ns3::Application {
47 ns3::Time
start{ns3::Seconds(0.0)};
104 ns3::TracedCallback<uint64_t, ns3::Time, uint8_t, uint8_t>
146 void OnCtrlRx(ns3::Ptr<const ns3::Packet> pkt,
const ns3::Address& from);
147 void EnsureSink(uint16_t port,
const std::string& proto);
159 std::unordered_map<uint16_t, ns3::Ptr<ns3::Socket>>
m_udp4;
160 std::unordered_map<uint16_t, ns3::Ptr<ns3::Socket>>
m_udp6;
172 return std::hash<std::string>()(k.
dst) ^ (k.
port << 1) ^ (k.
v6 ? 0x9e37 : 0);
177 std::unordered_map<uintptr_t, ns3::Ptr<ns3::Packet>>
180 std::unordered_map<uintptr_t, ns3::Ptr<ns3::Packet>>
Main user-facing facade for creating and configuring a quantum network.
void StopApplication() override
ns3::Ptr< ns3::Socket > GetOrCreateUdpSender(uint16_t port, bool v6)
void SetPeerAddress6(ns3::Ipv6Address v6)
std::unordered_map< TcpKey, ns3::Ptr< ns3::Socket >, TcpKeyHash > m_udp6_conn
ns3::Ipv4Address m_peerV4
std::unordered_map< TcpKey, ns3::Ptr< ns3::Socket >, TcpKeyHash > m_tcp
std::unordered_map< uint16_t, ns3::Ptr< ns3::PacketSink > > m_sinksByPort
~SwapApp() override=default
static ns3::TypeId GetTypeId()
void StartApplication() override
void EnsureSink(uint16_t port, const std::string &proto)
void OnTcpConnected(ns3::Ptr< ns3::Socket > s)
ns3::Ptr< ns3::Socket > GetOrCreateTcpSender(const ns3::Address &dst, bool v6, uint16_t port)
void TryApply(SessionState &s)
std::unordered_map< uintptr_t, ns3::Ptr< ns3::Packet > > m_tcpPending
void SetPayloadBytes(uint32_t n)
std::unordered_map< uint16_t, ns3::Ptr< ns3::Socket > > m_udp4
std::unordered_map< uint64_t, SessionState > m_sessions
void DoEndpointStart(SessionState &s)
void AddSession(const SessionConfig &cfg)
std::unordered_map< uint16_t, ns3::Ptr< ns3::Socket > > m_udp6
void MaybeDoBsmAndAnnounce(SessionState &s)
ns3::Ipv6Address m_peerV6
std::unordered_map< uintptr_t, ns3::Ptr< ns3::Packet > > m_tcpPendingOnce
void OnTcpConnectFail(ns3::Ptr< ns3::Socket > s)
void ScheduleSession(const SessionState &s)
void DoRepeaterRound(SessionState &s)
void SetNetController(NetController *nc)
ns3::TracedCallback< uint64_t, ns3::Time, uint8_t, uint8_t > m_traceBSMDone
ns3::TracedCallback< uint64_t, ns3::Time, double > m_traceVerifyFidelity
void OnCtrlRx(ns3::Ptr< const ns3::Packet > pkt, const ns3::Address &from)
ns3::TracedCallback< uint64_t, ns3::Time, uint8_t, uint8_t > m_traceFrameResolved
ns3::TracedCallback< uint64_t, ns3::Time, uint8_t, uint8_t > m_traceCtrlSent
ns3::TracedCallback< uint64_t, ns3::Time > m_traceRoundStart
ns3::Ptr< ns3::Socket > GetOrCreateUdpV6Connected(const ns3::Ipv6Address &dst, uint16_t port)
void SetPeerAddress(ns3::Ipv4Address v4)
ns3::TracedCallback< uint64_t, ns3::Time > m_traceCorrectionApplied
ns3::Ipv6Address nextEndAddr6
ns3::Ipv4Address prevEndAddr
ns3::Ipv6Address prevEndAddr6
ns3::Ipv4Address nextEndAddr
std::shared_ptr< Qubit > qNext
std::shared_ptr< q2ns::Qubit > targetQubit
std::shared_ptr< Qubit > qPrev
size_t operator()(const TcpKey &k) const
bool operator==(const TcpKey &o) const