A Discrete-Event Network Simulator
API
qkd-charging-application.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/log.h"
22 #include "ns3/address.h"
23 #include "ns3/node.h"
24 #include "ns3/nstime.h"
25 #include "ns3/socket.h"
26 #include "ns3/simulator.h"
27 #include "ns3/socket-factory.h"
28 #include "ns3/packet.h"
29 #include "ns3/uinteger.h"
30 #include "ns3/trace-source-accessor.h"
31 #include "ns3/virtual-tcp-socket-factory.h"
32 #include "ns3/qkd-manager.h"
34 #include <iostream>
35 #include <fstream>
36 #include <string>
37 
38 
39 NS_LOG_COMPONENT_DEFINE ("QKDChargingApplication");
40 
41 namespace ns3 {
42 
43 NS_OBJECT_ENSURE_REGISTERED (QKDChargingApplication);
44 
45 TypeId
47 {
48  static TypeId tid = TypeId ("ns3::QKDChargingApplication")
50  .AddConstructor<QKDChargingApplication> ()
51  //send params
52  .AddAttribute ("ThrPeriod", "The period for exchange of Threshold packets.",
53  UintegerValue (15),
55  MakeUintegerChecker<uint32_t> (1))
56  .AddAttribute ("KeyRate", "The amount of data to be added to QKD Buffer (in bits).",
57  UintegerValue (100000),
59  MakeUintegerChecker<uint32_t> (1))
60  .AddAttribute ("DataRate", "The average data rate of communication.",
61  DataRateValue (DataRate ("650kbps")), //3.3Mbps //10kbps
64  .AddAttribute ("PacketSize", "The size of packets sent in post-processing state",
65  UintegerValue (320), //280
67  MakeUintegerChecker<uint32_t> (1))
68  .AddAttribute ("MaxPackets", "The size of packets sent in post-processing state",
69  UintegerValue (1270), //93000
71  MakeUintegerChecker<uint32_t> (1))
72  .AddAttribute ("MaxAuthPackets", "The size of packets sent in auth state",
73  UintegerValue (540), //4
75  MakeUintegerChecker<uint32_t> (1))
76  .AddAttribute ("MaxSiftingPackets", "The size of packets sent in sifting state",
77  UintegerValue (330),
79  MakeUintegerChecker<uint32_t> (1))
80  .AddAttribute ("MaxTemp1Packets", "The size of packets sent in temp1 state",
81  UintegerValue (200),
83  MakeUintegerChecker<uint32_t> (1))
84  .AddAttribute ("MaxTemp2Packets", "The size of packets sent in temp2 state",
85  UintegerValue (190),
87  MakeUintegerChecker<uint32_t> (1))
88 
89  .AddAttribute ("MaxTemp3Packets", "The size of packets sent in temp2 state",
90  UintegerValue (190),
92  MakeUintegerChecker<uint32_t> (1))
93 
94  .AddAttribute ("MaxTemp4Packets", "The size of packets sent in temp2 state",
95  UintegerValue (190),
97  MakeUintegerChecker<uint32_t> (1))
98 
99  .AddAttribute ("MaxTemp5Packets", "The size of packets sent in temp2 state",
100  UintegerValue (18),
102  MakeUintegerChecker<uint32_t> (1))
103 
104  .AddAttribute ("MaxTemp6Packets", "The size of packets sent in temp2 state",
105  UintegerValue (1),
107  MakeUintegerChecker<uint32_t> (1))
108 
109  .AddAttribute ("MaxTemp7Packets", "The size of packets sent in temp2 state",
110  UintegerValue (8),
112  MakeUintegerChecker<uint32_t> (1))
113 
114  .AddAttribute ("MaxTemp8Packets", "The size of packets sent in temp2 state",
115  UintegerValue (1),
117  MakeUintegerChecker<uint32_t> (1))
118 
119  .AddAttribute ("Protocol", "The type of protocol to use.",
122  MakeTypeIdChecker ())
123 
124  .AddAttribute ("Remote", "The address of the destination",
125  AddressValue (),
128  .AddAttribute ("Local", "The Address on which to Bind the rx socket.",
129  AddressValue (),
131  MakeAddressChecker ())
132 
133  .AddAttribute ("Remote_Sifting", "The address of the destination",
134  AddressValue (),
137  .AddAttribute ("Local_Sifting", "The Address on which to Bind the rx socket.",
138  AddressValue (),
140  MakeAddressChecker ())
141 
142  .AddAttribute ("Remote_Auth", "The address of the destination",
143  AddressValue (),
146  .AddAttribute ("Local_Auth", "The Address on which to Bind the rx socket.",
147  AddressValue (),
149  MakeAddressChecker ())
150 
151  .AddAttribute ("Remote_Mthreshold", "The address of the destination",
152  AddressValue (),
155  .AddAttribute ("Local_Mthreshold", "The Address on which to Bind the rx socket.",
156  AddressValue (),
158  MakeAddressChecker ())
159 
160  .AddAttribute ("Remote_Temp1", "The address of the destination",
161  AddressValue (),
164  .AddAttribute ("Local_Temp1", "The Address on which to Bind the rx socket.",
165  AddressValue (),
167  MakeAddressChecker ())
168 
169  .AddAttribute ("Remote_Temp2", "The address of the destination",
170  AddressValue (),
173  .AddAttribute ("Local_Temp2", "The Address on which to Bind the rx socket.",
174  AddressValue (),
176  MakeAddressChecker ())
177 
178  .AddAttribute ("Remote_Temp3", "The address of the destination",
179  AddressValue (),
182  .AddAttribute ("Local_Temp3", "The Address on which to Bind the rx socket.",
183  AddressValue (),
185  MakeAddressChecker ())
186 
187  .AddAttribute ("Remote_Temp4", "The address of the destination",
188  AddressValue (),
191  .AddAttribute ("Local_Temp4", "The Address on which to Bind the rx socket.",
192  AddressValue (),
194  MakeAddressChecker ())
195 
196  .AddAttribute ("Remote_Temp5", "The address of the destination",
197  AddressValue (),
200  .AddAttribute ("Local_Temp5", "The Address on which to Bind the rx socket.",
201  AddressValue (),
203  MakeAddressChecker ())
204 
205  .AddAttribute ("Remote_Temp6", "The address of the destination",
206  AddressValue (),
209  .AddAttribute ("Local_Temp6", "The Address on which to Bind the rx socket.",
210  AddressValue (),
212  MakeAddressChecker ())
213 
214  .AddAttribute ("Remote_Temp7", "The address of the destination",
215  AddressValue (),
218  .AddAttribute ("Local_Temp7", "The Address on which to Bind the rx socket.",
219  AddressValue (),
221  MakeAddressChecker ())
222 
223  .AddAttribute ("Remote_Temp8", "The address of the destination",
224  AddressValue (),
227  .AddAttribute ("Local_Temp8", "The Address on which to Bind the rx socket.",
228  AddressValue (),
230  MakeAddressChecker ())
231 
232  .AddTraceSource ("Tx", "A new packet is created and is sent",
234  "ns3::QKDChargingApplication::Tx")
235  .AddTraceSource ("Rx", "A packet has been received",
237  "ns3::QKDChargingApplication::Rx")
238  ;
239  return tid;
240 }
241 
242 
244 {
245  m_connected = false;
246  m_packetNumber= 0;
247  m_totalRx= 0;
250  m_qkdTotalTime= 0;
251  m_status= 0;
262 }
263 
265 {
266  NS_LOG_FUNCTION (this);
267 }
268 
269 
271 {
272  NS_LOG_FUNCTION (this);
273  return m_totalRx;
274 }
275 
276 
277 std::list<Ptr<Socket> >
279 {
280  NS_LOG_FUNCTION (this);
281  return m_sinkSocketList;
282 }
283 
286 {
287  NS_LOG_FUNCTION (this);
288  return m_sinkSocket;
289 }
290 
291 
294 {
295  NS_LOG_FUNCTION (this);
296  return m_sendSocket;
297 }
298 
299 void
300 QKDChargingApplication::SetSocket (std::string type, Ptr<Socket> socket, Ptr<NetDevice> device, bool isMaster)
301 {
302  NS_LOG_FUNCTION (this << type << socket << device << isMaster);
303 
304  if(type == "send"){//send app
305  m_sendSocket = socket;
306  m_sendDevice = device;
307  }else{ // sink app
308  m_sinkSocket = socket;
309  m_sinkDevice = device;
310  }
311  m_master = isMaster;
312 }
313 
314 void
316 {
317  NS_LOG_FUNCTION (this << type << socket);
318 
319  if(type == "send"){//send app
320  m_sendSocket_auth = socket;
321  }else{ // sink app
322  m_sinkSocket_auth = socket;
323  }
324 }
325 
326 void
328 {
329  NS_LOG_FUNCTION (this << type << socket);
330 
331  if(type == "send"){//send app
332  m_sendSocket_sifting = socket;
333  }else{ // sink app
334  m_sinkSocket_sifting = socket;
335  }
336 }
337 
338 void
340 {
341  NS_LOG_FUNCTION (this << type << socket);
342 
343  if(type == "send"){//send app
344  m_tempSendSocket_1 = socket;
345  }else{ // sink app
346  m_tempSinkSocket_1 = socket;
347  }
348 }
349 
350 void
352 {
353  NS_LOG_FUNCTION (this << type << socket);
354 
355  if(type == "send"){//send app
356  m_tempSendSocket_2 = socket;
357  }else{ // sink app
358  m_tempSinkSocket_2 = socket;
359  }
360 }
361 
362 void
364 {
365  NS_LOG_FUNCTION (this << type << socket);
366 
367  if(type == "send"){//send app
368  m_tempSendSocket_3 = socket;
369  }else{ // sink app
370  m_tempSinkSocket_3 = socket;
371  }
372 }
373 
374 void
376 {
377  NS_LOG_FUNCTION (this << type << socket);
378 
379  if(type == "send"){//send app
380  m_tempSendSocket_4 = socket;
381  }else{ // sink app
382  m_tempSinkSocket_4 = socket;
383  }
384 }
385 
386 void
388 {
389  NS_LOG_FUNCTION (this << type << socket);
390 
391  if(type == "send"){//send app
392  m_tempSendSocket_5 = socket;
393  }else{ // sink app
394  m_tempSinkSocket_5 = socket;
395  }
396 }
397 
398 void
400 {
401  NS_LOG_FUNCTION (this << type << socket);
402 
403  if(type == "send"){//send app
404  m_tempSendSocket_6 = socket;
405  }else{ // sink app
406  m_tempSinkSocket_6 = socket;
407  }
408 }
409 
410 void
412 {
413  NS_LOG_FUNCTION (this << type << socket);
414 
415  if(type == "send"){//send app
416  m_tempSendSocket_7 = socket;
417  }else{ // sink app
418  m_tempSinkSocket_7 = socket;
419  }
420 }
421 
422 void
424 {
425  NS_LOG_FUNCTION (this << type << socket);
426 
427  if(type == "send"){//send app
428  m_tempSendSocket_8 = socket;
429  }else{ // sink app
430  m_tempSinkSocket_8 = socket;
431  }
432 }
433 
434 
435 
436 void
438 {
439  NS_LOG_FUNCTION (this);
440 
441  m_sendSocket = 0;
442  m_sinkSocket = 0;
447  m_sendSocket_auth = 0;
448  m_sinkSocket_auth = 0;
449  m_tempSendSocket_1 = 0;
450  m_tempSinkSocket_1 = 0;
451  m_tempSendSocket_2 = 0;
452  m_tempSinkSocket_2 = 0;
453  m_tempSendSocket_3 = 0;
454  m_tempSinkSocket_3 = 0;
455  m_tempSendSocket_4 = 0;
456  m_tempSinkSocket_4 = 0;
457  m_tempSendSocket_5 = 0;
458  m_tempSinkSocket_5 = 0;
459  m_tempSendSocket_6 = 0;
460  m_tempSinkSocket_6 = 0;
461  m_tempSendSocket_7 = 0;
462  m_tempSinkSocket_7 = 0;
463  m_tempSendSocket_8 = 0;
464  m_tempSinkSocket_8 = 0;
465 
466  m_sinkSocketList.clear ();
468  // chain up
470 }
471 
472 // Application Methods
473 void QKDChargingApplication::StartApplication (void) // Called at time specified by Start
474 {
475  NS_LOG_FUNCTION (this);
476 
477  m_random = CreateObject<UniformRandomVariable> ();
478  //m_maxPackets = m_random->GetValue (m_maxPackets * 0.5, m_maxPackets * 1.5);
479 
480  // SINK socket settings
481  // Create the socket if not already
482  if (!m_sinkSocket)
484  m_sinkSocket->SetIpTos(16);
485  m_sinkSocket->SetIpRecvTos(true);
488  m_sinkSocket->Listen ();
492  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
497 
498  // SEND socket settings
499  // Create the socket if not already
500  if (!m_sendSocket)
502  m_sendSocket->SetIpTos(16);
503  m_sendSocket->SetIpRecvTos(true);
505  //initate TCP-threehand shaking
507  //disable receiving any data on this socket
514 
516 
517 
518  //---------------------------------------------------------------------
519  // mthreshold socket settings
520  //----------------------------------------------------------------------
521 
522  // mthreshold SINK socket settings
523  // Create the socket if not already
536  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
538 
542 
543  // mthreshold SEND socket settings
544  // Create the socket if not already
551  //m_sendSocket_mthreshold->Bind (m_local);
553  //initate TCP-threehand shaking
555  //m_sendSocket_mthreshold->SetIpTtl (0);
556  //disable receiving any data on this socket
561 
564 
565  //---------------------------------------------------------------------
566  // AUTH socket settings
567  //----------------------------------------------------------------------
568 
569  // AUTH SINK socket settings
570  // Create the socket if not already
571  if (!m_sinkSocket_auth)
581  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
583 
587 
588  // AUTH SEND socket settings
589  // Create the socket if not already
590  if (!m_sendSocket_auth)
602 
603 
604  //---------------------------------------------------------------------
605  // SIFTING socket settings
606  //----------------------------------------------------------------------
607 
608  // SIFTING SINK socket settings
609  // Create the socket if not already
610  if (!m_sinkSocket_sifting )
620  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
625 
626 
627  // SIFTING SEND socket settings
628  // Create the socket if not already
633  //m_sendSocket_sifting->Bind (m_local);
642 
643 
644  //---------------------------------------------------------------------
645  // temp1 socket settings
646  //----------------------------------------------------------------------
647 
648  // temp1 SINK socket settings
649  // Create the socket if not already
650  if (!m_tempSinkSocket_1){
651  NS_LOG_FUNCTION(this << "CREATE TEMP1 SINK SOCKET!");
653  }
662  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
667 
668  // temp1 SEND socket settings
669  // Create the socket if not already
670  if (!m_tempSendSocket_1){
671  NS_LOG_FUNCTION(this << "CREATE TEMP1 SEND SOCKET!");
673  }
684 
685 
686  //---------------------------------------------------------------------
687  // temp2 socket settings
688  //----------------------------------------------------------------------
689 
690  // temp2 SINK socket settings
691  // Create the socket if not already
692  if (!m_tempSinkSocket_2){
693  NS_LOG_FUNCTION(this << "CREATE TEMP2 SINK SOCKET!");
695  }
704  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
706 
710 
711 
712  // temp2 SEND socket settings
713  // Create the socket if not already
714  if (!m_tempSendSocket_2){
715  NS_LOG_FUNCTION(this << "CREATE TEMP2 SEND SOCKET!");
717  }
720  //m_tempSendSocket_2->Bind (m_local);
722  //initate TCP-threehand shaking
724  //m_tempSendSocket_2->SetIpTtl (0);
725  //disable receiving any data on this socket
732 
733 
734 
735 
736  //---------------------------------------------------------------------
737  // temp3 socket settings
738  //----------------------------------------------------------------------
739 
740  // temp3 SINK socket settings
741  // Create the socket if not already
742  if (!m_tempSinkSocket_3){
743  NS_LOG_FUNCTION(this << "CREATE TEMP3 SINK SOCKET!");
745  }
754  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
756 
760 
761 
762  // temp3 SEND socket settings
763  // Create the socket if not already
764  if (!m_tempSendSocket_3){
765  NS_LOG_FUNCTION(this << "CREATE TEMP3 SEND SOCKET!");
767  }
770  //m_tempSendSocket_3->Bind (m_local);
772  //initate TCP-threehand shaking
774  //m_tempSendSocket_3->SetIpTtl (0);
775  //disable receiving any data on this socket
782 
783 
784  //---------------------------------------------------------------------
785  // temp4 socket settings
786  //----------------------------------------------------------------------
787 
788  // temp4 SINK socket settings
789  // Create the socket if not already
790  if (!m_tempSinkSocket_4){
791  NS_LOG_FUNCTION(this << "CREATE TEMP4 SINK SOCKET!");
793  }
802  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
804 
808 
809 
810  // temp4 SEND socket settings
811  // Create the socket if not already
812  if (!m_tempSendSocket_4){
813  NS_LOG_FUNCTION(this << "CREATE TEMP4 SEND SOCKET!");
815  }
818  //m_tempSendSocket_4->Bind (m_local);
820  //initate TCP-threehand shaking
822  //m_tempSendSocket_4->SetIpTtl (0);
823  //disable receiving any data on this socket
830 
831 
832  //---------------------------------------------------------------------
833  // temp5 socket settings
834  //----------------------------------------------------------------------
835 
836  // temp5 SINK socket settings
837  // Create the socket if not already
838  if (!m_tempSinkSocket_5){
839  NS_LOG_FUNCTION(this << "CREATE TEMP5 SINK SOCKET!");
841  }
850  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
852 
856 
857 
858  // temp5 SEND socket settings
859  // Create the socket if not already
860  if (!m_tempSendSocket_5){
861  NS_LOG_FUNCTION(this << "CREATE TEMP5 SEND SOCKET!");
863  }
866  //m_tempSendSocket_5->Bind (m_local);
868  //initate TCP-threehand shaking
870  //m_tempSendSocket_5->SetIpTtl (0);
871  //disable receiving any data on this socket
878 
879 
880  //---------------------------------------------------------------------
881  // temp6 socket settings
882  //----------------------------------------------------------------------
883 
884  // temp6 SINK socket settings
885  // Create the socket if not already
886  if (!m_tempSinkSocket_6){
887  NS_LOG_FUNCTION(this << "CREATE TEMP6 SINK SOCKET!");
889  }
898  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
900 
904 
905  // temp6 SEND socket settings
906  // Create the socket if not already
907  if (!m_tempSendSocket_6){
908  NS_LOG_FUNCTION(this << "CREATE TEMP6 SEND SOCKET!");
910  }
913  //m_tempSendSocket_6->Bind (m_local);
915  //initate TCP-threehand shaking
917  //m_tempSendSocket_6->SetIpTtl (0);
918  //disable receiving any data on this socket
925 
926  //---------------------------------------------------------------------
927  // temp7 socket settings
928  //----------------------------------------------------------------------
929 
930  // temp7 SINK socket settings
931  // Create the socket if not already
932  if (!m_tempSinkSocket_7){
933  NS_LOG_FUNCTION(this << "CREATE TEMP7 SINK SOCKET!");
935  }
944  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
946 
950 
951  // temp7 SEND socket settings
952  // Create the socket if not already
953  if (!m_tempSendSocket_7){
954  NS_LOG_FUNCTION(this << "CREATE TEMP7 SEND SOCKET!");
956  }
959  //m_tempSendSocket_7->Bind (m_local);
961  //initate TCP-threehand shaking
963  //m_tempSendSocket_7->SetIpTtl (0);
964  //disable receiving any data on this socket
971 
972  //---------------------------------------------------------------------
973  // temp8 socket settings
974  //----------------------------------------------------------------------
975 
976  // temp8 SINK socket settings
977  // Create the socket if not already
978  if (!m_tempSinkSocket_8){
979  NS_LOG_FUNCTION(this << "CREATE TEMP8 SINK SOCKET!");
981  }
990  MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
992 
996 
997  // temp8 SEND socket settings
998  // Create the socket if not already
999  if (!m_tempSendSocket_8){
1000  NS_LOG_FUNCTION(this << "CREATE TEMP8 SEND SOCKET!");
1002  }
1005  //m_tempSendSocket_8->Bind (m_local);
1007  //initate TCP-threehand shaking
1009  //m_tempSendSocket_8->SetIpTtl (0);
1010  //disable receiving any data on this socket
1017 
1018  /******************
1019  * PLEASE START
1020  ******************/
1021  if(m_master){
1022 
1023  //SendSiftingPacket ();
1024 
1025  //SendData();
1026  //SendMthresholdPacket();
1027 
1028  //SendSiftingPacket();
1029  //SendDataTemp3 ();
1030  //SendDataTemp4 ();
1031  }
1032 }
1033 
1034 void QKDChargingApplication::StopApplication (void) // Called at time specified by Stop
1035 {
1036  NS_LOG_FUNCTION (this);
1037 
1038  if (m_sendSocket != 0)
1039  {
1040  m_sendSocket->Close ();
1041  }
1042  else
1043  {
1044  NS_LOG_WARN ("QKDChargingApplication found null socket to close in StopApplication");
1045  }
1046 
1047  NS_LOG_FUNCTION (this);
1048  while(!m_sinkSocketList.empty ()) //these are accepted sockets, close them
1049  {
1050  Ptr<Socket> acceptedSocket = m_sinkSocketList.front ();
1051  m_sinkSocketList.pop_front ();
1052  acceptedSocket->Close ();
1053  }
1054  if (m_sinkSocket != 0)
1055  {
1056  m_sinkSocket->Close ();
1058  }
1059 
1060  m_connected = false;
1062 }
1063 
1064 
1065 
1067 {
1068  NS_LOG_FUNCTION (this);
1069 
1070  if(m_master == true)
1071  NS_LOG_FUNCTION(this << "********************** MASTER **********************");
1072  else
1073  NS_LOG_FUNCTION(this << "********************** SLAVE **********************");
1074 
1075  NS_LOG_FUNCTION(this << "####################### POST-PROCESSING STATE #######################");
1076 
1077  NS_LOG_DEBUG(this << "\tSendData!\t" << m_sendDevice->GetAddress() << "\t" << m_sinkDevice->GetAddress() );
1078  NS_LOG_DEBUG (this << "\t Sending packet " << m_packetNumber << " of maximal " << m_maxPackets);
1079 
1081  {
1082  m_sendKeyRateMessage = true;
1083  m_packetNumber = 0;
1084  m_qkdPacketNumber = 0;
1085  }
1086 
1087  if(m_master == true && m_sendKeyRateMessage == true)
1088  PrepareOutput("ADDKEY", m_keyRate);
1089  else
1090  PrepareOutput("QKDPPS", m_packetNumber);
1091 }
1092 
1093 void QKDChargingApplication::PrepareOutput (std::string key, uint32_t value)
1094 {
1095  NS_LOG_DEBUG (this << Simulator::Now () << key << value);
1096 
1097  std::ostringstream msg;
1098  msg << key << ":" << value << ";";
1099 
1100  //playing with packet size to introduce some randomness
1101  msg << std::string( m_random->GetValue (m_pktSize, m_pktSize*1.5), '0');
1102  msg << '\0';
1103 
1104  //NS_LOG_FUNCTION (this << msg.str() );
1105 
1106  Ptr<Packet> packet = Create<Packet> ((uint8_t*) msg.str().c_str(), msg.str().length());
1107 
1108  if(key== "ADDKEY:"){
1109  if( GetNode()->GetObject<QKDManager> () != 0 )
1110  packet = GetNode()->GetObject<QKDManager> ()->MarkEncrypt (packet);
1111  }
1112 
1113  NS_LOG_DEBUG(this << "\t PACKET SIZE:" << packet->GetSize());
1114 
1115  uint32_t bits = packet->GetSize() * 8;
1116  NS_LOG_LOGIC (this << "bits = " << bits);
1117 
1118  Time nextTime (Seconds (bits / static_cast<double>(m_cbrRate.GetBitRate ()))); // Time till next packet
1119  NS_LOG_FUNCTION(this << "CALCULATED NEXTTIME:" << bits / m_cbrRate.GetBitRate ());
1120 
1121  NS_LOG_LOGIC ("nextTime = " << nextTime);
1123 }
1124 
1126 
1127  NS_LOG_DEBUG (this << "\t" << packet << "PACKETID: " << packet->GetUid() << packet->GetSize() );
1128  if(m_connected){
1129  m_txTrace (packet);
1130  m_sendSocket->Send (packet);
1131  }
1132 }
1133 
1135 
1136  NS_LOG_FUNCTION (this);
1137 
1138  uint32_t tempValue = 800 + m_random->GetValue (100, 300);
1139  NS_LOG_FUNCTION (this << "Sending SIFTING packet of size" << tempValue);
1140  Ptr<Packet> packet = Create<Packet> (tempValue);
1141  m_sendSocket_sifting->Send (packet);
1142  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1143 
1145 
1146  if(m_packetNumber_sifting < m_maxPackets_sifting){
1148  }else {
1149  SendAuthPacket();
1150  SendDataTemp1 ();
1151  SendDataTemp2 ();
1152  SendDataTemp5 ();
1153  SendDataTemp6 ();
1154  SendDataTemp7 ();
1155  m_packetNumber_sifting = 0;
1157  }
1158 
1159 }
1160 
1162 
1163  NS_LOG_FUNCTION (this);
1164  Ptr<Packet> packet = Create<Packet> (m_random->GetValue (400, 700));
1165  m_sendSocket_auth->Send (packet);
1166 
1167  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1168 
1170 
1171  if(m_packetNumber_auth < m_maxPackets_auth){
1173  }else {
1174  m_packetNumber_auth = 0;
1175  }
1176 }
1177 
1178 
1180 {
1181  NS_LOG_FUNCTION (this);
1182 
1183  Ptr<Packet> packet = Create<Packet> (m_random->GetValue (30, 100));
1184 
1185  m_tempSendSocket_1->Send (packet);
1186  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1187 
1189 
1190  if(m_packetNumber_temp1 < m_maxPackets_temp1){
1192  }else {
1193  m_packetNumber_temp1 = 0;
1194  }
1195 
1196 
1197 }
1198 
1200 {
1201  NS_LOG_FUNCTION (this);
1202 
1203  Ptr<Packet> packet = Create<Packet> (m_random->GetValue (400, 600));
1204 
1205  m_tempSendSocket_2->Send (packet);
1206  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1207 
1209 
1210  if(m_packetNumber_temp2 < m_maxPackets_temp2){
1212  }else {
1213  m_packetNumber_temp2 = 0;
1214  }
1215 }
1216 
1218 {
1219  NS_LOG_FUNCTION (this);
1220 
1221  Ptr<Packet> packet = Create<Packet> (m_random->GetValue (700,1000));
1222  m_tempSendSocket_3->Send (packet);
1223  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1224 
1225  Ptr<Packet> packet2 = Create<Packet> (m_random->GetValue (700,1000));
1226  m_tempSendSocket_3->Send (packet2);
1227  NS_LOG_FUNCTION (this << packet2 << "PACKETID: " << packet2->GetUid() << " of size: " << packet2->GetSize() );
1228 
1229  Ptr<Packet> packet3 = Create<Packet> (m_random->GetValue (700,1000));
1230  m_tempSendSocket_3->Send (packet3);
1231  NS_LOG_FUNCTION (this << packet3 << "PACKETID: " << packet3->GetUid() << " of size: " << packet3->GetSize() );
1232 
1233  Ptr<Packet> packet4 = Create<Packet> (m_random->GetValue (700,1000));
1234  m_tempSendSocket_3->Send (packet4);
1235  NS_LOG_FUNCTION (this << packet4 << "PACKETID: " << packet4->GetUid() << " of size: " << packet4->GetSize() );
1236 
1237  Ptr<Packet> packet5 = Create<Packet> (m_random->GetValue (700,1000));
1238  m_tempSendSocket_3->Send (packet5);
1239  NS_LOG_FUNCTION (this << packet5 << "PACKETID: " << packet5->GetUid() << " of size: " << packet5->GetSize() );
1240 
1241  Ptr<Packet> packet6 = Create<Packet> (m_random->GetValue (700,1000));
1242  m_tempSendSocket_3->Send (packet6);
1243  NS_LOG_FUNCTION (this << packet6 << "PACKETID: " << packet6->GetUid() << " of size: " << packet6->GetSize() );
1244 
1245  Ptr<Packet> packet7 = Create<Packet> (m_random->GetValue (700,1000));
1246  m_tempSendSocket_3->Send (packet7);
1247  NS_LOG_FUNCTION (this << packet7 << "PACKETID: " << packet7->GetUid() << " of size: " << packet7->GetSize() );
1248 
1249  Ptr<Packet> packet8 = Create<Packet> (m_random->GetValue (700,1000));
1250  m_tempSendSocket_3->Send (packet8);
1251  NS_LOG_FUNCTION (this << packet8 << "PACKETID: " << packet8->GetUid() << " of size: " << packet8->GetSize() );
1252 
1253  Ptr<Packet> packet9 = Create<Packet> (m_random->GetValue (700,1000));
1254  m_tempSendSocket_3->Send (packet9);
1255  NS_LOG_FUNCTION (this << packet9 << "PACKETID: " << packet9->GetUid() << " of size: " << packet9->GetSize() );
1256 
1257  Ptr<Packet> packet10 = Create<Packet> (m_random->GetValue (700,1000));
1258  m_tempSendSocket_3->Send (packet10);
1259  NS_LOG_FUNCTION (this << packet10 << "PACKETID: " << packet10->GetUid() << " of size: " << packet10->GetSize() );
1260 
1262 
1263 }
1264 
1266 {
1267  NS_LOG_FUNCTION (this);
1268 
1269  Ptr<Packet> packet = Create<Packet> (m_random->GetValue (30, 100));
1270  m_tempSendSocket_4->Send (packet);
1271  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1272 
1274 
1275 }
1276 
1278 {
1279  NS_LOG_FUNCTION (this);
1280 
1281  Ptr<Packet> packet;
1282 
1283  packet = Create<Packet> (m_random->GetValue (700,1000));
1284  m_tempSendSocket_5->Send (packet);
1285  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1286 
1287  packet = Create<Packet> (m_random->GetValue (700,1000));
1288  m_tempSendSocket_5->Send (packet);
1289  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1290 
1291  packet = Create<Packet> (m_random->GetValue (700,1000));
1292  m_tempSendSocket_5->Send (packet);
1293  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1294 
1295  packet = Create<Packet> (m_random->GetValue (700,1000));
1296  m_tempSendSocket_5->Send (packet);
1297  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1298 
1299  packet = Create<Packet> (m_random->GetValue (700,1000));
1300  m_tempSendSocket_5->Send (packet);
1301  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1302 
1303  packet = Create<Packet> (m_random->GetValue (700,1000));
1304  m_tempSendSocket_5->Send (packet);
1305  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1306 
1307  packet = Create<Packet> (m_random->GetValue (700,1000));
1308  m_tempSendSocket_5->Send (packet);
1309  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1310 
1311  packet = Create<Packet> (m_random->GetValue (700, 1000));
1312  m_tempSendSocket_5->Send (packet);
1313  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1314 
1316 
1317  if(m_packetNumber_temp5 < m_maxPackets_temp5){
1319  }else {
1320  m_packetNumber_temp5 = 0;
1321  }
1322 }
1323 
1325 {
1326  NS_LOG_FUNCTION (this);
1327 
1328  Ptr<Packet> packet;
1329  for (uint32_t i=0; i < 12; i++){
1330  packet = Create<Packet> (m_random->GetValue (800, 1000));
1331  m_tempSendSocket_6->Send (packet);
1332  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1333  }
1334 
1338  }else {
1339  m_packetNumber_temp6 = 0;
1340  }
1341 }
1342 
1344 {
1345  NS_LOG_FUNCTION (this);
1346 
1347  Ptr<Packet> packet;
1348  for (uint32_t i=0; i < 26; i++){
1349  packet = Create<Packet> (m_random->GetValue (700, 1000));
1350  m_tempSendSocket_7->Send (packet);
1351  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1352  }
1353 
1357  }else {
1358  m_packetNumber_temp7 = 0;
1359  }
1360 }
1361 
1363 {
1364  NS_LOG_FUNCTION (this);
1365 
1366  Ptr<Packet> packet;
1367  for (uint32_t i=0; i < 11; i++){
1368  packet = Create<Packet> (m_random->GetValue (700,1000));
1369  m_tempSendSocket_8->Send (packet);
1370  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1371  }
1372 
1376  }else {
1377  m_packetNumber_temp8 = 0;
1378  }
1379 }
1380 
1381 
1383 {
1384 
1385  NS_LOG_FUNCTION (this << socket);
1386 
1387  if(m_master == true)
1388  NS_LOG_FUNCTION(this << "***MASTER***");
1389  else
1390  NS_LOG_FUNCTION(this << "!!!SLAVE!!!");
1391 
1392  Ptr<Packet> packet;
1393  Address from;
1394  while ((packet = socket->RecvFrom (from)))
1395  {
1396  if (packet->GetSize () == 0)
1397  { //EOF
1398  break;
1399  }
1400 
1401  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1402 
1403  m_totalRx += packet->GetSize ();
1405  {
1406 
1407  NS_LOG_FUNCTION (this << "At time " << Simulator::Now ().GetSeconds ()
1408  << "s packet sink received "
1409  << packet->GetSize () << " bytes from "
1411  << " port " << InetSocketAddress::ConvertFrom (from).GetPort ()
1412  << " total Rx " << m_totalRx << " bytes");
1413 
1414  }
1415 
1416  ProcessIncomingPacket(packet, socket);
1417  m_rxTrace (packet, from);
1418  }
1419 }
1420 
1422 {
1423 
1424  NS_LOG_FUNCTION (this << socket);
1425 
1426  if(m_master == true)
1427  NS_LOG_FUNCTION(this << "***MASTER***" );
1428  else
1429  NS_LOG_FUNCTION(this << "!!!SLAVE!!!");
1430 
1431  Ptr<Packet> packet;
1432  Address from;
1433 
1434  NS_LOG_FUNCTION (this << "IT is UDP sifting socket!");
1435  packet = socket->Recv (65535, 0);
1436 }
1437 
1439 
1440  NS_LOG_FUNCTION (this << Simulator::Now ());
1441 
1442 }
1443 
1445 {
1446 
1447 }
1448 
1450 {
1451 
1452  NS_LOG_FUNCTION (this << socket);
1453 
1454  if(m_master == true)
1455  NS_LOG_FUNCTION(this << "***MASTER***" );
1456  else
1457  NS_LOG_FUNCTION(this << "!!!SLAVE!!!");
1458 
1459  Ptr<Packet> packet;
1460  Address from;
1461  while ((packet = socket->RecvFrom (from)))
1462  {
1463  if (packet->GetSize () == 0)
1464  { //EOF
1465  break;
1466  }
1467  NS_LOG_FUNCTION (this << packet << "PACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1468 
1469  m_totalRx += packet->GetSize ();
1471  {
1472 
1473  NS_LOG_FUNCTION (this << "At time " << Simulator::Now ().GetSeconds ()
1474  << "s packet sink received "
1475  << packet->GetSize () << " bytes from "
1477  << " port " << InetSocketAddress::ConvertFrom (from).GetPort ()
1478  << " total Rx " << m_totalRx << " bytes");
1479 
1480  }
1481  }
1482 }
1483 
1485 {
1486 
1487  NS_LOG_FUNCTION (this << socket);
1488 
1489  if(m_master == true)
1490  NS_LOG_FUNCTION(this << "***MASTER***" );
1491  else
1492  NS_LOG_FUNCTION(this << "!!!SLAVE!!!");
1493 
1494  Ptr<Packet> packet;
1495  Address from;
1496 
1497  NS_LOG_FUNCTION (this << "IT is UDP sifting socket!");
1498  packet = socket->Recv (65535, 0);
1499 }
1500 
1502 {
1503 
1504  NS_LOG_FUNCTION (this << socket);
1505 
1506  if(m_master == true)
1507  NS_LOG_FUNCTION(this << "***MASTER***" );
1508  else
1509  NS_LOG_FUNCTION(this << "!!!SLAVE!!!");
1510 
1511  Ptr<Packet> packet;
1512  Address from;
1513 
1514  NS_LOG_FUNCTION (this << "IT is UDP sifting socket!");
1515  packet = socket->Recv (65535, 0);
1516 }
1517 
1519 {
1520 
1521  NS_LOG_FUNCTION (this << socket);
1522 
1523  if(m_master == true)
1524  NS_LOG_FUNCTION(this << "***MASTER***" );
1525  else
1526  NS_LOG_FUNCTION(this << "!!!SLAVE!!!");
1527 
1528  Ptr<Packet> packet;
1529  Address from;
1530 
1531  NS_LOG_FUNCTION (this << "IT is UDP sifting socket!");
1532  packet = socket->Recv (65535, 0);
1533 }
1534 
1536 {
1537 
1538  NS_LOG_FUNCTION (this << socket);
1539 
1540  if(m_master == true)
1541  NS_LOG_FUNCTION(this << "***MASTER***" );
1542  else
1543  NS_LOG_FUNCTION(this << "!!!SLAVE!!!");
1544 
1545  Ptr<Packet> packet;
1546  Address from;
1547 
1548  NS_LOG_FUNCTION (this << "IT is UDP sifting socket!");
1549  packet = socket->Recv (65535, 0);
1550 }
1551 
1553 {
1554 
1555  NS_LOG_FUNCTION (this << socket);
1556 
1557  if(m_master == true)
1558  NS_LOG_FUNCTION(this << "***MASTER***" );
1559  else
1560  NS_LOG_FUNCTION(this << "!!!SLAVE!!!");
1561 
1562  Ptr<Packet> packet;
1563  Address from;
1564 
1565  NS_LOG_FUNCTION (this << "IT is UDP sifting socket!");
1566  packet = socket->Recv (65535, 0);
1567 }
1569 {
1570 
1571  NS_LOG_FUNCTION (this << socket);
1572 
1573  if(m_master == true)
1574  NS_LOG_FUNCTION(this << "***MASTER***" );
1575  else
1576  NS_LOG_FUNCTION(this << "!!!SLAVE!!!");
1577 
1578  Ptr<Packet> packet;
1579  Address from;
1580 
1581  NS_LOG_FUNCTION (this << "IT is UDP sifting socket!");
1582  packet = socket->Recv (65535, 0);
1583 }
1585 {
1586 
1587  NS_LOG_FUNCTION (this << socket);
1588 
1589  if(m_master == true)
1590  NS_LOG_FUNCTION(this << "***MASTER***" );
1591  else
1592  NS_LOG_FUNCTION(this << "!!!SLAVE!!!");
1593 
1594  Ptr<Packet> packet;
1595  Address from;
1596 
1597  NS_LOG_FUNCTION (this << "IT is UDP sifting socket!");
1598  packet = socket->Recv (65535, 0);
1599 }
1600 
1602 {
1603 
1604  NS_LOG_FUNCTION (this << socket);
1605 
1606  if(m_master == true)
1607  NS_LOG_FUNCTION(this << "***MASTER***" );
1608  else
1609  NS_LOG_FUNCTION(this << "!!!SLAVE!!!");
1610 
1611  Ptr<Packet> packet;
1612  Address from;
1613 
1614  NS_LOG_FUNCTION (this << "IT is UDP sifting socket!");
1615  packet = socket->Recv (65535, 0);
1616 }
1617 
1619 
1620  NS_LOG_DEBUG(this << "\nProcessIncomingPacket!\t" << m_sendDevice->GetAddress() << "\t" << m_sinkDevice->GetAddress() );
1621 
1622  NS_LOG_DEBUG (this << packet << "\tPACKETID: " << packet->GetUid() << " of size: " << packet->GetSize() );
1623  m_packetNumber++;
1624 
1628  uint8_t *buffer = new uint8_t[packet->GetSize ()];
1629  packet->CopyData(buffer, packet->GetSize ());
1630  std::string s = std::string((char*)buffer);
1631  delete[] buffer;
1632 
1633  uint32_t packetValue;
1634  if(s.size() > 5){
1635 
1636  char labelChar[6];
1637  sscanf(s.c_str(), "%6[^;]:%d;", labelChar, &packetValue);
1638  std::string label (labelChar);
1639 
1640  NS_LOG_DEBUG (this << "\tLABEL:\t" << label << "\tPACKETVALUE:\t" << packetValue);
1641 
1642  if(label == "ADDKEY"){
1643  m_packetNumber = 0;
1644  m_sendKeyRateMessage = false;
1645 
1646  //add key to buffer
1647  if(GetNode ()->GetObject<QKDManager> () != 0){
1648 
1649  /*
1650  std::cout << Simulator::Now ().GetSeconds ()
1651  << "\t" << m_sendDevice->GetAddress()
1652  << "\t" << m_sinkDevice->GetAddress()
1653  << "\tLABEL:\t" << label
1654  << "\tPACKETVALUE:\t" << packetValue << "\n";
1655  */
1656 
1657  NS_LOG_DEBUG(this << "\t" << m_sendDevice->GetAddress() << "\t" << m_sinkDevice->GetAddress() );
1658  GetNode ()->GetObject<QKDManager> ()->AddNewKeyMaterial(m_sendDevice->GetAddress(), packetValue);
1659  //m_maxPackets = m_random->GetValue (m_maxPackets * 0.8, m_maxPackets * 1.2);
1660  }
1661 
1662  //prepare response
1663  if(m_master == false){
1665  PrepareOutput(label, packetValue);
1666  }else{
1667  SendData();
1668  }
1669 
1670  //Reset QKDPacketNumber
1671  m_qkdPacketNumber = 0;
1672  return;
1673  }
1674  }
1675 
1676  if(packetValue < m_maxPackets){
1677  m_packetNumber = packetValue + 1;
1678  }
1679 
1680  SendData();
1681 
1682 }
1683 
1685 {
1686  NS_LOG_FUNCTION (this << socket);
1687 }
1688 
1690 {
1691  NS_LOG_FUNCTION (this << socket);
1692 }
1693 
1695 {
1696  NS_LOG_FUNCTION (this << s << from);
1698  m_sinkSocketList.push_back (s);
1699 }
1700 
1702 {
1703  NS_LOG_FUNCTION (this << s << from);
1705  m_sinkSocketList.push_back (s);
1706 }
1707 
1709 {
1710  NS_LOG_FUNCTION (this << s << from);
1712  m_sinkSocketList.push_back (s);
1713 }
1714 
1716 {
1717  NS_LOG_FUNCTION (this << s << from);
1719  m_sinkSocketList.push_back (s);
1720 }
1721 
1723 {
1724  NS_LOG_FUNCTION (this << s << from);
1726  m_sinkSocketList.push_back (s);
1727 }
1728 
1730 {
1731  NS_LOG_FUNCTION (this << s << from);
1733  m_sinkSocketList.push_back (s);
1734 }
1735 
1737 {
1738  NS_LOG_FUNCTION (this << s << from);
1740  m_sinkSocketList.push_back (s);
1741 }
1743 {
1744  NS_LOG_FUNCTION (this << s << from);
1746  m_sinkSocketList.push_back (s);
1747 }
1749 {
1750  NS_LOG_FUNCTION (this << s << from);
1752  m_sinkSocketList.push_back (s);
1753 }
1755 {
1756  NS_LOG_FUNCTION (this << s << from);
1758  m_sinkSocketList.push_back (s);
1759 }
1761 {
1762  NS_LOG_FUNCTION (this << s << from);
1764  m_sinkSocketList.push_back (s);
1765 }
1767 {
1768  NS_LOG_FUNCTION (this << s << from);
1770  m_sinkSocketList.push_back (s);
1771 }
1772 
1774 {
1775  NS_LOG_FUNCTION (this << socket);
1776  NS_LOG_FUNCTION (this << "QKDChargingApplication Connection succeeded");
1777 
1778  if (m_sendSocket == socket || m_sinkSocket == socket){
1779  m_connected = true;
1780  }
1781 
1782  if(m_master) SendData();
1783 }
1784 
1786 {
1787  NS_LOG_FUNCTION (this << socket);
1788  NS_LOG_FUNCTION (this << "QKDChargingApplication AUTH Connection succeeded");
1789 
1790  if(m_master)
1792  /*
1793  if (m_connected && m_master && m_sendSocket_mthreshold == socket)
1794  SendData ();
1795  */
1796 }
1797 
1799 {
1800  NS_LOG_FUNCTION (this << socket);
1801  NS_LOG_FUNCTION (this << "QKDChargingApplication AUTH Connection succeeded");
1802  /*
1803  if (m_connected && m_master && m_sendSocket_auth == socket)
1804  SendData ();
1805  */
1806 }
1807 
1809 {
1810  NS_LOG_FUNCTION (this << socket);
1811  NS_LOG_FUNCTION (this << "QKDChargingApplication SIFTING Connection succeeded");
1812 }
1813 
1815 {
1816  NS_LOG_FUNCTION (this << socket);
1817  NS_LOG_FUNCTION (this << "QKDChargingApplication TEMP1 Connection succeeded");
1818 }
1819 
1821 {
1822  NS_LOG_FUNCTION (this << socket);
1823  NS_LOG_FUNCTION (this << "QKDChargingApplication TEMP2 Connection succeeded");
1824 }
1825 
1827 {
1828  NS_LOG_FUNCTION (this << socket);
1829  NS_LOG_FUNCTION (this << "QKDChargingApplication TEMP3 Connection succeeded");
1830 
1831  if (m_master)
1832  SendDataTemp3();
1833 }
1834 
1836 {
1837  NS_LOG_FUNCTION (this << socket);
1838  NS_LOG_FUNCTION (this << "QKDChargingApplication TEMP4 Connection succeeded");
1839 
1840  if (m_master)
1841  SendDataTemp4();
1842 }
1843 
1845 {
1846  NS_LOG_FUNCTION (this << socket);
1847  NS_LOG_FUNCTION (this << "QKDChargingApplication TEMP5 Connection succeeded");
1848 }
1849 
1851 {
1852  NS_LOG_FUNCTION (this << socket);
1853  NS_LOG_FUNCTION (this << "QKDChargingApplication TEMP6 Connection succeeded");
1854 }
1855 
1857 {
1858  NS_LOG_FUNCTION (this << socket);
1859  NS_LOG_FUNCTION (this << "QKDChargingApplication TEMP7 Connection succeeded");
1860 }
1861 
1863 {
1864  NS_LOG_FUNCTION (this << socket);
1865  NS_LOG_FUNCTION (this << "QKDChargingApplication TEMP8 Connection succeeded");
1866 }
1867 
1868 
1870 {
1871  NS_LOG_FUNCTION (this << socket);
1872  NS_LOG_FUNCTION (this << "QKDChargingApplication, Connection Failed");
1873 }
1874 
1876 {
1877  NS_LOG_FUNCTION (this << socket);
1878  NS_LOG_FUNCTION (this << "QKDChargingApplication, Connection Failed");
1879 }
1880 
1882 {
1883  NS_LOG_FUNCTION (this << socket);
1884  NS_LOG_FUNCTION (this << "QKDChargingApplication, Connection Failed");
1885 }
1886 
1888 {
1889  NS_LOG_FUNCTION (this << socket);
1890  NS_LOG_FUNCTION (this << "QKDChargingApplication, Connection Failed");
1891 }
1892 
1894 {
1895  NS_LOG_FUNCTION (this << socket);
1896  NS_LOG_FUNCTION (this << "QKDChargingApplication, Connection Failed");
1897 }
1898 
1900 {
1901  NS_LOG_FUNCTION (this << socket);
1902  NS_LOG_FUNCTION (this << "QKDChargingApplication, Connection Failed");
1903 }
1904 
1906 {
1907  NS_LOG_FUNCTION (this << socket);
1908  NS_LOG_FUNCTION (this << "QKDChargingApplication, Connection Failed");
1909 }
1910 
1912 {
1913  NS_LOG_FUNCTION (this << socket);
1914  NS_LOG_FUNCTION (this << "QKDChargingApplication, Connection Failed");
1915 }
1916 
1918 {
1919  NS_LOG_FUNCTION (this << socket);
1920  NS_LOG_FUNCTION (this << "QKDChargingApplication, Connection Failed");
1921 }
1922 
1924 {
1925  NS_LOG_FUNCTION (this << socket);
1926  NS_LOG_FUNCTION (this << "QKDChargingApplication, Connection Failed");
1927 }
1928 
1930 {
1931  NS_LOG_FUNCTION (this << socket);
1932  NS_LOG_FUNCTION (this << "QKDChargingApplication, Connection Failed");
1933 }
1934 
1936 {
1937  NS_LOG_FUNCTION (this << socket);
1938  NS_LOG_FUNCTION (this << "QKDChargingApplication, Connection Failed");
1939 }
1940 
1941 
1942 
1943 
1944 
1945 
1947 {
1948  NS_LOG_FUNCTION (this);
1949 }
1950 
1952 {
1953  NS_LOG_FUNCTION (this << oldRtt << newRtt);
1955 }
1956 
1958 {
1959  NS_LOG_FUNCTION (this);
1960  return m_lastAck;
1961 }
1962 
1963 } // Namespace ns3
void HandleAcceptMthreshold(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.
void HandleReadTemp4(Ptr< Socket > socket)
void SetTemp2Socket(std::string type, Ptr< Socket > socket)
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void SendSiftingPacket(void)
Send SIFTING packet to the socket.
void ConnectionSucceededMthreshold(Ptr< Socket > socket)
Ipv4Address GetIpv4(void) const
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetTemp6Socket(std::string type, Ptr< Socket > socket)
void SendPacket(Ptr< Packet > packet)
Send packet to the socket.
void HandleAcceptTemp7(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
virtual int ShutdownSend(void)=0
void HandlePeerClose(Ptr< Socket > socket)
Handle an connection close.
void ConnectionSucceededtemp5(Ptr< Socket > socket)
Address m_local_temp4
Local address to bind to.
uint64_t GetUid(void) const
Returns the packet&#39;s Uid.
Definition: packet.cc:390
void HandleReadTemp1(Ptr< Socket > socket)
void HandleReadMthreshold(Ptr< Socket > socket)
Handle a packet received by the application.
void HandleReadTemp6(Ptr< Socket > socket)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
virtual int ShutdownRecv(void)=0
void SetIpRecvTos(bool ipv4RecvTos)
Tells a socket to pass information about IP Type of Service up the stack.
Definition: socket.cc:465
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:831
void ConnectionSucceededtemp1(Ptr< Socket > socket)
void SetCloseCallbacks(Callback< void, Ptr< Socket > > normalClose, Callback< void, Ptr< Socket > > errorClose)
Detect socket recv() events such as graceful shutdown or error.
Definition: socket.cc:94
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event&#39;s associated function will not be invoked when it expires...
Definition: simulator.cc:346
Callback< R > MakeNullCallback(void)
Definition: callback.h:1635
void ConnectionFailedtemp6(Ptr< Socket > socket)
void HandleAcceptTemp1(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.
void SetSocket(std::string type, Ptr< Socket > socket, Ptr< NetDevice > dev, bool isMaster)
Ptr< Socket > m_sendSocket_mthreshold
Sockets used for mthreshold value exchange.
a polymophic address class
Definition: address.h:90
Ptr< Socket > m_sendSocket
IMITATE post-processing traffic (CASCADE, PRIVACY AMPLIFICATION and etc.
void SetTemp1Socket(std::string type, Ptr< Socket > socket)
EventId m_sendEvent
Event id of pending "send packet" event.
Ptr< const AttributeChecker > MakeDataRateChecker(void)
Definition: data-rate.cc:30
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Introspection did not find any typical Config paths.
Definition: qkd-manager.h:72
void DataSend(Ptr< Socket >, uint32_t)
Address m_local_auth
Local address to bind to.
void ConnectionFailedtemp3(Ptr< Socket > socket)
void HandleReadTemp7(Ptr< Socket > socket)
virtual int Listen(void)=0
Listen for incoming connections.
Class for representing data rates.
Definition: data-rate.h:88
void ConnectionSucceededtemp8(Ptr< Socket > socket)
virtual void DoDispose(void)
Destructor implementation.
void HandleRead(Ptr< Socket > socket)
Handle a packet received by the application.
Address m_local_temp5
Local address to bind to.
Ptr< const AttributeAccessor > MakeAddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: address.h:278
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1381
void HandleAccept(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.
void HandleAcceptTemp4(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.
The base class for all ns3 applications.
Definition: application.h:60
void ProcessIncomingPacket(Ptr< Packet > packet, Ptr< Socket > socket)
void PrepareOutput(std::string key, uint32_t value)
Hold an unsigned integer type.
Definition: uinteger.h:44
uint32_t m_totalRx
Total bytes received.
Ptr< Node > GetNode() const
Definition: application.cc:104
void StopApplication(void)
Application specific shutdown code.
AttributeValue implementation for TypeId.
Definition: type-id.h:608
Ptr< Socket > GetSinkSocket(void) const
Address m_local_temp6
Local address to bind to.
void HandleAcceptTemp8(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.
void ConnectionFailedtemp1(Ptr< Socket > socket)
void SetAuthSocket(std::string type, Ptr< Socket > socket)
Ptr< UniformRandomVariable > m_random
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
void ConnectionSucceededtemp3(Ptr< Socket > socket)
Address m_local_sifting
Local address to bind to.
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
Definition: socket.cc:128
void HandleReadTemp8(Ptr< Socket > socket)
void ConnectionFailedtemp8(Ptr< Socket > socket)
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
void SetTemp5Socket(std::string type, Ptr< Socket > socket)
void ConnectionSucceededAuth(Ptr< Socket > socket)
void HandleReadAuth(Ptr< Socket > socket)
Handle a packet received by the application.
void SendMthresholdPacket(void)
Send Mthreshold packet to the socket.
Address m_local_temp7
Local address to bind to.
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: data-rate.h:242
void ConnectionFailedAuth(Ptr< Socket > socket)
Address m_local_temp8
Local address to bind to.
void ConnectionFailedSifting(Ptr< Socket > socket)
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual void DoDispose(void)
Destructor implementation.
Definition: application.cc:83
uint32_t m_pktSize
Size of packets.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:293
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
void HandlePeerError(Ptr< Socket > socket)
Handle an connection error.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void ConnectionFailedtemp7(Ptr< Socket > socket)
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
void ConnectionFailed(Ptr< Socket > socket)
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
Address m_local_temp1
Local address to bind to.
std::list< Ptr< Socket > > GetAcceptedSockets(void) const
Ptr< Socket > m_sendSocket_auth
Sockets used for authentication.
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition: data-rate.cc:249
void SendAuthPacket(void)
Send AUTH packet to the socket.
Ptr< const AttributeChecker > MakeAddressChecker(void)
Definition: address.cc:172
void HandleAcceptAuth(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.
std::list< Ptr< Socket > > m_sinkSocketList
the accepted sockets
void SetTemp7Socket(std::string type, Ptr< Socket > socket)
void HandleReadTemp5(Ptr< Socket > socket)
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
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 ConnectionSucceeded(Ptr< Socket > socket)
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
Address m_local
Local address to bind to.
void ConnectionSucceededtemp7(Ptr< Socket > socket)
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
Definition: socket.cc:330
void SetDataSentCallback(Callback< void, Ptr< Socket >, uint32_t > dataSent)
Notify application when a packet has been sent from transport protocol (non-standard socket call) ...
Definition: socket.cc:114
void ConnectionFailedMthreshold(Ptr< Socket > socket)
void HandleAcceptTemp5(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.
void StartApplication(void)
Application specific startup code.
void HandleReadTemp2(Ptr< Socket > socket)
Ptr< const AttributeAccessor > MakeTypeIdAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: type-id.h:608
AttributeValue implementation for Address.
Definition: address.h:278
void SetTemp3Socket(std::string type, Ptr< Socket > socket)
Address m_local_mthreshold
Local address to bind to.
void SetTemp8Socket(std::string type, Ptr< Socket > socket)
void HandleReadSifting(Ptr< Socket > socket)
Handle a packet received by the application.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:262
AttributeValue implementation for DataRate.
Definition: data-rate.h:242
void ConnectionFailedtemp4(Ptr< Socket > socket)
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced Callback: received packets, source address.
void HandleReadTemp3(Ptr< Socket > socket)
TracedCallback< Ptr< const Packet > > m_txTrace
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:270
Ptr< Socket > GetSendSocket(void) const
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1007
Address m_local_temp3
Local address to bind to.
static TypeId GetTypeId(void)
Get the type ID.
void SetIpRecvTtl(bool ipv4RecvTtl)
Tells a socket to pass information about IP_TTL up the stack.
Definition: socket.cc:532
Address m_local_temp2
Local address to bind to.
void ConnectionSucceededtemp6(Ptr< Socket > socket)
void SetTemp4Socket(std::string type, Ptr< Socket > socket)
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Definition: packet.cc:378
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1023
uint16_t GetPort(void) const
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
void ConnectionSucceededtemp4(Ptr< Socket > socket)
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
void ConnectionSucceededtemp2(Ptr< Socket > socket)
void ConnectionFailedtemp5(Ptr< Socket > socket)
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
void RegisterAckTime(Time oldRtt, Time newRtt)
virtual int Close(void)=0
Close a socket.
void ConnectionSucceededSifting(Ptr< Socket > socket)
void ConnectionFailedtemp2(Ptr< Socket > socket)
Ptr< const AttributeChecker > MakeTypeIdChecker(void)
Definition: type-id.cc:1225
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
void SetIpTos(uint8_t ipTos)
Manually set IP Type of Service field.
Definition: socket.cc:443
a unique identifier for an interface.
Definition: type-id.h:58
DataRate m_cbrRate
Rate that data is generatedm_pktSize.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
void HandleAcceptTemp3(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.
void SetSiftingSocket(std::string type, Ptr< Socket > socket)
Ptr< Socket > m_sendSocket_sifting
Sockets used for SIFTING.
static bool IsMatchingType(const Address &address)
void HandleAcceptSifting(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.
void HandleAcceptTemp2(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
Definition: socket.cc:519
void HandleAcceptTemp6(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.