21 #include "ns3/address.h"
23 #include "ns3/nstime.h"
24 #include "ns3/socket.h"
25 #include "ns3/simulator.h"
26 #include "ns3/packet.h"
27 #include "ns3/uinteger.h"
28 #include "ns3/trace-source-accessor.h"
43 static TypeId tid =
TypeId (
"ns3::QKDPostprocessingApplication")
45 .SetGroupName(
"Applications")
47 .AddAttribute (
"KeySizeInBits",
"The amount of data to be added to QKD Buffer (in bits).",
50 MakeUintegerChecker<uint32_t> ())
51 .AddAttribute (
"KeyRate",
"The average QKD key rate in bps.",
55 .AddAttribute (
"DataRate",
"The average data rate of communication.",
59 .AddAttribute (
"PacketSize",
"The size of packets sent in post-processing state",
62 MakeUintegerChecker<uint32_t> ())
63 .AddAttribute (
"MaxSiftingPackets",
"The size of packets sent in sifting state",
66 MakeUintegerChecker<uint32_t> ())
68 .AddAttribute (
"Protocol",
"The type of protocol to use (TCP by default).",
72 .AddAttribute (
"ProtocolSifting",
"The type of protocol to use for sifting (UDP by default).",
77 .AddAttribute (
"Remote",
"The address of the destination",
81 .AddAttribute (
"Local",
"The local address on which to bind the listening socket.",
85 .AddAttribute (
"Remote_Sifting",
"The address of the destination for sifting traffic.",
89 .AddAttribute (
"Local_Sifting",
"The local address on which to bind the listening sifting socket.",
93 .AddAttribute (
"Local_KMS",
"The local KSM address.",
97 .AddTraceSource (
"Tx",
"A new packet is created and is sent",
99 "ns3::QKDPostprocessingApplication::Tx")
100 .AddTraceSource (
"Rx",
"A packet has been received",
102 "ns3::QKDPostprocessingApplication::Rx")
103 .AddTraceSource (
"TxKMS",
"A new packet is created and is sent to LKMS",
105 "ns3::QKDPostprocessingApplication::TxKMS")
106 .AddTraceSource (
"RxKMS",
"A packet has been received from LKMS",
108 "ns3::QKDPostprocessingApplication::RxLKMS")
116 m_random = CreateObject<UniformRandomVariable> ();
161 std::list<Ptr<Socket> >
249 uint32_t
interface = ipv4->GetInterfaceForAddress(
InetSocketAddress::ConvertFrom (m_local).GetIpv4 () );
250 Ptr<NetDevice> netDevice = ipv4->GetNetDevice(interface);
254 MakeCallback (&QKDPostprocessingApplication::ConnectionSucceeded, this),
255 MakeCallback (&QKDPostprocessingApplication::ConnectionFailed, this)
258 MakeCallback (&QKDPostprocessingApplication::DataSend, this)
265 "Connecting QKDApp (" <<
266 InetSocketAddress::ConvertFrom (m_peer).GetIpv4 () << " port " << InetSocketAddress::ConvertFrom (m_peer).GetPort () <<
268 InetSocketAddress::ConvertFrom (m_local).GetIpv4 () << " port " << InetSocketAddress::ConvertFrom (m_local).GetPort ()
275 if (!m_sinkSocket_sifting) m_sinkSocket_sifting = Socket::CreateSocket (GetNode (), m_tidSifting);
276 m_sinkSocket_sifting->Bind (m_local_sifting);
277 m_sinkSocket_sifting->Listen ();
278 m_sinkSocket_sifting->ShutdownSend ();
279 m_sinkSocket_sifting->SetRecvCallback (MakeCallback (&QKDPostprocessingApplication::HandleReadSifting, this));
282 if (!m_sendSocket_sifting) m_sendSocket_sifting = Socket::CreateSocket (GetNode (), m_tidSifting);
283 m_sendSocket_sifting->Connect (m_peer_sifting);
284 m_sendSocket_sifting->ShutdownRecv ();
290 if (!m_sinkSocketKMS) m_sinkSocketKMS = Socket::CreateSocket (GetNode (), m_tid);
291 uint32_t portKMS = InetSocketAddress::ConvertFrom (m_kms).GetPort ();
292 if (m_sinkSocketKMS->Bind (m_kms) == -1) NS_FATAL_ERROR ("Failed to bind socket");
293 m_sinkSocketKMS->Listen ();
294 m_sinkSocketKMS->ShutdownSend ();
295 m_sinkSocketKMS->SetRecvCallback (MakeCallback (&QKDPostprocessingApplication::HandleReadKMS, this));
296 m_sinkSocketKMS->SetAcceptCallback (
297 MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
298 MakeCallback (&QKDPostprocessingApplication::HandleAcceptKMS, this));
299 m_sinkSocketKMS->SetCloseCallbacks (
300 MakeCallback (&QKDPostprocessingApplication::HandlePeerCloseKMS, this),
301 MakeCallback (&QKDPostprocessingApplication::HandlePeerErrorKMS, this));
304 if (!m_sendSocketKMS) m_sendSocketKMS = Socket::CreateSocket (GetNode (), m_tid);
305 Ipv4Address localIpv4 = InetSocketAddress::ConvertFrom (m_local).GetIpv4 ();
306 InetSocketAddress senderKMS = InetSocketAddress (
312 "Connecting KMS (" <<
313 InetSocketAddress::ConvertFrom (m_kms).GetIpv4 () << " port " << portKMS <<
315 localIpv4 << " port" << portKMS
317 m_sendSocketKMS->Bind (senderKMS);
318 m_sendSocketKMS->ShutdownRecv ();
319 m_sendSocketKMS->SetConnectCallback (
320 MakeCallback (&QKDPostprocessingApplication::ConnectionSucceededKMS, this),
321 MakeCallback (&QKDPostprocessingApplication::ConnectionFailedKMS, this));
322 m_sendSocketKMS->SetDataSentCallback (
323 MakeCallback (&QKDPostprocessingApplication::DataSendKMS, this));
324 m_sendSocketKMS->TraceConnectWithoutContext ("RTT", MakeCallback (&QKDPostprocessingApplication::RegisterAckTime, this));
325 m_sendSocketKMS->Connect (m_kms);
330 void QKDPostprocessingApplication::StopApplication (void)
332 NS_LOG_FUNCTION (this);
334 if (m_sendSocket != 0)
336 m_sendSocket->Close ();
340 NS_LOG_WARN ("QKDPostprocessingApplication found null socket to close in StopApplication");
343 NS_LOG_FUNCTION (this);
344 while(!m_sinkSocketList.empty ())
346 Ptr<Socket> acceptedSocket = m_sinkSocketList.front ();
347 m_sinkSocketList.pop_front ();
348 acceptedSocket->Close ();
350 if (m_sinkSocket != 0)
352 m_sinkSocket->Close ();
353 m_sinkSocket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ());
357 Simulator::Cancel (m_sendEvent);
360 void QKDPostprocessingApplication::ScheduleNextReset(){
362 double ratio = m_keySizeInBits / static_cast<double>(m_keyRate.GetBitRate ());
364 Time nextTime (Seconds (ratio));
365 Simulator::Schedule (nextTime, &QKDPostprocessingApplication::ResetCounter, this);
367 NS_LOG_FUNCTION (this << m_keySizeInBits << "\t" << static_cast<double>(m_keyRate.GetBitRate ()) << "\t" << "ratio:" << ratio << "nextTime:" << nextTime);
370 void QKDPostprocessingApplication::ResetCounter (){
372 NS_LOG_FUNCTION (this << m_packetNumber);
374 if(m_master) m_packetNumber = 0;
375 if(m_connected) SendSiftingPacket();
380 void QKDPostprocessingApplication::SendData (void)
382 NS_LOG_FUNCTION (this);
384 if(m_master == true){
385 NS_LOG_FUNCTION(this << "********************** MASTER **********************");
387 NS_LOG_FUNCTION(this << "********************** SLAVE **********************");
390 NS_LOG_DEBUG (this << "\t Sending packet " << m_packetNumber );
391 if(m_packetNumber > 0){
392 nlohmann::json msgBody;
393 msgBody["ACTION"] = "QKDPPS";
394 msgBody["NUMBER"] = m_packetNumber;
395 std::string message = msgBody.dump();
396 PrepareOutput(message, "qkdpps");
399 NS_LOG_FUNCTION (this << "m_lastUUID:\t" << m_lastUUID);
403 UUID keyIdRaw = UUID::Sequential();
404 keyId = keyIdRaw.string();
408 if(keyId.size() > 0){
410 GenerateRandomKeyId();
412 nlohmann::json msgBody;
413 msgBody["ACTION"] = "ADDKEY";
414 msgBody["size"] = m_keySizeInBits;
415 msgBody["uuid"] = keyId;
416 msgBody["srid"] = m_keyId;
417 std::string message = msgBody.dump();
419 PrepareOutput(message, "addkey");
422 if(m_master && m_connected){
423 NS_LOG_FUNCTION( this << "ADDKEY" << keyId );
424 Ptr<QKDKey> newKey = Create<QKDKey> (keyId, m_keyId, m_keySizeInBits);
425 SendPacketToKMS(newKey);
433 void QKDPostprocessingApplication::PrepareOutput (std::string value, std::string action)
435 NS_LOG_FUNCTION (this << Simulator::Now () << action << value);
437 std::ostringstream msg;
441 msg << std::string( m_random->GetValue (m_pktSize, m_pktSize*1.1), '0');
444 Ptr<Packet> packet = Create<Packet> ((uint8_t*) msg.str().c_str(), msg.str().length());
445 NS_LOG_DEBUG(this << "\t !!!SENDING PACKET WITH CONTENT:" << value << " of size " << packet->GetSize() );
447 uint32_t bits = packet->GetSize() * 8;
448 NS_LOG_LOGIC (this << "bits = " << bits);
450 if(action == "qkdpps"){
451 Time nextTime (Seconds (bits / static_cast<double>(m_dataRate.GetBitRate ())));
452 NS_LOG_FUNCTION(this << "CALCULATED NEXTTIME:" << bits / m_dataRate.GetBitRate ());
453 NS_LOG_LOGIC ("nextTime = " << nextTime);
454 m_sendEvent = Simulator::Schedule (nextTime, &QKDPostprocessingApplication::SendPacket, this, packet);
455 }else if(action == "addkey"){
462 void QKDPostprocessingApplication::SendPacket (Ptr<Packet> packet){
464 NS_LOG_FUNCTION (this << "\t" << packet << "PACKETID: " << packet->GetUid() << packet->GetSize() );
467 m_sendSocket->Send (packet);
471 void QKDPostprocessingApplication::SendPacketToKMS (Ptr<QKDKey> key){
473 NS_LOG_FUNCTION (this);
476 nlohmann::json msgBody;
477 Ipv4Address source = InetSocketAddress::ConvertFrom(m_local).GetIpv4 ();
478 std::ostringstream srcAddressTemp;
479 source.Print(srcAddressTemp);
480 std::string sourceString = srcAddressTemp.str ();
482 Ipv4Address destination = InetSocketAddress::ConvertFrom(m_peer).GetIpv4 ();
483 std::ostringstream dstAddressTemp;
484 destination.Print(dstAddressTemp);
485 std::string destinationString = dstAddressTemp.str ();
487 msgBody["source"] = sourceString;
488 msgBody["destination"] = destinationString;
490 msgBody["key_id"] = key->GetId();
491 msgBody["key"] = key->GetKeyString();
492 msgBody["src_id"] = GetSrc()->GetId();
493 msgBody["dst_id"] = GetDst()->GetId();
495 std::string message = msgBody.dump();
497 Ipv4Address lkmsAddress = InetSocketAddress::ConvertFrom(m_kms).GetIpv4 ();
498 std::ostringstream lkmsAddressTemp;
499 lkmsAddress.Print(lkmsAddressTemp);
500 std::string headerUri = "http://" + lkmsAddressTemp.str ();
501 headerUri += "/api/v1/keys/" + destinationString + "/store_pp_key";
503 HTTPMessage httpMessage;
504 httpMessage.CreateRequest(headerUri, "POST", message);
505 std::string hMessage = httpMessage.ToString();
506 Ptr<Packet> packet = Create<Packet> (
507 (uint8_t*) (hMessage).c_str(),
510 NS_ASSERT (packet != 0);
512 NS_LOG_FUNCTION (this << "Sending PACKETID: " << packet->GetUid()
513 << " of size: " << packet->GetSize()
514 << " key_id: " << key->GetId()
515 << " via socket " << m_sendSocketKMS
518 m_txTraceKMS (packet);
519 m_sendSocketKMS->Send (packet);
522 void QKDPostprocessingApplication::SendSiftingPacket(){
524 NS_LOG_FUNCTION (this);
526 uint32_t tempValue = 800 + m_random->GetValue (100, 300);
527 NS_LOG_FUNCTION (this << "Sending SIFTING packet of size" << tempValue);
528 Ptr<Packet> packet = Create<Packet> (tempValue);
529 m_sendSocket_sifting->Send (packet);
530 NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
532 m_packetNumber_sifting++;
534 if(m_packetNumber_sifting < m_maxPackets_sifting){
535 Simulator::Schedule (MicroSeconds(400), &QKDPostprocessingApplication::SendSiftingPacket, this);
537 m_packetNumber_sifting = 0;
541 void QKDPostprocessingApplication::HandleReadKMS (Ptr<Socket> socket)
543 if(m_master == true) {
544 NS_LOG_FUNCTION(this << "--------------MASTER--------------");
546 NS_LOG_FUNCTION(this << "--------------SLAVE--------------");
551 while ((packet = socket->RecvFrom (from)))
553 if (packet->GetSize () == 0)
558 NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
560 m_totalRx += packet->GetSize ();
561 if (InetSocketAddress::IsMatchingType (from))
564 NS_LOG_FUNCTION (this << "At time " << Simulator::Now ().GetSeconds ()
565 << "s packet sink received "
566 << packet->GetSize () << " bytes from "
567 << InetSocketAddress::ConvertFrom(from).GetIpv4 ()
568 << " port " << InetSocketAddress::ConvertFrom (from).GetPort ()
569 << " total Rx " << m_totalRx << " bytes");
571 m_rxTraceKMS (packet, from);
574 void QKDPostprocessingApplication::HandleRead (Ptr<Socket> socket)
576 if(m_master == true) {
577 NS_LOG_FUNCTION(this << "--------------MASTER--------------");
579 NS_LOG_FUNCTION(this << "--------------SLAVE--------------");
584 while ((packet = socket->RecvFrom (from)))
586 if (packet->GetSize () == 0)
591 NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
593 m_totalRx += packet->GetSize ();
594 if (InetSocketAddress::IsMatchingType (from))
597 NS_LOG_FUNCTION (this << "At time " << Simulator::Now ().GetSeconds ()
598 << "s packet sink received "
599 << packet->GetSize () << " bytes from "
600 << InetSocketAddress::ConvertFrom(from).GetIpv4 ()
601 << " port " << InetSocketAddress::ConvertFrom (from).GetPort ()
602 << " total Rx " << m_totalRx << " bytes");
606 m_rxTrace (packet, from);
607 ProcessIncomingPacket(packet);
613 void QKDPostprocessingApplication::ProcessIncomingPacket(Ptr<Packet> packet)
618 uint8_t *buffer = new uint8_t[packet->GetSize ()];
619 packet->CopyData(buffer, packet->GetSize ());
620 std::string s = std::string((char*)buffer);
623 std::string packetValue;
626 NS_LOG_FUNCTION(this << "payload:" << s);
628 std::size_t pos = s.find(";");
629 std::string payloadRaw = s.substr(0,pos);
631 NS_LOG_FUNCTION(this << "payloadRaw:" << payloadRaw << payloadRaw.size());
636 nlohmann::json jresponse;
637 jresponse = nlohmann::json::parse(payloadRaw);
639 if (jresponse.contains("ACTION")) label = jresponse["ACTION"];
640 NS_LOG_DEBUG (this << "\tLABEL:\t" << jresponse["ACTION"] << "\tPACKETVALUE:\t" << s);
642 if(label == "ADDKEY"){
647 uint32_t keySize = m_keySizeInBits;
649 if (jresponse.contains("size")) keySize = uint32_t(jresponse["size"]);
650 if (jresponse.contains("uuid")) keyId = jresponse["uuid"];
651 if (jresponse.contains("srid")) m_keyId = jresponse["srid"];
654 NS_LOG_FUNCTION( this << "ADDKEY" << keyId );
655 Ptr<QKDKey> newKey = Create<QKDKey> (keyId, m_keyId, keySize);
656 SendPacketToKMS(newKey);
663 NS_LOG_FUNCTION( this << "!!!!!!!!!!!!!!!!!!!!! JSON parse error! !!!!!!!!!!!!!!!!!!!!! \t"<< payloadRaw << payloadRaw.size());
670 void QKDPostprocessingApplication::HandleReadSifting (Ptr<Socket> socket)
672 NS_LOG_FUNCTION (this << socket);
676 NS_LOG_FUNCTION(this << "***MASTER***" );
680 NS_LOG_FUNCTION(this << "!!!SLAVE!!!");
684 packet = socket->Recv (65535, 0);
687 void QKDPostprocessingApplication::HandlePeerClose (Ptr<Socket> socket)
689 NS_LOG_FUNCTION (this << socket);
691 void QKDPostprocessingApplication::HandlePeerCloseKMS (Ptr<Socket> socket)
693 NS_LOG_FUNCTION (this << socket);
696 void QKDPostprocessingApplication::HandlePeerError (Ptr<Socket> socket)
698 NS_LOG_FUNCTION (this << socket);
700 void QKDPostprocessingApplication::HandlePeerErrorKMS (Ptr<Socket> socket)
702 NS_LOG_FUNCTION (this << socket);
705 void QKDPostprocessingApplication::HandleAccept (Ptr<Socket> s, const Address& from)
707 NS_LOG_FUNCTION (this << s << from);
708 s->SetRecvCallback (MakeCallback (&QKDPostprocessingApplication::HandleRead, this));
709 m_sinkSocketList.push_back (s);
711 void QKDPostprocessingApplication::HandleAcceptKMS (Ptr<Socket> s, const Address& from)
713 NS_LOG_FUNCTION (this << s << from);
714 s->SetRecvCallback (MakeCallback (&QKDPostprocessingApplication::HandleReadKMS, this));
716 void QKDPostprocessingApplication::HandleAcceptSifting (Ptr<Socket> s, const Address& from)
718 NS_LOG_FUNCTION (this << s << from);
719 s->SetRecvCallback (MakeCallback (&QKDPostprocessingApplication::HandleReadSifting, this));
720 m_sinkSocketList.push_back (s);
723 void QKDPostprocessingApplication::ConnectionSucceeded (Ptr<Socket> socket)
725 NS_LOG_FUNCTION (this << socket);
726 NS_LOG_FUNCTION (this << "QKDPostprocessingApplication Connection succeeded");
728 if (m_sendSocket == socket || m_sinkSocket == socket){
739 void QKDPostprocessingApplication::ConnectionSucceededSifting (Ptr<Socket> socket)
741 NS_LOG_FUNCTION (this << socket);
742 NS_LOG_FUNCTION (this << "QKDPostprocessingApplication SIFTING Connection succeeded");
745 void QKDPostprocessingApplication::ConnectionFailed (Ptr<Socket> socket)
747 NS_LOG_FUNCTION (this << socket);
748 NS_LOG_FUNCTION (this << "QKDPostprocessingApplication, Connection Failed");
751 void QKDPostprocessingApplication::DataSend (Ptr<Socket> socket, uint32_t value)
753 NS_LOG_FUNCTION (this);
759 void QKDPostprocessingApplication::ConnectionSucceededKMS (Ptr<Socket> socket)
761 NS_LOG_FUNCTION (this << socket);
762 NS_LOG_FUNCTION (this << "QKDPostprocessingApplication-KMS Connection succeeded");
765 void QKDPostprocessingApplication::ConnectionFailedKMS (Ptr<Socket> socket)
767 NS_LOG_FUNCTION (this << socket);
768 NS_LOG_FUNCTION (this << "QKDPostprocessingApplication-KMS Connection Failed");
771 void QKDPostprocessingApplication::DataSendKMS (Ptr<Socket> socket, uint32_t value)
773 NS_LOG_FUNCTION (this);
780 void QKDPostprocessingApplication::RegisterAckTime (Time oldRtt, Time newRtt)
782 NS_LOG_FUNCTION (this << oldRtt << newRtt);
783 m_lastAck = Simulator::Now ();
786 Time QKDPostprocessingApplication::GetLastAckTime ()
788 NS_LOG_FUNCTION (this);
793 QKDPostprocessingApplication::GenerateRandomString(const int len) {
795 static const char alphanum[] =
797 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
798 "abcdefghijklmnopqrstuvwxyz";
800 uint32_t randVal = 0;
801 for (int i = 0; i < len; ++i){
802 randVal = round(m_random->GetValue (0, sizeof(alphanum) - 1));
803 tmp_s += alphanum[ randVal ];
a polymophic address class
AttributeValue implementation for Address.
The base class for all ns3 applications.
virtual void DoDispose(void)
Destructor implementation.
Ptr< Node > GetNode() const
Class for representing data rates.
AttributeValue implementation for DataRate.
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
static Ipv4Address GetAny(void)
Implement the IPv4 layer.
uint32_t GetId(void) const
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void HandleRead(Ptr< Socket > socket)
Handle a packet received from the peer application.
void HandleAccept(Ptr< Socket > socket, const Address &from)
Handle an incoming connection from the application.
std::list< Ptr< Socket > > m_sinkSocketList
the accepted sockets
bool m_connected
Connection Status.
void StartApplication(void)
Start the post-processing application.
Ptr< Socket > GetSinkSocket(void) const
Get the sink socket.
TracedCallback< Ptr< const Packet >, const Address & > m_rxTraceKMS
Ptr< Node > GetSrc()
Get the source node.
uint64_t m_keyId
ID counter of generated keys.
Ptr< Node > GetDst()
Get the destination node.
std::list< Ptr< Socket > > GetAcceptedSockets(void) const
Get the list of the accepted sockets.
QKDPostprocessingApplication()
Constructor.
Address m_peer_sifting
Peer address for sifting.
std::string GenerateRandomString(const int len)
Generate a random string with a given length.
uint32_t m_maxPackets_sifting
Limitation for the number of sifting packets.
void SetSiftingSocket(std::string type, Ptr< Socket > socket)
Set the sifting socket.
void HandlePeerError(Ptr< Socket > socket)
Handle a connection error from the peer application.
Ptr< Socket > m_sendSocket_sifting
Sockets used for SIFTING.
uint32_t m_pktSize
Size of packets.
DataRate m_dataRate
Rate that data is generatedm_pktSize.
Ptr< Socket > m_sinkSocket_sifting
Associated socket for sifting.
void SetSocket(std::string type, Ptr< Socket > socket, bool isMaster)
Set the socket.
TracedCallback< Ptr< const Packet > > m_txTrace
static TypeId GetTypeId(void)
Get the type ID.
void GenerateRandomKeyId()
Generate a random seed that will be used to generate key values.
virtual ~QKDPostprocessingApplication()
Donstructor.
Address m_local_sifting
Local address for sifting to bind to.
bool m_master
Alice (1) or Bob (0)
Address m_local
Local address to bind to.
std::string m_appId
Random string marking the app ID.
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced Callback: received packets, source address.
EventId m_sendEvent
Event id of pending "send packet" event.
uint32_t m_totalRx
Total bytes received
Ptr< UniformRandomVariable > m_random
The uniform random variable.
Ptr< Socket > m_sendSocket
IMITATE post-processing traffic (CASCADE, PRIVACY AMPLIFICATION and etc.
Ptr< Node > m_src
The source node.
Ptr< Socket > m_sinkSocket
Associated socket.
uint32_t GetTotalRx() const
Get the total amount of data received (in bytes).
void SetSrc(Ptr< Node >)
Set the source node.
DataRate m_keyRate
QKD Key rate.
TracedCallback< Ptr< const Packet > > m_txTraceKMS
uint32_t m_keySizeInBits
KeyRate of the QKDlink.
virtual void DoDispose(void)
Destructor implementation.
Ptr< Node > m_dst
The destination node.
uint32_t m_packetNumber_sifting
How many sifting packets have been sent.
Address m_peer
Peer address.
Ptr< Socket > GetSendSocket(void) const
Get the send socket.
void HandlePeerClose(Ptr< Socket > socket)
Handle a connection close from the peer application.
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
void SetAcceptCallback(Callback< bool, Ptr< Socket >, const Address & > connectionRequest, Callback< void, Ptr< Socket >, const Address & > newConnectionCreated)
Accept connection requests from remote hosts.
virtual int Listen(void)=0
Listen for incoming connections.
virtual int ShutdownSend(void)=0
void SetCloseCallbacks(Callback< void, Ptr< Socket > > normalClose, Callback< void, Ptr< Socket > > errorClose)
Detect socket recv() events such as graceful shutdown or error.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
static TypeId GetTypeId(void)
Get the type ID.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
AttributeValue implementation for TypeId.
static TypeId GetTypeId(void)
Get the type ID.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakeAddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeAddressChecker(void)
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeDataRateChecker(void)
Ptr< const AttributeAccessor > MakeTypeIdAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeTypeIdChecker(void)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Callback< R, Ts... > MakeNullCallback(void)
void Connect(std::string path, const CallbackBase &cb)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...