A Discrete-Event Network Simulator
API
qkd-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2015 LIPTEL.ieee.org
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  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Miralem Mehic <miralem.mehic@ieee.org>
19  */
20 
21 #include "ns3/abort.h"
22 #include "ns3/log.h"
23 #include "ns3/simulator.h"
24 #include "ns3/queue.h"
25 #include "ns3/config.h"
26 #include "ns3/packet.h"
27 #include "ns3/object.h"
28 #include "ns3/names.h"
29 #include "ns3/mpi-interface.h"
30 #include "ns3/mpi-receiver.h"
31 #include "ns3/qkd-net-device.h"
32 #include "ns3/qkd-manager.h"
33 #include "ns3/internet-module.h"
34 #include "ns3/random-variable-stream.h"
35 #include "ns3/trace-helper.h"
36 #include "ns3/qkd-l4-traffic-control-layer.h"
37 #include "ns3/traffic-control-module.h"
38 #include "ns3/virtual-ipv4-l3-protocol.h"
39 #include "ns3/udp-l4-protocol.h"
40 #include "ns3/tcp-l4-protocol.h"
41 #include "ns3/virtual-tcp-l4-protocol.h"
42 #include "ns3/qkd-graph-manager.h"
43 #include "qkd-helper.h"
44 
45 namespace ns3 {
46 
47 NS_LOG_COMPONENT_DEFINE ("QKDHelper");
48 
50 {
51  m_deviceFactory.SetTypeId ("ns3::QKDNetDevice");
52  m_tcpFactory.SetTypeId ("ns3::VirtualTcpL4Protocol");
53 
54  m_useRealStorages = false;
55  m_portOverlayNumber = 667;
56  m_channelID = 0;
57  m_routing = 0;
58  m_counter = 0;
59  m_QCrypto = CreateObject<QKDCrypto> ();
60  m_supportQKDL4 = 1;
61 }
62 
63 void
64 QKDHelper::SetDeviceAttribute (std::string n1, const AttributeValue &v1)
65 {
66  m_deviceFactory.Set (n1, v1);
67 }
68 
72 void
73 QKDHelper::EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promiscuous, bool explicitFilename)
74 {
75 
76  //
77  // All of the Pcap enable functions vector through here including the ones
78  // that are wandering through all of devices on perhaps all of the nodes in
79  // the system. We can only deal with devices of type QKDNetDevice.
80  //
81  Ptr<QKDNetDevice> device = nd->GetObject<QKDNetDevice> ();
82  if (device == 0 || device->GetNode()->GetObject<QKDManager> () == 0)
83  {
84  NS_LOG_INFO ("QKDHelper::EnablePcapInternal(): Device " << device << " is not related with QKD TCP/IP stack");
85  return;
86  }
87 
88  PcapHelper pcapHelper;
89 
90  std::string filename;
91  if (explicitFilename)
92  {
93  filename = prefix;
94  }
95  else
96  {
97  filename = pcapHelper.GetFilenameFromDevice (prefix, device);
98  }
99 
100  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out,
102  pcapHelper.HookDefaultSink<QKDNetDevice> (device, "PromiscSniffer", file);
103 }
104 
108 void
110  Ptr<OutputStreamWrapper> stream,
111  std::string prefix,
112  Ptr<NetDevice> nd,
113  bool explicitFilename)
114 {
115 
116  //
117  // All of the ascii enable functions vector through here including the ones
118  // that are wandering through all of devices on perhaps all of the nodes in
119  // the system. We can only deal with devices of type QKDNetDevice.
120  //
121  Ptr<QKDNetDevice> device = nd->GetObject<QKDNetDevice> ();
122  if (device == 0)
123  {
124  NS_LOG_INFO ("QKDHelper::EnableAsciiInternal(): Device " << device <<
125  " not of type ns3::QKDNetDevice");
126  return;
127  }
128 
129  //
130  // Our default trace sinks are going to use packet printing, so we have to
131  // make sure that is turned on.
132  //
134 
135  //
136  // If we are not provided an OutputStreamWrapper, we are expected to create
137  // one using the usual trace filename conventions and do a Hook*WithoutContext
138  // since there will be one file per context and therefore the context would
139  // be redundant.
140  //
141  if (stream == 0)
142  {
143  //
144  // Set up an output stream object to deal with private ofstream copy
145  // constructor and lifetime issues. Let the helper decide the actual
146  // name of the file given the prefix.
147  //
148  AsciiTraceHelper asciiTraceHelper;
149 
150  std::string filename;
151  if (explicitFilename)
152  {
153  filename = prefix;
154  }
155  else
156  {
157  filename = asciiTraceHelper.GetFilenameFromDevice (prefix, device);
158  }
159 
160  Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
161 
162  //
163  // The MacRx trace source provides our "r" event.
164  //
165  asciiTraceHelper.HookDefaultReceiveSinkWithoutContext<QKDNetDevice> (device, "MacRx", theStream);
166 
167  //
168  // The "+", '-', and 'd' events are driven by trace sources actually in the
169  // transmit queue.
170  //
171  Ptr<Queue<Packet> > queue = device->GetQueue ();
172  asciiTraceHelper.HookDefaultEnqueueSinkWithoutContext<Queue<Packet> > (queue, "Enqueue", theStream);
173  asciiTraceHelper.HookDefaultDropSinkWithoutContext<Queue<Packet> > (queue, "Drop", theStream);
174  asciiTraceHelper.HookDefaultDequeueSinkWithoutContext<Queue<Packet> > (queue, "Dequeue", theStream);
175 
176  // PhyRxDrop trace source for "d" event
177  asciiTraceHelper.HookDefaultDropSinkWithoutContext<QKDNetDevice> (device, "PhyRxDrop", theStream);
178 
179  return;
180  }
181 
182  //
183  // If we are provided an OutputStreamWrapper, we are expected to use it, and
184  // to providd a context. We are free to come up with our own context if we
185  // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
186  // compatibility and simplicity, we just use Config::Connect and let it deal
187  // with the context.
188  //
189  // Note that we are going to use the default trace sinks provided by the
190  // ascii trace helper. There is actually no AsciiTraceHelper in sight here,
191  // but the default trace sinks are actually publicly available static
192  // functions that are always there waiting for just such a case.
193  //
194  uint32_t nodeid = nd->GetNode ()->GetId ();
195  uint32_t deviceid = nd->GetIfIndex ();
196  std::ostringstream oss;
197 
198  oss << "/NodeList/" << nd->GetNode ()->GetId () << "/DeviceList/" << deviceid << "/$ns3::QKDNetDevice/MacRx";
200 
201  oss.str ("");
202  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::QKDNetDevice/TxQueue/Enqueue";
204 
205  oss.str ("");
206  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::QKDNetDevice/TxQueue/Dequeue";
208 
209  oss.str ("");
210  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::QKDNetDevice/TxQueue/Drop";
212 
213  oss.str ("");
214  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::QKDNetDevice/PhyRxDrop";
216 }
217 
223 void
225 {
226  AddGraph(node, device, "", "png");
227 }
228 
235 void
236 QKDHelper::AddGraph(Ptr<Node> node, Ptr<NetDevice> device, std::string graphName)
237 {
238  AddGraph(node, device, graphName, "png");
239 }
247 void
248 QKDHelper::AddGraph(Ptr<Node> node, Ptr<NetDevice> device, std::string graphName, std::string graphType)
249 {
250 
251  NS_ASSERT (node != 0);
252  NS_ASSERT (device != 0);
253 
254  uint32_t bufferPosition = node->GetObject<QKDManager> ()->GetBufferPosition ( device->GetAddress() );
255  NS_LOG_FUNCTION(this << node->GetId() << bufferPosition << device );
256 
257  Ptr<QKDBuffer> buffer = node->GetObject<QKDManager> ()->GetBufferByBufferPosition (bufferPosition);
258  NS_ASSERT (buffer != 0);
259 
260  NS_LOG_FUNCTION(this << buffer << buffer->FetchState() << node->GetObject<QKDManager> ()->GetNBuffers() );
261 
263  QKDGraphManager->AddBuffer(node->GetId(), bufferPosition, graphName, graphType);
264 }
265 
269 void
271 {
273  QKDGraphManager->PrintGraphs();
274 }
275 
280 void
282 {
283  ObjectFactory factory;
284  factory.SetTypeId ("ns3::QKDManager");
285 
286  for(uint16_t i=0; i< n.GetN(); i++)
287  {
288  if(n.Get(i)->GetObject<QKDManager> () == 0){
289  Ptr<Object> manager = factory.Create <Object> ();
290  n.Get(i)->AggregateObject (manager);
291  n.Get(i)->GetObject<QKDManager> ()->UseRealStorages(m_useRealStorages);
292  }
293  }
294 }
295 
300 void
302 {
303  delete m_routing;
304  m_routing = routing.Copy ();
305 }
306 
312 void
314 {
315  ObjectFactory factory;
316  factory.SetTypeId (typeId);
317  Ptr<Object> protocol = factory.Create <Object> ();
318  node->AggregateObject (protocol);
319 }
320 
329  Ptr<NetDevice> a,
331 )
332 {
333  //################################
334  // SINGLE TCP/IP NETWORK
335  //################################
336 
337  Ptr<UniformRandomVariable> random = CreateObject<UniformRandomVariable> ();
338  return InstallQKD (
339  a,
340  b,
341  1000000, //1 Megabit
342  0,
343  100000000, //1000 Megabit
344  random->GetValue ( 1000000, 100000000)
345  );
346 }
347 
348 
357  Ptr<NetDevice> a,
359 )
360 {
361  //################################
362  // OVERLAY NETWORK
363  //################################
364 
365  std::string address;
366 
367  address = "11.0.0." + (++m_counter);
368  Ipv4InterfaceAddress da (Ipv4Address (address.c_str()), Ipv4Mask ("255.255.255.0"));
369 
370  address = "11.0.0." + (++m_counter);
371  Ipv4InterfaceAddress db (Ipv4Address (address.c_str()), Ipv4Mask ("255.255.255.0"));
372 
373  Ptr<UniformRandomVariable> random = CreateObject<UniformRandomVariable> ();
374 
375  return InstallOverlayQKD (
376  a,
377  b,
378  da,
379  db,
380  1000000, //1 Megabit
381  0,
382  1000000000, //1000 Megabit
383  random->GetValue ( 1000000, 1000000000)
384  );
385 }
386 
387 
388 
402  Ptr<NetDevice> IPa, //IP Net device of underlay network on node A
403  Ptr<NetDevice> IPb, //IP Net device of underlay network on node B
404  Ipv4InterfaceAddress IPQKDaddressA, //IP address of overlay network on node A
405  Ipv4InterfaceAddress IPQKDaddressB, //IP address of overlay network on node B
406  uint32_t Mmin, //Buffer details
407  uint32_t Mthr, //Buffer details
408  uint32_t Mmax, //Buffer details
409  uint32_t Mcurrent //Buffer details
410 ){
411  return InstallOverlayQKD(
412  IPa, //IP Net device of underlay network on node A
413  IPb, //IP Net device of underlay network on node B
414  IPQKDaddressA, //IP address of overlay network on node A
415  IPQKDaddressB, //IP address of overlay network on node B
416  Mmin, //Buffer details
417  Mthr, //Buffer details
418  Mmax, //Buffer details
419  Mcurrent, //Buffer details
420  "ns3::UdpSocketFactory"
421  );
422 }
423 
438  Ptr<NetDevice> IPa, //IP Net device of underlay network on node A
439  Ptr<NetDevice> IPb, //IP Net device of underlay network on node B
440  Ipv4InterfaceAddress IPQKDaddressA, //IP address of overlay network on node A
441  Ipv4InterfaceAddress IPQKDaddressB, //IP address of overlay network on node B
442  uint32_t Mmin, //Buffer details
443  uint32_t Mthr, //Buffer details
444  uint32_t Mmax, //Buffer details
445  uint32_t Mcurrent, //Buffer details
446  const std::string typeId //Protocol which is used in the underlying network for connection
447 )
448 {
449 
450  //################################
451  // OVERLAY NETWORK
452  //################################
453 
455  // Virtual IPv4L3 Protocol
457 
458  Ptr<Node> a = IPa->GetNode();
459  Ptr<Node> b = IPb->GetNode();
460 
461  NS_LOG_FUNCTION(this << a->GetId() << b->GetId());
462 
463  // Set virtual IPv4L3 on A
464  if (a->GetObject<VirtualIpv4L3Protocol> () == 0){
465  CreateAndAggregateObjectFromTypeId (a, "ns3::VirtualIpv4L3Protocol");
466 
467  //Install Routing Protocol
469  Ptr<Ipv4RoutingProtocol> ipv4Routinga_temp = m_routing->Create (a);
470  Virtualipv4a_temp->SetRoutingProtocol (ipv4Routinga_temp);
471  }
472 
474  CreateAndAggregateObjectFromTypeId (a, "ns3::QKDL4TrafficControlLayer");
475 
476  if( a->GetObject<TrafficControlLayer> () == 0)
477  CreateAndAggregateObjectFromTypeId (a, "ns3::TrafficControlLayer");
478 
479  //Install UDPL4 and TCPL4
480  if( a->GetObject<VirtualUdpL4Protocol> () == 0){
481  CreateAndAggregateObjectFromTypeId (a, "ns3::VirtualUdpL4Protocol");
483  }
485 
486 
488  // NODE A
490 
491  //install new QKDNetDevice on node A
493  devA->SetAddress (Mac48Address::Allocate ());
494  devA->SetSendCallback (MakeCallback (&QKDManager::VirtualSendOverlay, a->GetObject<QKDManager> () ));
495  a->AddDevice (devA);
496 
497  //Setup QKD NetDevice and interface
499  uint32_t i = Virtualipv4a->AddInterface (devA);
500  Virtualipv4a->AddAddress (i, IPQKDaddressA);
501  Virtualipv4a->SetUp (i);
502 
503  //Get address of classical device which is used for connection on the lower layer
504  Ptr<Ipv4> ipv4a = a->GetObject<Ipv4L3Protocol> ();
505  uint32_t interfaceOfClassicalDeviceOnNodeA = ipv4a->GetInterfaceForDevice(IPa);
506  Ipv4InterfaceAddress netA = ipv4a->GetAddress (interfaceOfClassicalDeviceOnNodeA, 0);
507 
508 
509 
511  // NODE B
513 
514  // Set virtual IPv4L3 on B
515  if (b->GetObject<VirtualIpv4L3Protocol> () == 0){
516  CreateAndAggregateObjectFromTypeId (b, "ns3::VirtualIpv4L3Protocol");
517  //Install Routing Protocol
519  Ptr<Ipv4RoutingProtocol> ipv4Routingb_temp = m_routing->Create (b);
520  Virtualipv4b_temp->SetRoutingProtocol (ipv4Routingb_temp);
521  }
522 
524  CreateAndAggregateObjectFromTypeId (b, "ns3::QKDL4TrafficControlLayer");
525 
526  if( b->GetObject<TrafficControlLayer> () == 0)
527  CreateAndAggregateObjectFromTypeId (b, "ns3::TrafficControlLayer");
528 
529  //Install UDPL4 and TCPL4
530  if( b->GetObject<VirtualUdpL4Protocol> () == 0){
531  CreateAndAggregateObjectFromTypeId (b, "ns3::VirtualUdpL4Protocol");
533  }
535 
536  //install new QKDNetDevice on node B
538  devB->SetAddress (Mac48Address::Allocate ());
539  devB->SetSendCallback (MakeCallback (&QKDManager::VirtualSendOverlay, b->GetObject<QKDManager> () ));
540  b->AddDevice (devB);
541 
542  //Setup QKD NetDevice and interface
544  uint32_t j = Virtualipv4b->AddInterface (devB);
545  Virtualipv4b->AddAddress (j, IPQKDaddressB);
546  Virtualipv4b->SetUp (j);
547 
548  //Get address of classical device which is used for connection of QKDNetDevice on lower layer
549  Ptr<Ipv4> ipv4b = b->GetObject<Ipv4L3Protocol> ();
550  uint32_t interfaceOfClassicalDeviceOnNodeB = ipv4b->GetInterfaceForDevice(IPb);
551  Ipv4InterfaceAddress netB = ipv4b->GetAddress (interfaceOfClassicalDeviceOnNodeB, 0);
552 
553  Ptr<Socket> m_socketA;
554  Ptr<Socket> m_socketB;
555  Ptr<Socket> m_socketA_sink;
556  Ptr<Socket> m_socketB_sink;
557 
558  /*
559  In NS3, TCP is not bidirectional. Therefore, we need to create separate sockets for listening and sending
560  */
561  if(typeId == "ns3::TcpSocketFactory"){
562 
563  Address inetAddrA (InetSocketAddress (ipv4a->GetAddress (interfaceOfClassicalDeviceOnNodeA, 0).GetLocal (), m_portOverlayNumber) );
564  Address inetAddrB (InetSocketAddress (ipv4b->GetAddress (interfaceOfClassicalDeviceOnNodeB, 0).GetLocal (), m_portOverlayNumber) );
565 
566  // SINK SOCKETS
567 
568  //create TCP Sink socket on A
569  m_socketA_sink = Socket::CreateSocket (a, TypeId::LookupByName ("ns3::TcpSocketFactory"));
570  m_socketA_sink->Bind ( inetAddrA );
571  m_socketA_sink->BindToNetDevice ( IPa );
572  m_socketA_sink->Listen ();
573  m_socketA_sink->ShutdownSend ();
575  m_socketA_sink->SetAcceptCallback (
576  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
578  );
579 
580 
581  //create TCP Sink socket on B
582  m_socketB_sink = Socket::CreateSocket (b, TypeId::LookupByName ("ns3::TcpSocketFactory"));
583  m_socketB_sink->Bind ( inetAddrB );
584  m_socketB_sink->BindToNetDevice ( IPb );
585  m_socketB_sink->Listen ();
586  m_socketB_sink->ShutdownSend ();
588  m_socketB_sink->SetAcceptCallback (
589  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
591  );
592 
593  // SEND SOCKETS
594 
595  //create TCP Send socket
596  m_socketA = Socket::CreateSocket (a, TypeId::LookupByName ("ns3::TcpSocketFactory"));
597  m_socketA->Bind ();
598  m_socketA->SetConnectCallback (
601  m_socketA->Connect ( inetAddrB );
602  m_socketA->ShutdownRecv ();
603 
604  //create TCP Send socket
605  m_socketB = Socket::CreateSocket (b, TypeId::LookupByName ("ns3::TcpSocketFactory"));
606  m_socketB->Bind ();
607  m_socketB->SetConnectCallback (
610  m_socketB->Connect ( inetAddrA );
611  m_socketB->ShutdownRecv ();
612 
613  } else {
614 
615  //create UDP socket
616  InetSocketAddress inetAddrA (ipv4a->GetAddress (interfaceOfClassicalDeviceOnNodeA, 0).GetLocal (), m_portOverlayNumber);
617  m_socketA = Socket::CreateSocket (a, TypeId::LookupByName ("ns3::UdpSocketFactory"));
618  m_socketA->Bind ( inetAddrA );
619  m_socketA->BindToNetDevice ( IPa );
620  m_socketA->SetRecvCallback (MakeCallback (&QKDManager::VirtualReceive, a->GetObject<QKDManager> () ));
621 
622  //create UDP socket
623  InetSocketAddress inetAddrB (ipv4b->GetAddress (interfaceOfClassicalDeviceOnNodeB, 0).GetLocal (), m_portOverlayNumber);
624  m_socketB = Socket::CreateSocket (b, TypeId::LookupByName ("ns3::UdpSocketFactory"));
625  m_socketB->Bind ( inetAddrB );
626  m_socketB->BindToNetDevice ( IPb );
627  m_socketB->SetRecvCallback (MakeCallback (&QKDManager::VirtualReceive, b->GetObject<QKDManager> () ));
628 
629  m_socketA_sink = m_socketA;
630  m_socketB_sink = m_socketB;
631  }
632 
634  // QKD Traffic Control - queues on QKD Netdevices (L2)
635  // Optional usage, that is the reason why the length of the queue is only 1
637 
638  //TCH for net devices on overlay L2
639  NetDeviceContainer qkdNetDevices;
640  qkdNetDevices.Add(devA);
641  qkdNetDevices.Add(devB);
642 
643  //TCH for net devices on underlay L2
644  NetDeviceContainer UnderlayNetDevices;
645  UnderlayNetDevices.Add(IPa);
646  UnderlayNetDevices.Add(IPb);
647 
648  TrafficControlHelper tchUnderlay;
649  tchUnderlay.Uninstall(UnderlayNetDevices);
650  uint16_t handleUnderlay = tchUnderlay.SetRootQueueDisc ("ns3::QKDL2PfifoFastQueueDisc");
651  tchUnderlay.AddInternalQueues (handleUnderlay, 3, "ns3::DropTailQueue<QueueDiscItem>", "MaxSize", StringValue ("1000p"));
652  //tchUnderlay.AddPacketFilter (handleUnderlay, "ns3::PfifoFastIpv4PacketFilter");
653  QueueDiscContainer qdiscsUnderlay = tchUnderlay.Install (UnderlayNetDevices);
654 
656  // UDP AND TCP SetDownTarget to QKD Priority Queues which sit between L3 and L4
658 
659  //------------------------------------------
660  // Forward from TCP/UDP L4 to QKD Queues
661  //------------------------------------------
662  if( m_supportQKDL4 ){
663 
665  uint16_t QKDhandle = qkdTch.SetRootQueueDisc ("ns3::QKDL4PfifoFastQueueDisc");
666  qkdTch.AddInternalQueues (QKDhandle, 3, "ns3::DropTailQueue<QueueDiscItem>", "MaxSize", StringValue ("1000p"));
667  //qkdTch.AddPacketFilter (QKDhandle, "ns3::PfifoFastQKDPacketFilter");
668  QueueDiscContainer QKDqdiscsA = qkdTch.Install (a);
669  QueueDiscContainer QKDqdiscsB = qkdTch.Install (b);
670 
671  //NODE A
672  //Forward UDP communication from L4 to QKD Queues
675 
676  //Forward TCP communication from L4 to QKD Queues
679 
680  //NODE B
681  //Forward UDP communication from L4 to QKD Queues
684 
685  //Forward TCP communication from L4 to QKD Queues
688 
689  //------------------------------------------
690  // Forward from QKD Queues to Virtual IPv4 L3
691  //------------------------------------------
692 
693  //Forward TCP communication from L4 to Virtual L3
695  QKDTCLa->SetDownTarget (MakeCallback (&VirtualIpv4L3Protocol::Send, a->GetObject<VirtualIpv4L3Protocol> ()));
696 
697  //Forward TCP communication from L4 to Virtual L3
699  QKDTCLb->SetDownTarget (MakeCallback (&VirtualIpv4L3Protocol::Send, b->GetObject<VirtualIpv4L3Protocol> ()));
700 
701  }
702 
704  // Store details in QKD Managers
705  // which are in charge to create QKD buffers
707 
708  //MASTER on node A
709  if(a->GetObject<QKDManager> () != 0){
710  a->GetObject<QKDManager> ()->AddNewLink(
711  devA, //QKDNetDevice on node A
712  devB, //QKDNetDevice on node B
713  IPa, //IPNetDevice on node A
714  IPb, //IPNetDevice on node B
715  m_QCrypto,
716  m_socketA,
717  m_socketA_sink,
718  typeId,
720  IPQKDaddressA, //QKD IP Src Address - overlay device
721  IPQKDaddressB, //QKD IP Dst Address - overlay device
722  netA, //IP Src Address - underlay device
723  netB, //IP Dst Address - underlay device
724  true,
725  Mmin,
726  Mthr,
727  Mmax,
728  Mcurrent,
730  );
731  }
732 
733  //SLAVE on node B
734  if(b->GetObject<QKDManager> () != 0){
735  b->GetObject<QKDManager> ()->AddNewLink(
736  devB, //QKDNetDevice on node B
737  devA, //QKDNetDevice on node A
738  IPb, //IPNetDevice on node B
739  IPa, //IPNetDevice on node A
740  m_QCrypto,
741  m_socketB,
742  m_socketB_sink,
743  typeId,
745  IPQKDaddressB, //QKD IP Dst Address - overlay device
746  IPQKDaddressA, //QKD IP Src Address - overlay device
747  netB, //IP Dst Address - underlay device
748  netA, //IP Src Address - underlay device
749  false,
750  Mmin,
751  Mthr,
752  Mmax,
753  Mcurrent,
754  m_channelID++
755  );
756  }
757 
763  if(m_useRealStorages){
764  Ptr<QKDBuffer> bufferA = a->GetObject<QKDManager> ()->GetBufferBySourceAddress(IPQKDaddressA.GetLocal ());
765  Ptr<QKDBuffer> bufferB = b->GetObject<QKDManager> ()->GetBufferBySourceAddress(IPQKDaddressB.GetLocal ());
766 
767  NS_LOG_FUNCTION(this << "!!!!!!!!!!!!!!" << bufferA->GetBufferId() << bufferB->GetBufferId() );
768 
769  uint32_t packetSize = 32;
770  for(uint32_t i = 0; i < Mcurrent; i++ )
771  {
772  bufferA->AddNewContent(packetSize);
773  bufferB->AddNewContent(packetSize);
774  }
775  }
776 
777 
778  if(typeId == "ns3::TcpSocketFactory")
780 
781  return qkdNetDevices;
782 }
783 
795  Ptr<NetDevice> IPa, //IP Net device of underlay network on node A
796  Ptr<NetDevice> IPb, //IP Net device of underlay network on node B
797  uint32_t Mmin, //Buffer details
798  uint32_t Mthr, //Buffer details
799  uint32_t Mmax, //Buffer details
800  uint32_t Mcurrent //Buffer details
801 )
802 {
803  //################################
804  // SINGLE TCP/IP NETWORK
805  //################################
806 
807  IPa->SetSniffPacketFromDevice(false);
808  IPb->SetSniffPacketFromDevice(false);
809 
811  // IPv4L3 Protocol and QKDL2 Traffic controller
813 
814  Ptr<Node> a = IPa->GetNode();
815  Ptr<Node> b = IPb->GetNode();
816 
817  NS_LOG_FUNCTION(this << a->GetId() << b->GetId());
818 
820  // NODE A
822 
824  CreateAndAggregateObjectFromTypeId (a, "ns3::QKDL4TrafficControlLayer");
825 
826  if( a->GetObject<TrafficControlLayer> () == 0)
827  CreateAndAggregateObjectFromTypeId (a, "ns3::TrafficControlLayer");
828 
829  //Get address of classical device which is used for connection on the lower layer
830  Ptr<Ipv4> ipv4a = a->GetObject<Ipv4L3Protocol> ();
831  uint32_t interfaceOfClassicalDeviceOnNodeA = ipv4a->GetInterfaceForDevice(IPa);
832  Ipv4InterfaceAddress netA = ipv4a->GetAddress (interfaceOfClassicalDeviceOnNodeA, 0);
833 
835  // NODE B
837 
839  CreateAndAggregateObjectFromTypeId (b, "ns3::QKDL4TrafficControlLayer");
840 
841  if( b->GetObject<TrafficControlLayer> () == 0)
842  CreateAndAggregateObjectFromTypeId (b, "ns3::TrafficControlLayer");
843 
844  //Get address of classical device which is used for connection of QKDNetDevice on lower layer
845  Ptr<Ipv4> ipv4b = b->GetObject<Ipv4L3Protocol> ();
846  uint32_t interfaceOfClassicalDeviceOnNodeB = ipv4b->GetInterfaceForDevice(IPb);
847  Ipv4InterfaceAddress netB = ipv4b->GetAddress (interfaceOfClassicalDeviceOnNodeB, 0);
848 
849  Ptr<Socket> m_socketA;
850  Ptr<Socket> m_socketB;
851  Ptr<Socket> m_socketA_sink;
852  Ptr<Socket> m_socketB_sink;
853 
855  // UDP AND TCP SetDownTarget to QKD Priority Queues which sit between L3 and L4
857 
858  //------------------------------------------
859  // Forward from TCP/UDP L4 to QKD Queues
860  //------------------------------------------
861 
862  if (m_supportQKDL4) {
863 
865  uint16_t QKDhandle = qkdTch.SetRootQueueDisc ("ns3::QKDL4PfifoFastQueueDisc");
866  qkdTch.AddInternalQueues (QKDhandle, 3, "ns3::DropTailQueue<QueueDiscItem>", "MaxSize", StringValue ("1000p"));
867  //qkdTch.AddPacketFilter (QKDhandle, "ns3::PfifoFastQKDPacketFilter");
868  QueueDiscContainer QKDqdiscsA = qkdTch.Install (a);
869  QueueDiscContainer QKDqdiscsB = qkdTch.Install (b);
870 
871 
872  //------------------------------------------
873  // Forward from QKD Queues to IPv4 L3
874  //------------------------------------------
875 
876  //Forward L4 communication to IPv4 L3
878  IpL4Protocol::DownTargetCallback qkdl4DownTarget_a = QKDTCLa->GetDownTarget();
879 
880  //Set it only once, otherwise we will finish in infinite loop
881  if(qkdl4DownTarget_a.IsNull()){
882 
883  //Node A
886 
887  IpL4Protocol::DownTargetCallback udpA_L4_downTarget = udpA->GetDownTarget ();
888  IpL4Protocol::DownTargetCallback tcpA_L4_downTarget = tcpA->GetDownTarget ();
889 
890  if(!udpA_L4_downTarget.IsNull ())
891  QKDTCLa->SetDownTarget (udpA_L4_downTarget);
892  else if(!tcpA_L4_downTarget.IsNull ())
893  QKDTCLa->SetDownTarget (tcpA_L4_downTarget);
894  else
895  NS_ASSERT (!udpA_L4_downTarget.IsNull ());
896  //QKDTCLa->SetDownTarget (MakeCallback (&Ipv4L3Protocol::Send, a->GetObject<Ipv4L3Protocol> ()));
897 
898  //NODE A
899  //Forward UDP communication from L4 to QKD Queues
901  //Forward TCP communication from L4 to QKD Queues
903 
904  }
905 
906 
907 
909  IpL4Protocol::DownTargetCallback qkdl4DownTarget_b = QKDTCLb->GetDownTarget();
910 
911  //Set it only once, otherwise we will finish in infinite loop
912  if(qkdl4DownTarget_b.IsNull()){
913 
914  //Node B
917 
918  //Forward L4 communication to IPv4 L3
919  IpL4Protocol::DownTargetCallback udpB_L4_downTarget = udpB->GetDownTarget ();
920  IpL4Protocol::DownTargetCallback tcpB_L4_downTarget = tcpB->GetDownTarget ();
921 
922  if(!udpB_L4_downTarget.IsNull ())
923  QKDTCLb->SetDownTarget (udpB_L4_downTarget);
924  else if(!tcpB_L4_downTarget.IsNull ())
925  QKDTCLb->SetDownTarget (tcpB_L4_downTarget);
926  else
927  NS_ASSERT (!udpB_L4_downTarget.IsNull ());
928  //QKDTCLb->SetDownTarget (MakeCallback (&Ipv4L3Protocol::Send, b->GetObject<Ipv4L3Protocol> ()));
929 
930  //NODE B
931  //Forward UDP communication from L4 to QKD Queues
933  //Forward TCP communication from L4 to QKD Queues
935 
936  }
937 
938  }
939 
941  // QKD Traffic Control - queues on QKD Netdevices (L2)
942  // Optional usage
944 
945  NetDeviceContainer qkdNetDevices;
946  qkdNetDevices.Add(IPa);
947  qkdNetDevices.Add(IPb);
948 
950  tch.Uninstall(qkdNetDevices);
951  uint16_t handle = tch.SetRootQueueDisc ("ns3::QKDL2SingleTCPIPPfifoFastQueueDisc");
952  tch.AddInternalQueues (handle, 3, "ns3::DropTailQueue<QueueDiscItem>", "MaxSize", StringValue ("1000p"));
953  //tch.AddPacketFilter (handle, "ns3::PfifoFastIpv4PacketFilter");
954  QueueDiscContainer qdiscs = tch.Install (qkdNetDevices);
955 
957  //Forward packet from NETDevice to QKDManager to be processed (decrypted and authentication check);
958 
960  NS_ASSERT (tc_a != 0);
961 
963  NS_ASSERT (tc_b != 0);
964 
971 
972  //a->UnregisterProtocolHandler (MakeCallback (&QKDManager::VirtualReceiveSimpleNetwork, a->GetObject<QKDManager> () ));
973  //a->UnregisterProtocolHandler (MakeCallback (&QKDManager::VirtualReceiveSimpleNetwork, a->GetObject<QKDManager> () ));
974 
979 
986 
987  //b->UnregisterProtocolHandler (MakeCallback (&QKDManager::VirtualReceiveSimpleNetwork, b->GetObject<QKDManager> () ));
988  //b->UnregisterProtocolHandler (MakeCallback (&QKDManager::VirtualReceiveSimpleNetwork, b->GetObject<QKDManager> () ));
989 
994 
996  // Store details in QKD Managers
997  // which are in charge to create QKD buffers
999 
1000  //MASTER on node A
1001  if(a->GetObject<QKDManager> () != 0){
1002  a->GetObject<QKDManager> ()->AddNewLink(
1003  0, //QKDNetDevice on node A
1004  0, //QKDNetDevice on node B
1005  IPa, //IPNetDevice on node A
1006  IPb, //IPNetDevice on node B
1007  m_QCrypto,
1008  0, //m_socketA = 0
1009  0, //m_socketA_sink = 0
1010  "", //sockettypeID
1012  netA, //QKD IP Src Address - overlay device - same as underlay
1013  netB, //QKD IP Dst Address - overlay device - same as underlay
1014  netA, //IP Src Address - underlay device
1015  netB, //IP Dst Address - underlay device
1016  true,
1017  Mmin,
1018  Mthr,
1019  Mmax,
1020  Mcurrent,
1021  m_channelID
1022  );
1023  }
1024 
1025  //SLAVE on node B
1026  if(b->GetObject<QKDManager> () != 0){
1027  b->GetObject<QKDManager> ()->AddNewLink(
1028  0, //QKDNetDevice on node B
1029  0, //QKDNetDevice on node A
1030  IPb, //IPNetDevice on node B
1031  IPa, //IPNetDevice on node A
1032  m_QCrypto,
1033  0, //m_socketB = 0
1034  0, //m_socketB_sink = 0
1035  "", //sockettypeID
1037  netB, //QKD IP Dst Address - overlay device - same as underlay
1038  netA, //QKD IP Src Address - overlay device - same as underlay
1039  netB, //IP Dst Address - underlay device
1040  netA, //IP Src Address - underlay device
1041  false,
1042  Mmin,
1043  Mthr,
1044  Mmax,
1045  Mcurrent,
1046  m_channelID++
1047  );
1048  }
1049 
1055  if(m_useRealStorages){
1056 
1057  //Get buffer on node A which is pointed from netA
1058  Ptr<QKDBuffer> bufferA = a->GetObject<QKDManager> ()->GetBufferBySourceAddress(netA.GetLocal ());
1059 
1060  //Get buffer on node B which is pointed from netB
1061  Ptr<QKDBuffer> bufferB = b->GetObject<QKDManager> ()->GetBufferBySourceAddress(netB.GetLocal ());
1062 
1063  NS_LOG_FUNCTION(this << "!!!!!!!!!!!!!!" << bufferA->GetBufferId() << bufferB->GetBufferId() );
1064 
1065  uint32_t packetSize = 32;
1066  for(uint32_t i = 0; i < Mcurrent; i++ )
1067  {
1068  bufferA->AddNewContent(packetSize);
1069  bufferB->AddNewContent(packetSize);
1070  }
1071  }
1072 
1073  return qkdNetDevices;
1074 
1075  }
1076 } // namespace ns3
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)
Enable pcap output the indicated net device.
Definition: qkd-helper.cc:73
Manage ASCII trace files for device models.
Definition: trace-helper.h:161
an Inet address class
static void CreateAndAggregateObjectFromTypeId(Ptr< Node > node, const std::string typeId)
create an object from its TypeId and aggregates it to the node
Definition: qkd-helper.cc:313
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint32_t m_counter
Definition: qkd-helper.h:258
QueueDiscContainer Install(NetDeviceContainer c)
static void DefaultEnqueueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Enqueue default trace sink.
void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)
Called from upper layer (L4) to queue a packet for the transmission.
bool VirtualSendOverlay(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Forward packet from device to the underlay network through the socket.
Definition: qkd-manager.cc:340
void HookDefaultDropSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default drop operation trace sink that does not accept nor log a trace con...
Definition: trace-helper.h:483
Ipv4Address GetLocal(void) const
Get the local address.
void AddInternalQueues(uint16_t handle, uint16_t count, std::string type, std::string n01="", const AttributeValue &v01=EmptyAttributeValue(), std::string n02="", const AttributeValue &v02=EmptyAttributeValue(), std::string n03="", const AttributeValue &v03=EmptyAttributeValue(), std::string n04="", const AttributeValue &v04=EmptyAttributeValue(), std::string n05="", const AttributeValue &v05=EmptyAttributeValue(), std::string n06="", const AttributeValue &v06=EmptyAttributeValue(), std::string n07="", const AttributeValue &v07=EmptyAttributeValue(), std::string n08="", const AttributeValue &v08=EmptyAttributeValue())
Helper function used to add the given number of internal queues (of the given type and with the given...
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
Hold variables of type string.
Definition: string.h:41
Introspection did not find any typical Config paths.
Build a set of QueueDisc objects.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:258
Hold a value for an Attribute.
Definition: attribute.h:68
virtual int ShutdownSend(void)=0
Manage pcap files for device models.
Definition: trace-helper.h:38
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output on the indicated net device.
Definition: qkd-helper.cc:109
virtual Ipv4RoutingHelper * Copy(void) const =0
virtual constructor
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1686
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
TCP socket creation and multiplexing/demultiplexing.
Ptr< Queue< Packet > > GetQueue(void) const
Get a copy of the attached Queue.
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
static void DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Drop default trace sink.
Ptr< QKDCrypto > m_QCrypto
Definition: qkd-helper.h:256
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
virtual int ShutdownRecv(void)=0
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
uint32_t m_portOverlayNumber
Definition: qkd-helper.h:250
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:278
virtual void Receive(Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Called by NetDevices, incoming packet.
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we&#39;ll use to write the traced bits. ...
Callback< R > MakeNullCallback(void)
Definition: callback.h:1635
void Uninstall(NetDeviceContainer c)
void HookDefaultEnqueueSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default enqueue operation trace sink that does not accept nor log a trace ...
Definition: trace-helper.h:461
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the ascii trace helper figure out a reasonable filename to use for an ascii trace file associated...
uint16_t SetRootQueueDisc(std::string type, std::string n01="", const AttributeValue &v01=EmptyAttributeValue(), std::string n02="", const AttributeValue &v02=EmptyAttributeValue(), std::string n03="", const AttributeValue &v03=EmptyAttributeValue(), std::string n04="", const AttributeValue &v04=EmptyAttributeValue(), std::string n05="", const AttributeValue &v05=EmptyAttributeValue(), std::string n06="", const AttributeValue &v06=EmptyAttributeValue(), std::string n07="", const AttributeValue &v07=EmptyAttributeValue(), std::string n08="", const AttributeValue &v08=EmptyAttributeValue(), std::string n09="", const AttributeValue &v09=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue(), std::string n11="", const AttributeValue &v11=EmptyAttributeValue(), std::string n12="", const AttributeValue &v12=EmptyAttributeValue(), std::string n13="", const AttributeValue &v13=EmptyAttributeValue(), std::string n14="", const AttributeValue &v14=EmptyAttributeValue(), std::string n15="", const AttributeValue &v15=EmptyAttributeValue())
Helper function used to set a root queue disc of the given type and with the given attributes...
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, DataLinkType dataLinkType, uint32_t snapLen=std::numeric_limits< uint32_t >::max(), int32_t tzCorrection=0)
Create and initialize a pcap file.
Definition: trace-helper.cc:49
void UnregisterProtocolHandler(ProtocolHandler handler)
Definition: node.cc:261
a polymophic address class
Definition: address.h:90
Holds a vector of ns3::QueueDisc pointers.
TCP socket creation and multiplexing/demultiplexing.
Introspection did not find any typical Config paths.
Definition: qkd-manager.h:72
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
virtual int Listen(void)=0
Listen for incoming connections.
uint32_t m_channelID
Definition: qkd-helper.h:252
void HandleAccept(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.
Definition: qkd-manager.cc:700
void VirtualReceive(Ptr< Socket > socket)
Forward packet from underlay network through the socket to the QKDNetDevice Note: USED ONLY IN OVERLA...
Definition: qkd-manager.cc:588
void VirtualReceiveSimpleNetwork(Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Process packet (Decrypt and authentication check) after receiving at NetDevice, and forward it to upp...
Definition: qkd-manager.cc:526
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the pcap helper figure out a reasonable filename to use for a pcap file associated with a device...
Definition: trace-helper.cc:80
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
static void EnablePrinting(void)
Enable printing packets metadata.
Definition: packet.cc:572
A virtual device, similar to Linux TUN/TAP interfaces.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
void PrintGraphs()
Print graphs.
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
Build a set of QueueDisc objects.
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
Definition: socket.cc:128
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...
Definition: socket.cc:71
NetDeviceContainer InstallQKD(Ptr< NetDevice > IPa, Ptr< NetDevice > IPb, uint32_t Mmin, uint32_t Mthr, uint32_t Mmax, uint32_t Mcurrent)
Install and setup SINGLE TCP/IP QKD link between the nodes.
Definition: qkd-helper.cc:794
ObjectFactory m_deviceFactory
Device Factory.
Definition: qkd-helper.h:294
void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)
a factory to create ns3::Ipv4RoutingProtocol objects
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:843
NetDeviceContainer InstallOverlayQKD(Ptr< NetDevice > IPa, Ptr< NetDevice > IPb, Ipv4InterfaceAddress da, Ipv4InterfaceAddress db, uint32_t Mmin, uint32_t Mthr, uint32_t Mmax, uint32_t Mcurrent, const std::string typeId)
Install and setup OVERLAY QKD link between the nodes.
Definition: qkd-helper.cc:437
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
Definition: qkd-helper.cc:64
static void DefaultReceiveSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Receive default trace sink.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
Set routing protocol to be used in overlay QKDNetwork.
Definition: qkd-helper.cc:301
Implement the IPv4 Overlay (virtual) layer.
Implement the IPv4 layer.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
static void DefaultDequeueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Dequeue default trace sink.
static const uint16_t PROT_NUMBER
ARP protocol number (0x0806)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void ConnectionSucceeded(Ptr< Socket > socket)
Indicates that the TCP connection for socket in param is established.
Definition: qkd-manager.cc:707
keep track of a set of node pointers.
address
Definition: first.py:37
uint16_t SetRootQueueDisc(std::string type, std::string n01="", const AttributeValue &v01=EmptyAttributeValue(), std::string n02="", const AttributeValue &v02=EmptyAttributeValue(), std::string n03="", const AttributeValue &v03=EmptyAttributeValue(), std::string n04="", const AttributeValue &v04=EmptyAttributeValue(), std::string n05="", const AttributeValue &v05=EmptyAttributeValue(), std::string n06="", const AttributeValue &v06=EmptyAttributeValue(), std::string n07="", const AttributeValue &v07=EmptyAttributeValue(), std::string n08="", const AttributeValue &v08=EmptyAttributeValue(), std::string n09="", const AttributeValue &v09=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue(), std::string n11="", const AttributeValue &v11=EmptyAttributeValue(), std::string n12="", const AttributeValue &v12=EmptyAttributeValue(), std::string n13="", const AttributeValue &v13=EmptyAttributeValue(), std::string n14="", const AttributeValue &v14=EmptyAttributeValue(), std::string n15="", const AttributeValue &v15=EmptyAttributeValue())
Helper function used to set a root queue disc of the given type and with the given attributes...
Implementation of the UDP protocol.
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
void SetAcceptCallback(Callback< bool, Ptr< Socket >, const Address & > connectionRequest, Callback< void, Ptr< Socket >, const Address & > newConnectionCreated)
Accept connection requests from remote hosts.
Definition: socket.cc:104
void HookDefaultReceiveSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default receive operation trace sink that does not accept nor log a trace ...
Definition: trace-helper.h:527
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
Definition: socket.cc:330
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
Definition: node.cc:227
void InstallQKDManager(NodeContainer &n)
Install QKDManager on the node.
Definition: qkd-helper.cc:281
Instantiate subclasses of ns3::Object.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:128
uint32_t GetId(void) const
Definition: node.cc:107
a class to store IPv4 address information on an interface
void AddInternalQueues(uint16_t handle, uint16_t count, std::string type, std::string n01="", const AttributeValue &v01=EmptyAttributeValue(), std::string n02="", const AttributeValue &v02=EmptyAttributeValue(), std::string n03="", const AttributeValue &v03=EmptyAttributeValue(), std::string n04="", const AttributeValue &v04=EmptyAttributeValue(), std::string n05="", const AttributeValue &v05=EmptyAttributeValue(), std::string n06="", const AttributeValue &v06=EmptyAttributeValue(), std::string n07="", const AttributeValue &v07=EmptyAttributeValue(), std::string n08="", const AttributeValue &v08=EmptyAttributeValue())
Helper function used to add the given number of internal queues (of the given type and with the given...
Implementation of the UDP protocol.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
virtual Ptr< Ipv4RoutingProtocol > Create(Ptr< Node > node) const =0
void AddGraph(Ptr< Node > node, Ptr< NetDevice > device)
ADD QKDGraph.
Definition: qkd-helper.cc:224
static QKDGraphManager * getInstance()
Signelton getInstance function.
QKDHelper()
Create a QKDHelper to make life easier when creating point to point networks.
Definition: qkd-helper.cc:49
bool m_useRealStorages
Definition: qkd-helper.h:254
const Ipv4RoutingHelper * m_routing
IPv4 routing helper.
Definition: qkd-helper.h:248
static const uint32_t packetSize
void ConnectionFailed(Ptr< Socket > socket)
Indicates that the TCP connection for socket in param failed to establish.
Definition: qkd-manager.cc:715
void SetConnectCallback(Callback< void, Ptr< Socket > > connectionSucceeded, Callback< void, Ptr< Socket > > connectionFailed)
Specify callbacks to allow the caller to determine if the connection succeeds of fails.
Definition: socket.cc:84
A base class which provides memory management and object aggregation.
Definition: object.h:87
void HookDefaultSink(Ptr< T > object, std::string traceName, Ptr< PcapFileWrapper > file)
Hook a trace source to the default trace sink.
Definition: trace-helper.h:147
ObjectFactory m_tcpFactory
TCP objects factory.
Definition: qkd-helper.h:243
uint32_t m_supportQKDL4
Definition: qkd-helper.h:260
QueueDiscContainer Install(NetDeviceContainer c)
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
QKD Traffic control layer definition.
void HookDefaultDequeueSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default dequeue operation trace sink that does not accept nor log a trace ...
Definition: trace-helper.h:505
Introspection did not find any typical Config paths.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Definition: type-id.cc:824
void PrintGraphs()
Print QKDGraphs.
Definition: qkd-helper.cc:270