-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlte_mocn_4.cc
1052 lines (861 loc) · 41.9 KB
/
lte_mocn_4.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* "ASLTE" an extension of LENA it provides a MOCN
* implementation to test different kind of scenarios.
*
* Copyright (C) 2015 University Of the West of Scotland
*
* Authors
* -------
*
* Jose Maria Alcaraz-Calero [email protected]
* Ricardo Marco Alaez [email protected]
*
*
* "ASLTE" is free software: you can redistribute it
* and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms of this License (availables in this distribution)
*
* 1. It is Required the preservation of specified reasonable legal notices
* and author attributions in that material and in the Appropriate Legal
* Notices displayed by works containing it.
*
* 2. It is limited the use for publicity purposes of names of licensors or
* authors of the material.
*
* 3. It is Required indemnification of licensors and authors of that material
* by anyone who conveys the material (or modified versions of it) with
* contractual assumptions of liability to the recipient, for any liability
* that these contractual assumptions directly impose on those licensors
* and authors.
*
* 4. It is Prohibed misrepresentation of the origin of that material, and it is
* required that modified versions of such material be marked in reasonable
* ways as different from the original version.
*
* 5. It is Declined to grant rights under trademark law for use of some trade
* names, trademarks, or service marks.
*
*/
#include "ns3/as-lte-helper.h"
#include "ns3/as-p2p-epc-helper.h"
#include "ns3/epc-helper.h"
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/internet-module.h"
#include "ns3/mobility-module.h"
#include "ns3/lte-module.h"
#include "ns3/applications-module.h"
#include <ns3/config-store-module.h>
#include "ns3/flow-monitor-module.h"
#include <unistd.h>
#include "ns3/netanim-module.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("AS");
// GLOBAL VARS
int counteripaddrss = 1;
int countermacaddrss = 1;
int countervethinf = 0;
void CreateVeth(int index, char *VethNames[]) {
char *filename; // final file name
for(uint16_t i = 0 ; i < index ; i++){
filename = (char *)malloc(18);
sprintf(filename,"veth%i", countervethinf);
VethNames[i]=filename;
countervethinf++;
}
}
void CreateMACAddress(int index, char *MacAddrss[]) {
char *filename; // final file name
for(uint16_t i = 0 ; i < index ; i++){
filename = (char *)malloc(18);
int round = countermacaddrss /99;
if ( round <= 0)
sprintf(filename,"00:00:00:AA:AA:%i", countermacaddrss);
else
sprintf(filename,"00:00:00:AA:%i:%i", round+1, countermacaddrss % 99);
MacAddrss[i]=filename;
countermacaddrss++;
}
}
void CreateIpAddress(int index, char *IpAddrss[]) {
char *filename; // final file name
for(uint16_t i = 0 ; i < index ; i++){
filename = (char *)malloc(16);
int round = counteripaddrss /240;
if ( round <= 0)
sprintf(filename,"1.%i.0.0", counteripaddrss);
else{
sprintf(filename,"%i.%i.0.0", round+1, counteripaddrss % 240);
}
IpAddrss[i]=filename;
counteripaddrss++;
}
}
void CreateMask(uint16_t NumberOfNodes, const char *Mask[], const char* MaskType){
for(uint16_t i = 0 ; i < NumberOfNodes ; i++){
Mask[i]=MaskType;
}
}
void CreatePlmns(uint16_t NumberOfNodes, uint16_t plmnids[]){
for(uint16_t i = 0 ; i < NumberOfNodes ; i++){
plmnids[i]=i;
}
}
int main (int argc, char *argv[]) {
//LOCAL VARS
double distanceenbs;
// CONFIG PARAMS
double interPacketInterval = 10;
double simTime = 2.1;
int startTime = 0.1;
int incrementTime = 0.01;
double srsPeriodicity = 320;
uint64_t gbrDl = 20000000; //20Mbps 20-50
uint64_t gbrUl = 20000000; //20Mbps
uint64_t mbrDl = 50000000; //50Mbps
uint64_t mbrUl = 50000000; //50Mbps
std::string Scheduler = "ns3::PssFfMacScheduler";
std::string S1uLinkDataRate = "1Gb/s";
uint16_t S1uLinkDelay = 1; //ms
uint16_t S1uLinkMtu = 2000;
std::string X2LinkDataRate = "1Gb/s";
uint16_t X2LinkDelay = 0;
uint16_t X2LinkMtu = 2000;
bool shareInternet = false;
bool internaltraffic = false;
bool shownetwork = true;
bool logenabled = false;
double txpowerue = 20; //20 db
double txpowerenb = 50; //50 db
uint64_t LTEDataRateDl = 25; //25 Resource Block
uint64_t LTEDataRateUl = 25; //25 Resource Block
double distanceues = 1;
bool loadbalancing = true;
uint16_t NHenbNode = 1;
uint16_t plmns =4; // NUMBER OF OPERATOR
uint16_t remotehosts = 1; // NUMBER OF REMOTE HOSTS
uint16_t NenbNode = 1; // NUMBER OF ENBS (MIN = PLMNS)--> MIN=PLMNS????---->MIN = 1 if PLMNS<512 else PLMNS/512
uint16_t NenbConnections = 1 ; // (MIN = 1, MAX=PLMNS)
uint16_t NueNode = 512 ; // NUMBER OF UES
std::string FileName="output";
// CONST
char const *sgwtoremotehostmask = "255.255.0.0";
// Command line arguments
CommandLine cmd;
cmd.AddValue("operator", "Number of PLMNs", plmns);
cmd.AddValue("remoteHosts", "Number of Remote Hosts", remotehosts);
cmd.AddValue("enbs", "Number of eNodeBs", NenbNode);
cmd.AddValue("Henbs", "Number of Home-eNodeBs", NHenbNode);
cmd.AddValue("connections", "Number of connections per ENB", NenbConnections);
cmd.AddValue("ues", "Number of UEs", NueNode);
cmd.AddValue("simTime", "Total duration of the simulation [s])", simTime);
cmd.AddValue("distanceues", "Distance between UEs [m]", distanceues);
cmd.AddValue("interpacketinterval", "Applicaiton - Inter packet interval [ms])", interPacketInterval);
cmd.AddValue("startTime", "Time Where the First Applications Starts [s])", startTime);
cmd.AddValue("incrementTime", "Interval between Starting Applications [s])", incrementTime);
cmd.AddValue("Scheduler", "Scheduler to use", Scheduler);
cmd.AddValue("gbrDl", "Minimum guaranteed bit rate per EPS bearer (download)", gbrDl);
cmd.AddValue("gbrUl", "Minimum guaranteed bit rate per EPS bearer (upload)", gbrUl);
cmd.AddValue("mbrDl", "Maximum guaranteed bit rate per EPS bearer (download)", mbrDl);
cmd.AddValue("mbrUl", "Maximum guaranteed bit rate per EPS bearer (upload)", mbrUl);
cmd.AddValue("S1uLinkDataRate", "S1U Data Rate [10Gbs/s...] ", S1uLinkDataRate);
cmd.AddValue("S1uLinkDelay", "S1U Delay [ms]", S1uLinkDelay);
cmd.AddValue("S1uLinkMtu", "S1U MTU [bytes]", S1uLinkMtu);
cmd.AddValue("X2LinkDataRate", "X2 Data Rate [10Gbs/s]", X2LinkDataRate);
cmd.AddValue("X2LinkDelay", "X2 Delay [ms]", X2LinkDelay);
cmd.AddValue("X2LinkMtu", "X2 MTU [bytes]", X2LinkMtu);
cmd.AddValue("srsPeriodicity", "At least grather than the maximum number of UE per EnB. Max 320", srsPeriodicity);
cmd.AddValue("shareInternet", "Link Between SGWs)", shareInternet);
cmd.AddValue("logenabled", "Logging Information Enabled", logenabled);
cmd.AddValue("shownetwork", "Show Network Interfaces Logging Information", shownetwork);
cmd.AddValue("internaltraffic", "Internal Traffic Between Operators Enabled", internaltraffic);
cmd.AddValue("txpowerenb", "Tx Power ENBs [db]", txpowerenb);
cmd.AddValue("txpowerue", "Tx Power UWs [db]", txpowerue);
cmd.AddValue("LTEDataRateDl", "LTE Data Rate [RBs] (download)", LTEDataRateDl);
cmd.AddValue("LTEDataRateUl", "LTE Data Rate [RBs] (upload)", LTEDataRateUl);
cmd.AddValue("FileName", "Filename for the results", FileName);
// FIXED PARAM
GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl"));
Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (true));
Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (true));
Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (srsPeriodicity));
Config::SetDefault ("ns3::ASLteHelper::UseIdealRrc", BooleanValue (false)); //FALSE=RealRRC Activated - TRUE=NO-Activated
GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));
Config::SetDefault ("ns3::ASP2PEpcHelper::S1uLinkDataRate", DataRateValue (DataRate (S1uLinkDataRate)));
Config::SetDefault ("ns3::ASP2PEpcHelper::S1uLinkDelay", TimeValue (Seconds (S1uLinkDelay)));
Config::SetDefault ("ns3::ASP2PEpcHelper::S1uLinkMtu", UintegerValue (S1uLinkMtu));
Config::SetDefault ("ns3::ASP2PEpcHelper::X2LinkDataRate", DataRateValue (DataRate (X2LinkDataRate)));
Config::SetDefault ("ns3::ASP2PEpcHelper::X2LinkDelay", TimeValue (Seconds (X2LinkDelay)));
Config::SetDefault ("ns3::ASP2PEpcHelper::X2LinkMtu", UintegerValue (X2LinkMtu));
Config::SetDefault ("ns3::ASLteEnbNetDevice::UlBandwidth", UintegerValue (LTEDataRateUl));
Config::SetDefault ("ns3::ASLteEnbNetDevice::DlBandwidth", UintegerValue (LTEDataRateDl));
Config::SetDefault ("ns3::ASLteEnbPhy::TxPower", DoubleValue (txpowerenb));
Config::SetDefault ("ns3::LteUePhy::TxPower", DoubleValue (txpowerue));
ConfigStore inputConfig;
inputConfig.ConfigureDefaults();
cmd.Parse(argc, argv);
if (logenabled){
LogComponentEnable ("PacketSink", LOG_LEVEL_ALL);
LogComponentEnable ("ASLteEnbRrc", LOG_LEVEL_ALL);
LogComponentEnable ("LteUeRrc", LOG_LEVEL_INFO);
LogComponentEnable ("ASEpcEnbApplication", LOG_LEVEL_ALL);
LogComponentEnable ("ASEpcSgwPgwApplication", LOG_LEVEL_ALL);
}
int epo = NenbNode / plmns;//--Enbs Per Operator
if ( epo > 0)
NenbConnections = NenbConnections * NenbNode;
else
NenbConnections = NenbConnections * plmns;
remotehosts = remotehosts * plmns;
int cpe = NenbConnections / (NenbNode+NHenbNode);//--Connections Per Enb/Henb
int cpo = NenbConnections / plmns;//--Connections Per Operator
int upe = NueNode / (NenbNode+NHenbNode);//--Users Per Enb
int rpo = remotehosts / plmns;//--Remote Hosts Per Operator
int upo = NueNode / plmns;//--Users Per Operator
int upr = NueNode / remotehosts;///--Users Per Remote Host
std::cout << "CPE = " << cpe <<std::endl;
std::cout << "CPO = " << cpo <<std::endl;
std::cout << "UPE = " << upe <<std::endl;
std::cout << "RPO = " << rpo <<std::endl;
std::cout << "UPO = " << upo <<std::endl;
std::cout << "UPR = " << upr <<std::endl;
std::cout << "EPO = " << epo <<std::endl;
// ERROR CHECKING
if (remotehosts < plmns){
std::cout << "remotehosts < plmns - Currently not supported" << std::endl;
return 0;
}
if (remotehosts > NueNode){
std::cout << "remotehosts > NueNode - Currently not supported. It does not make sense." << std::endl;
return 0;
}
if (remotehosts > NueNode){
std::cout << "remotehosts > ues - Currently not supported" << std::endl;
return 0;
}
if ((NenbNode+NHenbNode) > NueNode){
std::cout << "enbs > ues - Currently not supported" << std::endl;
return 0;
}
if (epo > 0){
if (NenbConnections/NenbNode > NenbNode){
std::cout << "EPO>0, NenbConnections > plmns - Currently not supported" << std::endl;
return 0;
}
}else{
if (NenbConnections/plmns > plmns){
std::cout << "EPO<0, NenbConnections > NenbNode - Currently not supported" << std::endl;
return 0;
}
}
if (plmns > NueNode){
std::cout << "plmns > ues - Currently not supported" << std::endl;
return 0;
}
if (cpe > plmns){
std::cout << "cpe > plmns - Currently not supported" << std::endl;
return 0;
}
if (NenbNode <= 0 || NueNode <=0 || remotehosts <= 0 || plmns <= 0 || NenbConnections <= 0 ){
std::cout << "enbs, ues, remote hsots, plmns and connects cannot be 0." << std::endl;
return 0;
}
if (cpo <= 0){
std::cout << "cpo < 0 - Currently not supported" << std::endl;
return 0;
}
char *ueaddress[plmns];
char *epcipaddress[NenbConnections];
char *x2ipaddress[plmns];
char *remotehostaddress[remotehosts];
const char *remotehostmask[remotehosts];
const char *uemasknetwork[plmns];
char *sgwtosgwaddress[1]; // Used for Connecting Operators via Internet.
uint16_t plmnids[plmns];
char *sgwMacAddress[plmns];
char *sgweth[plmns];
char *enbeth[NenbNode+NHenbNode];
char* enbMacAddress[NenbNode+NHenbNode];
enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; // define Qci type
GbrQosInformation qos;
qos.gbrDl = gbrDl; // Downlink GBR
qos.gbrUl = gbrUl; // Uplink GBR
qos.mbrDl = mbrDl; // Downlink MBR
qos.mbrUl = mbrUl; // Uplink MBR
EpsBearer bearer (q, qos);
// INITIALIZATION
CreateIpAddress(plmns, ueaddress);
CreateIpAddress(NenbConnections, epcipaddress);
CreateIpAddress(remotehosts, remotehostaddress);
CreateIpAddress(1, sgwtosgwaddress);
CreateIpAddress(plmns, x2ipaddress);
CreateMask(remotehosts, remotehostmask, "255.255.0.0");
CreateMask(plmns, uemasknetwork, "255.255.0.0");
CreatePlmns(plmns, plmnids);
CreateMACAddress(plmns, sgwMacAddress);
CreateVeth(plmns,sgweth);
CreateVeth(NenbNode+NHenbNode,enbeth);
CreateMACAddress(NenbNode+NHenbNode, enbMacAddress);
NodeContainer remoteHostContainer;
NodeContainer enbNodes;
NodeContainer HenbNodes;//Node Container for Henbs
NodeContainer ueNodes;
Ipv4Address remoteHostAddr[remotehosts]; // ONE PER EACH PLMN
Ipv4InterfaceContainer ueIpIface[NueNode]; // ONE PER EACH UE
ASP2PEpcHelper::EnbInf enbInf[NenbNode+NHenbNode]; // ONE PER EACH ENB
Ipv4StaticRoutingHelper ipv4RoutingHelper;
InternetStackHelper internet;
Ptr<Node> pgw[plmns];
// INITIALIZATION--*****LTE HELPER CREATED HERE********
Ptr<ASLteHelper> lteHelper = CreateObject<ASLteHelper> ();
Ptr<ASP2PEpcHelper> epcHelper = CreateObject<ASP2PEpcHelper> ();
lteHelper->SetEpcHelper (epcHelper);
lteHelper->SetSchedulerType (Scheduler);
// CREATE OPERATORS (SGW + MME)
std::cout << "CREATING OPERATORS. N="<< plmns << std::endl;
for(uint16_t u = 0 ; u < plmns ; u++){
plmnids[u] = epcHelper->AddNewOperator(ueaddress[u], uemasknetwork[u], sgweth[u], sgwMacAddress[u], x2ipaddress[u]);
pgw[u] = epcHelper->GetPgwNode (plmnids[u]);
}
// CREATE REMOTE HOST
remoteHostContainer.Create (remotehosts);
internet.Install (remoteHostContainer);
// CREATION OF ENBs
enbNodes.Create(NenbNode);
//CREATION OF hENBS
HenbNodes.Create(NHenbNode);
// CREATION OF UEs
ueNodes.Create(NueNode);
// Install Mobility Model for ENBs and UEs
distanceenbs = upe * distanceues;
std::cout << "INSTALLING MOBILITY ..." << std::endl;
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
for (uint16_t i = 0; i < NenbNode+NHenbNode; i++){
positionAlloc->Add (Vector((distanceenbs * i) + (upe/2)*distanceues, 1, 0)); // ENB IN THE MIDDLE OF THE NODES ATTACHED START TOPOLOGY
std::cout << "ENB/HENB= " << i << " LOCATED AT ("<< (distanceenbs * i) + (upe/2) << "," << 1 << "," << 0 << ")" << std::endl;
}
int enb=0;
//int Henb=0;
int counter = 0;
//=================EDITED TILL HERE ON 3/9================
for ( uint16_t u = 0; u < NueNode;) {
Ptr<Node> ueNode = ueNodes.Get (u);
int interspace = 0;// This is for ??
for(uint16_t i = 0 ; i < upe ; i++){
if (plmns==1){
if(i >= 160){
positionAlloc->Add (Vector(counter, 5, 0));
std::cout << "UE= " << u << " LOCATED AT ("<< counter<< "," << 5 << "," << 0 << ")" <<std::endl;
counter++;
}
if(i < 160){
positionAlloc->Add (Vector(i, -10, 0));
std::cout << "UE= " << u << " LOCATED AT ("<< i<< "," << -5 << "," << 0 << ")" <<std::endl;
}
}
else{
positionAlloc->Add (Vector((distanceenbs * enb) + interspace, 0, 0));
std::cout << "UE= " << u << " LOCATED AT ("<< distanceenbs * enb + interspace<< "," << 0 << "," << 0 << ")" <<std::endl;
}
interspace = interspace + distanceues;
u++;
}
enb++;
}//End of For
MobilityHelper mobility;
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
mobility.SetPositionAllocator(positionAlloc);
mobility.Install(enbNodes);
mobility.Install(HenbNodes);//Mobility Model for Henbs
mobility.Install(ueNodes);
std::cout << "CONFIGURING ENBS. N="<< NenbNode << std::endl;
//==========================================================================================
//Code to enable CSG-Id-> The distinguishing factor to identify the node as a femtocell node
//as given in Lena-Dual-Stripe Example (approx around line:600)
//Added on 16/8
//==========================================================================================
/*lteHelper->SetEnbDeviceAttribute ("CsgId", UintegerValue (1));
lteHelper->SetEnbDeviceAttribute ("CsgIndication", BooleanValue (true));*/
//In order to assign different CSG-Ids to different devices, we need to first define a NetDeviceContainer
//And then add to the cotainer each Henb
//Similarly we need to configure homeUEs
NetDeviceContainer HenbLteDevs;
for(int henb_id = 1; henb_id <= NHenbNode; henb_id++){
lteHelper->SetEnbDeviceAttribute("CsgId",UintegerValue(henb_id));
lteHelper->SetEnbDeviceAttribute ("CsgIndication", BooleanValue (true));
NetDeviceContainer tempHenbDev = lteHelper->InstallEnbDevice(NodeContainer(HenbNodes.Get(henb_id-1)));
//lteHelper->InstallEnbDevice(NodeContainer) is the function definition of InstallEnbDevice
//It takes a NodeContainer and returns a NetDeviceContainer
//However, we can create a NodeContainer by calling the constructor NodeContainer(Ptr<Node> node) which is what
//we are trying to do
HenbLteDevs.Add(tempHenbDev);
}
//Added on 3/9
//==========================================================================================
NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNodes);
uint16_t tempu0;
for(uint16_t u = 0 ; u < NenbNode ; u++){
Ptr<Node> enbNode = enbNodes.Get (u);
enbInf[u] = epcHelper->AddNewEnodeB (enbNode, enbLteDevs.Get(u), enbLteDevs.Get(u)->GetObject<ASLteEnbNetDevice> ()->GetCellId ());
tempu0=u;
}
//DOING THE SAME FOR HENBs
for(uint16_t u = 0 ; u < NHenbNode ; u++){
Ptr<Node> HenbNode = HenbNodes.Get (u);
enbInf[tempu0 + u] = epcHelper->AddNewEnodeB (HenbNode, HenbLteDevs.Get(u), HenbLteDevs.Get(u)->GetObject<ASLteEnbNetDevice> ()->GetCellId ());
}
std::cout << "ASSIGNING ENBS TO OPERATORS. N CONECTIONS="<< NenbConnections << std::endl;
int conn =0;
if(epo > 0){
uint16_t tempu;
for(uint16_t u = 0 ; u < NenbNode ; ){
for(uint16_t c = 0 ; c < cpe ; c++){
std::cout << "EPO>0, ENB = " << u << " CONN ID - " << conn <<" TO OPERATOR = " << (u+c) % plmns << std::endl;
Ptr<Node> enbNode = enbNodes.Get (u);
epcHelper->AssignEnbToOperator(epcipaddress[conn], enbNode, enbLteDevs.Get(u), enbInf[u].lteSocket, enbLteDevs.Get(u)->GetObject<ASLteEnbNetDevice> ()->GetCellId (), enbeth[u], enbMacAddress[u], enbInf[u].enbApp, (u+c) % plmns);
conn++;
}
tempu = u++;
}
//Doing the same for Henbs
for(uint16_t u = 0 ; u < NHenbNode ; ){
for(uint16_t c = 0 ; c < cpe ; c++){
std::cout << "EPO>0, HENB = " << u << " CONN ID - " << conn <<" TO OPERATOR = " << (u+c) % plmns << std::endl;
Ptr<Node> HenbNode = HenbNodes.Get (u);
epcHelper->AssignEnbToOperator(epcipaddress[conn], HenbNode, HenbLteDevs.Get(u), enbInf[tempu + u].lteSocket, HenbLteDevs.Get(u)->GetObject<ASLteEnbNetDevice> ()->GetCellId (), enbeth[tempu + u], enbMacAddress[tempu + u], enbInf[tempu + u].enbApp, (tempu + u + c) % plmns);
conn++;
}
u++;
}
}else{
// epo < 0
int Henb_idx_overhead;
for(uint16_t p = 0 ; p < plmns ; ){
for(uint16_t c = 0 ; c < cpo ; c++){
int enb = p % NenbNode;
Henb_idx_overhead = enb;//Since enbInf is an array of size NenbNode+NHenbNode
std::cout << "EPO<0, ENB = " << enb << " CONN ID - " << conn <<" TO OPERATOR = " << (p+c) % plmns << std::endl;
Ptr<Node> enbNode = enbNodes.Get (enb);
epcHelper->AssignEnbToOperator(epcipaddress[conn], enbNode, enbLteDevs.Get(enb), enbInf[enb].lteSocket, enbLteDevs.Get(enb)->GetObject<ASLteEnbNetDevice> ()->GetCellId (), enbeth[enb], enbMacAddress[enb], enbInf[enb].enbApp, (p+c) % plmns);
conn++;
}
p++;
}
//Doing the same for Henbs
for(uint16_t p = 0 ; p < plmns ; ){
for(uint16_t c = 0 ; c < cpo ; c++){
int Henb = p % NHenbNode;
std::cout << "EPO<0, HENB = " << Henb << " CONN ID - " << conn <<" TO OPERATOR = " << (p+c) % plmns << std::endl;
Ptr<Node> HenbNode = HenbNodes.Get (Henb);
epcHelper->AssignEnbToOperator(epcipaddress[conn], HenbNode, HenbLteDevs.Get(enb), enbInf[Henb+ Henb_idx_overhead].lteSocket, enbLteDevs.Get(Henb)->GetObject<ASLteEnbNetDevice> ()->GetCellId (), enbeth[Henb_idx_overhead + enb], enbMacAddress[Henb_idx_overhead + enb], enbInf[Henb_idx_overhead + enb].enbApp, (p+c) % plmns);
conn++;
}
p++;
}
}
//
std::cout << "INSTALLING LTE IN UE. N="<< NueNode<< std::endl;
/*=====CONFIGURING UEs TO BE ABLE TO BE CONNECTED TO hENBs========
// set the home UE as a CSG member of the home eNodeBs
*/
//lteHelper->SetUeDeviceAttribute ("CsgId", UintegerValue (1));
/*
======================REFERNCE CODE SNIPPET FOR CONFIGURING UES=================
NetDeviceContainer ueLteDevs;
for(uint16_t u = 0 ; u < NueNode ; u++){
Ptr<Node> ueNode = ueNodes.Get (u);
ueLteDevs.Add (lteHelper->InstallSingleUeDevice (ueNode));
}
internet.Install (ueNodes);
*/
//Now we assign chunks of ues to each femtocell first, by assigning their csg. Then we proceed with the rest of the UEs normally as in the above snippet
NetDeviceContainer ueLteDevs;
uint16_t ue_count = 0;
for(uint16_t u = 1; u < NHenbNode; u++){
for(uint16_t u_henb =0 ; u_henb < upe; u_henb++){
lteHelper->SetUeDeviceAttribute("CsgId",UintegerValue(u));
ueLteDevs.Add(lteHelper->InstallSingleUeDevice(ueNodes.Get( ue_count+u )));
}
ue_count+= upe;
}
for(uint16_t u = ue_count; u < NueNode; u++){
Ptr<Node> ueNode = ueNodes.Get (u);
ueLteDevs.Add (lteHelper->InstallSingleUeDevice (ueNode));
}
internet.Install (ueNodes);
//====================ASSIGNING UES TO OPERATORS=========================
std::cout << "ASSING UE TO OPERATOR ..." << std::endl;
if ( epo > 0 ){
// EPO > 0
for ( uint16_t u = 0; u < NueNode; ) {
int iterator = 0;
if ( cpe < upe)
iterator = cpe;
else
iterator = upe;
for ( uint16_t c = 0; c < iterator; c++) { // Conns per ENB
int enb = u / upe;
int assignedOperator = (enb+c) % plmns;
Ptr<Node> ueNode = ueNodes.Get (u);
epcHelper->AddUePlmn (ueLteDevs.Get(u), assignedOperator);
Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
ueIpIface[u] = epcHelper->AssignUeIpv4Address (ueLteDevs.Get(u), assignedOperator);
ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (assignedOperator), 1);
std::cout << "EPO >0 UE = " << u << " TO OPERATOR = " << assignedOperator << std::endl;
std::cout << "EPO >0 ASSIGN IP AND DEFAULT GW TO UE = " << u << " FOR PLMN = " << assignedOperator << std::endl;
u++;
}
}
}else{
// EPO < 0
for ( uint16_t u = 0; u < NueNode; ) {
int iterator = 0;
if ( cpe < upe)
iterator = cpe;
else
iterator = upe;
for(uint16_t c = 0 ; c < iterator ; c++){
Ptr<Node> ueNode = ueNodes.Get (u);
int connused = c / cpo;
int internal = c % cpo;
int enbAttached = u / upe;// no need to change since upe is same for both Henbs and enbs
//Though ideally upHenb < upEnb
int assignedOperator = (enbAttached + internal+ (connused * (NenbNode + NHenbNode)) ) % plmns;
epcHelper->AddUePlmn (ueLteDevs.Get(u), assignedOperator);
Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
ueIpIface[u] = epcHelper->AssignUeIpv4Address (ueLteDevs.Get(u), assignedOperator);
ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (assignedOperator), 1);
std::cout << "EPO <0 UE = " << u << " TO OPERATOR = " << assignedOperator << std::endl;
std::cout << "EPO <0 ASSIGN IP AND DEFAULT GW TO UE = " << u << " FOR PLMN = " << assignedOperator << std::endl;
u++;
}
}
}
std::cout << "CONNECTING REMOTE HOSTS TO OPERATOR ..." << std::endl;
int plmn=0;
for(uint16_t u = 0 ; u < remotehosts ; ){
for(uint16_t i = 0 ; i < rpo ; i++){
Ptr<Node> remoteHost = remoteHostContainer.Get (u);
ASP2PEpcHelper::SgwAddresses sgwAddresses;
sgwAddresses = epcHelper->ConnectRemoteHostToSGW(pgw[plmn], remoteHost, remotehostaddress[u], remotehostmask[u]);
remoteHostAddr[u] = sgwAddresses.sgwDestinationAddr;
// Route by default to reach REmote Host
std::cout << " REMOTE HOST = " << u << " TO OPERATOR = " << plmn << " ADDRESS " << remoteHostAddr[u] << " DEFAULT GW IP " << sgwAddresses.sgwSourceAddr << std::endl;
Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
remoteHostStaticRouting->SetDefaultRoute (sgwAddresses.sgwSourceAddr, 1);
u++;
}
plmn++;
}
//We need to change this part to ensure that UEs with compatible CSGs are connected with respective HeNBs
std::cout << "ATTACH UE TO ENBS ..." << std::endl;
enb=0;
for ( uint16_t u = 0; u < NueNode;) {
Ptr<Node> ueNode = ueNodes.Get (u);
for(uint16_t i = 0 ; i < upe ; i++){
std::cout << " ATTACH UE NUMBER = " << u << " TO ENB = " << enb << std::endl;
epcHelper->Attach (ueLteDevs.Get(u), enbLteDevs.Get (enb));
u++;
}
enb++;
}
int henb_ptr = 0;
for(uint16_t u = 0; u< upe*NHenbNode;){
for(uint16_t u_henb = 0; u_henb < upe;){
epcHelper->Attach(ueLteDevs.Get(u),HenbLteDevs.Get(henb_ptr));
u_henb++;
u = u_henb;
}
henb_ptr++;
}
enb=0;
for ( uint16_t u = upe*NHenbNode; u < NueNode;) {
Ptr<Node> ueNode = ueNodes.Get (u);
for(uint16_t i = 0 ; i < upe ; i++){
std::cout << " ATTACH UE NUMBER = " << u << " TO ENB = " << enb << std::endl;
epcHelper->Attach (ueLteDevs.Get(u), enbLteDevs.Get (enb));
u++;
}
enb++;
}
if (shareInternet){
Ipv4Address sgwToSgwAddresses[plmns][plmns];
epcHelper->ConfigureSGWToSGWNetworkAddress(sgwtosgwaddress[0], sgwtoremotehostmask);
std::cout << "CONNECTING SGWS TOGETHER ..." << std::endl;
for(uint16_t u = 0 ; u < plmns-1 ; u++){
Ptr<Node> pgwSource = pgw[u];
for(uint16_t i = u+1 ; i < plmns ; i++){
Ptr<Node> pgwDestination = pgw[i];
ASP2PEpcHelper::SgwAddresses sgwAddresses;
sgwAddresses = epcHelper->ConnectSGWToSGW(pgwSource, pgwDestination);
sgwToSgwAddresses[u][i] = sgwAddresses.sgwDestinationAddr;
sgwToSgwAddresses[i][u] = sgwAddresses.sgwSourceAddr;
}
}
std::cout << "CONFIGURE STATIC ROUTING FOR SGWS ..." << std::endl;
for(uint16_t u = 0 ; u < plmns ; u++){
Ptr<Node> pgwSource = pgw[u];
for(uint16_t i = 0 ; i < plmns ; i++){
Ptr<Node> pgwDestination = pgw[i];
if ( u != i ){
Ptr<Ipv4StaticRouting> sgwSourceStaticRouting = ipv4RoutingHelper.GetStaticRouting (pgwSource->GetObject<Ipv4> ());
int iface = epcHelper->GetInterfaceIndexByIPAddress(pgwSource,sgwToSgwAddresses[i][u]);
if (iface == -1){
iface = epcHelper->GetInterfaceIndexByIPAddress(pgwSource,sgwToSgwAddresses[u][i]);
if (iface != -1){
sgwSourceStaticRouting->AddNetworkRouteTo (Ipv4Address (ueaddress[i % plmns]), Ipv4Mask (uemasknetwork[i % plmns]),sgwToSgwAddresses[i][u], iface);
}else{
std::cout << "SOMETHING IS WRONG IN THE SGW STATIC ROUTES ...." << std::endl;
}
}else{
sgwSourceStaticRouting->AddNetworkRouteTo (Ipv4Address (ueaddress[i % plmns]), Ipv4Mask (uemasknetwork[i % plmns]),sgwToSgwAddresses[u][i], iface);
}
}
}
}
}
lteHelper->ActivateDedicatedEpsBearer (ueLteDevs, bearer, EpcTft::Default ());
if (shownetwork){
///// DEBUG DE EVERY INTERFACES
std::cout << " /////////////////// START IP INTERFACES AND ROUTES ///////////////////" << std::endl;
for(uint16_t u = 0 ; u < plmns ; u++){
Ptr<Node> netdevice = epcHelper->GetPgwNode (u);
std::cout << "SGW FOR PLMN " << u << " has " << netdevice->GetObject<Ipv4> ()->GetNInterfaces () << " INTERFACES" << " NODE ID= " << netdevice->GetId() << std::endl;
for(uint16_t i = 0 ; i < netdevice->GetObject<Ipv4> ()->GetNInterfaces () ; i++){
for(uint16_t j = 0 ; j < netdevice->GetObject<Ipv4> ()->GetNAddresses (i) ; j++){
Ipv4Address address = netdevice->GetObject<Ipv4> ()->GetAddress (i, j).GetLocal();
Ipv4Mask mask = netdevice->GetObject<Ipv4> ()->GetAddress (i, j).GetMask();
std::cout << "INTERFACE =" << i << " : ADDRESS=" << j << " : IP=" << address << " MASK=" << mask << std::endl;
}
}
Ptr<Ipv4StaticRouting> netdeviceStaticRouting = ipv4RoutingHelper.GetStaticRouting (netdevice->GetObject<Ipv4> ());
for(uint16_t i = 0 ; i < netdeviceStaticRouting->GetNRoutes () ; i++){
std::cout << "GW N= " << u << " ROUTE N="<< i << " ROUTE=" << netdeviceStaticRouting->GetRoute (i) << std::endl;
}
}
for(uint16_t u = 0 ; u < remotehosts ; u++){
Ptr<Node> netdevice = remoteHostContainer.Get (u);
std::cout << "REMOTE HOST N=" << u << " has " << netdevice->GetObject<Ipv4> ()->GetNInterfaces () << " INTERFACES" << " NODE ID= " << netdevice->GetId() << std::endl;
for(uint16_t i = 0 ; i < netdevice->GetObject<Ipv4> ()->GetNInterfaces () ; i++){
for(uint16_t j = 0 ; j < netdevice->GetObject<Ipv4> ()->GetNAddresses (i) ; j++){
Ipv4Address address = netdevice->GetObject<Ipv4> ()->GetAddress (i, j).GetLocal();
Ipv4Mask mask = netdevice->GetObject<Ipv4> ()->GetAddress (i, j).GetMask();
std::cout << "INTERFACE =" << i << " : ADDRESS=" << j << " : IP=" << address << " MASK=" << mask << std::endl;
}
}
Ptr<Ipv4StaticRouting> netdeviceStaticRouting = ipv4RoutingHelper.GetStaticRouting (netdevice->GetObject<Ipv4> ());
for(uint16_t i = 0 ; i < netdeviceStaticRouting->GetNRoutes () ; i++){
std::cout << "REMOTEHOST N= " << u << " ROUTE N="<< i << " ROUTE=" << netdeviceStaticRouting->GetRoute (i) << std::endl;
}
}
for(uint16_t u = 0 ; u < NenbNode ; u++){
Ptr<Node> netdevice = enbNodes.Get (u);
std::cout << "ENB N= " << u << " has " << netdevice->GetObject<Ipv4> ()->GetNInterfaces () << " INTERFACES" << " NODE ID= " << netdevice->GetId() << std::endl;
for(uint16_t i = 0 ; i < netdevice->GetObject<Ipv4> ()->GetNInterfaces () ; i++){
for(uint16_t j = 0 ; j < netdevice->GetObject<Ipv4> ()->GetNAddresses (i) ; j++){
Ipv4Address address = netdevice->GetObject<Ipv4> ()->GetAddress (i, j).GetLocal();
Ipv4Mask mask = netdevice->GetObject<Ipv4> ()->GetAddress (i, j).GetMask();
std::cout << "INTERFACE =" << i << " : ADDRESS=" << j << " : IP=" << address << " MASK=" << mask << std::endl;
}
}
Ptr<Ipv4StaticRouting> netdeviceStaticRouting = ipv4RoutingHelper.GetStaticRouting (netdevice->GetObject<Ipv4> ());
for(uint16_t i = 0 ; i < netdeviceStaticRouting->GetNRoutes () ; i++){
std::cout << "ENB N= " << u << " ROUTE N="<< i << " ROUTE=" << netdeviceStaticRouting->GetRoute (i) << std::endl;
}
}
//We Copy the same as above for HENB
for(uint16_t u = 0 ; u < NHenbNode ; u++){
Ptr<Node> netdevice = HenbNodes.Get (u);
std::cout << "HENB N= " << u << " has " << netdevice->GetObject<Ipv4> ()->GetNInterfaces () << " INTERFACES" << " NODE ID= " << netdevice->GetId() << std::endl;
for(uint16_t i = 0 ; i < netdevice->GetObject<Ipv4> ()->GetNInterfaces () ; i++){
for(uint16_t j = 0 ; j < netdevice->GetObject<Ipv4> ()->GetNAddresses (i) ; j++){
Ipv4Address address = netdevice->GetObject<Ipv4> ()->GetAddress (i, j).GetLocal();
Ipv4Mask mask = netdevice->GetObject<Ipv4> ()->GetAddress (i, j).GetMask();
std::cout << "INTERFACE =" << i << " : ADDRESS=" << j << " : IP=" << address << " MASK=" << mask << std::endl;
}
}
Ptr<Ipv4StaticRouting> netdeviceStaticRouting = ipv4RoutingHelper.GetStaticRouting (netdevice->GetObject<Ipv4> ());
for(uint16_t i = 0 ; i < netdeviceStaticRouting->GetNRoutes () ; i++){
std::cout << "ENB N= " << u << " ROUTE N="<< i << " ROUTE=" << netdeviceStaticRouting->GetRoute (i) << std::endl;
}
}
//===========================END OF HHENB COPY===========================
for ( uint16_t u = 0; u < NueNode; u++) {
Ptr<Node> netdevice = ueNodes.Get (u);
std::cout << "UE N= " << u << " has " << netdevice->GetObject<Ipv4> ()->GetNInterfaces () << " INTERFACES" << " NODE ID= " << netdevice->GetId() << std::endl;
for(uint16_t i = 0 ; i < netdevice->GetObject<Ipv4> ()->GetNInterfaces () ; i++){
for(uint16_t j = 0 ; j < netdevice->GetObject<Ipv4> ()->GetNAddresses (i) ; j++){
Ipv4Address address = netdevice->GetObject<Ipv4> ()->GetAddress (i, j).GetLocal();
Ipv4Mask mask = netdevice->GetObject<Ipv4> ()->GetAddress (i, j).GetMask();
std::cout << "INTERFACE =" << i << " : ADDRESS=" << j << " : IP=" << address << " MASK=" << mask << std::endl;
}
}
Ptr<Ipv4StaticRouting> netdeviceStaticRouting = ipv4RoutingHelper.GetStaticRouting (netdevice->GetObject<Ipv4> ());
for(uint16_t i = 0 ; i < netdeviceStaticRouting->GetNRoutes () ; i++){
std::cout << "UE N= " << u << " ROUTE N="<< i << " ROUTE=" << netdeviceStaticRouting->GetRoute (i) << std::endl;
}
}
std::cout << " /////////////////// END IP INTERFACES ///////////////////" << std::endl;
}
std::cout << "INSTALLING APPLICATIONS ..." << std::endl;
// Install and start applications on UEs and remote host
uint16_t dlPort = 1234;
uint16_t ulPort = 2000;
uint16_t otherPort = 3000;
ApplicationContainer clientApps[NueNode];
ApplicationContainer serverApps[NueNode];
int balance[plmns];
for ( int i = 0 ; i < plmns ; i++){
balance[i] = 0;
}
for ( uint16_t u = 0; u < NueNode; u++) {
int rhdestination = 0;
int uedestination = 0;
int iterator = 0;
if ( cpe < upe)
iterator = cpe;
else
iterator = upe;
if ( epo > 0 ){
// EPO > 0
int ceb = u % iterator;// what is ceb?
int connused = ceb / cpe;// why is the connection used = ceb/cpe
int internal = ceb % cpe;//why is the connection used = ceb%cpe
int enb = u / upe; //why
int assignedOperator = (enb + internal+ (connused * (NenbNode+NHenbNode)) ) % plmns;
Ptr<Node> ueNode = ueNodes.Get (u);
rhdestination = assignedOperator*rpo;
if (loadbalancing){
rhdestination = rhdestination + (balance[assignedOperator] % rpo);
balance[assignedOperator]=balance[assignedOperator]+1;
}
}else{
// EPO < 0
int ceb = u % iterator;
int connused = ceb / cpo;
int internal = ceb % cpo;
int enb = u / upe;
int assignedOperator = (enb + internal+ (connused * NenbNode) ) % plmns;
Ptr<Node> ueNode = ueNodes.Get (u);
rhdestination =assignedOperator*rpo;
if (loadbalancing){
rhdestination = rhdestination + (balance[assignedOperator] % rpo);
balance[assignedOperator]=balance[assignedOperator]+1;
}
}
++ulPort;
++otherPort;
PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort));
serverApps[u].Add (dlPacketSinkHelper.Install (ueNodes.Get(u)));
serverApps[u].Add (ulPacketSinkHelper.Install (remoteHostContainer.Get(rhdestination)));
std::cout << " APPS: UE <-> REMOTE HOST " << ueIpIface[u].GetAddress (0) << " <-> " << remoteHostAddr[rhdestination]<< " UE ID " << u << "<-> RH ID="<< rhdestination << std::endl;
UdpClientHelper dlClient (ueIpIface[u].GetAddress (0), dlPort);
dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds(interPacketInterval)));
dlClient.SetAttribute ("MaxPackets", UintegerValue(1000000));
UdpClientHelper ulClient (remoteHostAddr[rhdestination], ulPort);
ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds(interPacketInterval)));
ulClient.SetAttribute ("MaxPackets", UintegerValue(1000000));
clientApps[u].Add (dlClient.Install (remoteHostContainer.Get(rhdestination)));
clientApps[u].Add (ulClient.Install (ueNodes.Get(u)));
serverApps[u].Start (Seconds (startTime));
clientApps[u].Start (Seconds (startTime));
if (internaltraffic){
PacketSinkHelper packetSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), otherPort));
serverApps[u].Add (packetSinkHelper.Install (ueNodes.Get(u)));
UdpClientHelper client (ueIpIface[u].GetAddress (0), otherPort);
client.SetAttribute ("Interval", TimeValue (MilliSeconds(interPacketInterval)));
client.SetAttribute ("MaxPackets", UintegerValue(1000000));
std::cout << " APPS: UE <-> UE " << ueIpIface[u].GetAddress (0) << " <-> " << ueIpIface[uedestination].GetAddress (0) << std::endl;
clientApps[u].Add (client.Install (ueNodes.Get(uedestination)));
}
startTime=startTime+incrementTime;
}
// Install FlowMonitor on all nodes
FlowMonitorHelper flowmon;
Ptr<FlowMonitor> monitor = flowmon.InstallAll ();
// lteHelper->EnableTraces ();
AnimationInterface anim("lte_mocn_1.xml");
/* for (uint16_t i = 0; i < NenbNode; i++){
anim.SetConstantPosition(enbNodes.Get(i),(distanceenbs * i) + (upe/2),0);
}
enb=0;
counter = 0;
for ( uint16_t u = 0; u < NueNode;) {
Ptr<Node> ueNode = ueNodes.Get (u);
int interspace = 0;
for(uint16_t i = 0 ; i < upe ; i++){
if (plmns==1){
if(i >= 160){
//positionAlloc->Add (Vector(counter, 5, 0));
//std::cout << "UE= " << u << " LOCATED AT ("<< counter<< "," << 5 << "," << 0 << ")" <<std::endl;
anim.SetConstantPosition(enbNodes.Get(i),counter,5);
counter++;
}
if(i < 160){
//positionAlloc->Add (Vector(i, -10, 0));
//std::cout << "UE= " << u << " LOCATED AT ("<< i<< "," << -5 << "," << 0 << ")" <<std::endl;
anim.SetConstantPosition(enbNodes.Get(i),counter,-5);
}
}
else{
//positionAlloc->Add (Vector((distanceenbs * enb) + interspace, 0, 0));
//std::cout << "UE= " << u << " LOCATED AT ("<< distanceenbs * enb + interspace<< "," << 0 << "," << 0 << ")" <<std::endl;
anim.SetConstantPosition(enbNodes.Get(i),distanceenbs * enb + interspace,0);
}
interspace = interspace + distanceues;
u++;