-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathapp.js
1098 lines (961 loc) · 38.2 KB
/
app.js
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
/*
* 4G Speed Calculator
* Developed by AbsoluteDouble
* Special thanks to Peter Clarke for German Translations
* GitHub: https://github.com/jake-cryptic/4g-speed
* Website: https://absolutedouble.co.uk/
*/
// Polyfill: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Polyfill
if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > this.length) {
return false;
} else {
return this.indexOf(search, start) !== -1;
}
};
}
if (!window.location.host.includes("absolutedouble.co.uk")){
console.log("\n4G Theoretical Throughput Calculator");
console.log("Developed by AbsoluteDouble");
console.log("Website: https://absolutedouble.co.uk");
console.log("Github: https://github.com/jake-cryptic/4g-speed");
}
// For more info on the LAA band, see here: https://en.wikipedia.org/wiki/LTE_in_unlicensed_spectrum
// Fallback for jQuery
if (!window.jQuery){
var j = document.createElement("script");
j.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js";
j.type = "text/javascript";
document.head.append(j);
}
// Universal configurations
var followSpec = true; // Choose if client follows LTE Specification
var base = .5; // Base number for multipliers
var mod = [.5,1,1.5,1.958]; // Modulation Multiplier
var mimo = [1,2,4]; // MiMo Multiplier
var carriers = 0; // Number of LTE Carriers (CA)
var primary = 0; // Primary carrier ID
var uploadcarriers = []; // Array of IDs of uplink carriers
var vBandwidths = [1.4,3,5,10,15,20]; // List of valid bandwidths
var strings = {
"en":{
"numeric.separators":[",","."],
"alert.selband":"Please select a band",
"alert.selfirst":"Select a band first",
"alert.seltext":"Select a band",
"alert.selconf":"Please enter TDD Configuration",
"alert.laaband":"LAA Band is not supported yet",
"alert.remprim":"Can't remove the primary carrier",
"label.tddcpl":"Cyclic Prefix Length",
"label.tddcnf":"TDD Configuration",
"label.tddssf":"Special Subframe Configuration",
"label.band":"Band",
"label.config":"Config",
"label.mimo":"MiMo",
"label.options":"Options",
"label.earfcn":"EARFCN",
"label.resblocks":"Resource Blocks",
"label.bandwidth":"Bandwidth",
"label.mod":"Modulation",
"label.dlmod":"Downlink Modulation",
"label.ulmod":"Uplink Modulation",
"label.aggupl":"Aggregate Uplink",
"label.deaggupl":"Deaggregate Uplink",
"label.remca":"Remove Carrier",
"label.setprim":"Set as Primary",
"label.sdl":"Downlink (SDL)",
"label.sul":"Uplink (SUL)",
"msg.nofddopts":"No extra options for FDD bands",
"msg.nobandopts":"No options for this band type",
"ux.title":"4G Theoretical Throughput Calculator",
"ux.exitsetting":"Close Settings",
"ux.settings":"Settings",
"ux.reloadwarn":"Page will reload after setting change.",
"ux.language":"Update Language",
"ux.adherespec":"Adhere to 3gpp specification for LTE",
"ux.addca":"Add Carrier"
},
"fr":{
"numeric.separators":[".",","],
"alert.selband":"Merci de choisir une bande",
"alert.selfirst":"Sélectionnez d’abord une bande",
"alert.seltext":"Sélectionnez une bande",
"alert.selconf":"Merci d’entrer le type de configuration TDD",
"alert.laaband":"La bande de fréquence LAA (??) n’est pas encore supportée",
"alert.remprim":"Vous ne pouvez pas supprimer la porteuse principal (pas sur)",
"label.tddcpl":"Cyclic préfix Length",
"label.tddcnf":"Configuration TDD",
"label.tddssf":"Special Subframe Configuration",
"label.band":"Bande",
"label.config":"Config",
"label.mimo":"MiMo",
"label.options":"Options",
"label.earfcn":"EARFCN",
"label.bandwidth":"Bande passante",
"label.resblocks":"Blocs de ressources",
"label.mod":"Modulation de Fréquence",
"label.dlmod":"Télécharger la modulation",
"label.ulmod":"Modulation de téléchargement",
"label.aggupl":"Agrégat téléverser",
"label.deaggupl":"Désagréger téléverser",
"label.remca":"Retirer la porteuse",
"label.setprim":"Définir comme porteuse principale",
"label.sdl":"Télécharger (SDL)",
"label.sul":"Téléverser (SUL)",
"msg.nofddopts":"Aucune option disponible en FDD",
"msg.nobandopts":"Aucune option pour ce type de porteuse",
"ux.title":"Calculateur de débit théorique 4G",
"ux.exitsetting":"Fermer préférences",
"ux.settings":"Préférences",
"ux.reloadwarn":"Page will reload after setting change.",
"ux.language":"Choisir langue",
"ux.adherespec":"Adhérer aux spécifications 3GPP pour LTE",
"ux.addca":"Ajouter une porteuse"
},
"de":{
"numeric.separators":[".",","],
"alert.selband":"Bitte wählen Sie ein Frequenzband",
"alert.selfirst":"Bitte wählen Sie zuerst ein Frequenzband",
"alert.seltext":"Bitte wählen Sie ein Frequenzband",
"alert.selconf":"Bitte wählen Sie eine Konfiguration TDD",
"alert.laaband":"LAA wird noch nicht unterstützt ",
"alert.remprim":"Der primäre Träger kann nicht entfernt werden",
"label.tddcpl":"Zyklische Präfixlänge",
"label.tddcnf":"Konfiguration TDD ",
"label.tddssf":"Spezielle Subframe-Konfiguration",
"label.band":"Frequenzband",
"label.config":"Config",
"label.mimo":"MiMo",
"label.options":"Optionen",
"label.earfcn":"EARFCN",
"label.bandwidth":"Bandbreite",
"label.resblocks":"Ressourcenblöcke",
"label.mod":"Modulation",
"label.dlmod":"Downlink Modulation",
"label.ulmod":"Uplink Modulation",
"label.aggupl":"Aggregat Uplink",
"label.deaggupl":"Disaggregieren Uplink",
"label.remca":"Träger entfernen" ,
"label.setprim":"Als primär festlegen",
"label.sdl":"Downlink (SDL)",
"label.sul":"Uplink (SUL)",
"msg.nofddopts":"Keine anderen Optionen zur Auswahl für FDD",
"msg.nobandopts":"Keine Optionen für den ausgewählten Bandtyp",
"ux.title":"4G Theoretische Throughput-Rechner",
"ux.exitsetting":"Close Settings",
"ux.settings":"Settings",
"ux.reloadwarn":"Page will reload after setting change.",
"ux.language":"Sprache wählen",
"ux.adherespec":"Adhere to 3gpp specification for LTE",
"ux.addca":"Träger hinzufügen"
}
};
var loadSettings = function(){
// Set default values
window._l = strings["en"];
window.strict3gpp = true;
// Check for cookies library
if (typeof Cookies !== "function") return;
// Get setting information from cookies
var l = Cookies.get("language");
var s = Cookies.get("strict3gpp");
// If no setting cookie set, set one
if (l === undefined){
Cookies.set("language","en");
}
if (s === undefined){
Cookies.set("strict3gpp","true");
}
// If language is valid then use it
if (strings[l] !== undefined){
window._l = strings[l];
}
window.strict3gpp = (s === "false" ? false : true);
console.log("\n",l,s,"\n");
};
// TDD Specific Configurations
var defaultTddBase = .0005; // 5ms
// Extended CP rarely used in UK
var tcpl = {
"normal":7,
"extended":6
};
var tddmod = [2,4,6,8];
var tscprb = 12; // Sub carriers per resource block
var tconf = {
// tconf[CONFIG][D/S/U]
0:[2,2,6],
1:[4,2,4],
2:[6,2,2],
3:[6,1,3],
4:[7,1,2],
5:[8,1,1],
6:[3,2,5]
};
var ssubconf = {
"normal":{
// ssubconf[CONFIG][DwPTS/GP/UpPTS]
0:[3,10,1],
1:[9,4,1],
2:[10,3,1],
3:[11,2,1],
4:[12,1,1],
5:[3,9,2],
6:[9,3,2],
7:[10,2,2],
8:[11,1,2]
},
"extended":{
// ssubconf[CONFIG][DwPTS/GP/UpPTS]
0:[3,8,1],
1:[8,3,1],
2:[9,2,1],
3:[10,1,1],
4:[3,7,2],
5:[8,2,2],
6:[9,1,2],
7:[0,0,0],
8:[0,0,0]
}
};
/* \\ This is the big table of LTE data //
type = Has to be FDD/TDD/SDL, this is used to determine calculation
frequency = If this isn't set the band won't show in the selector
range = This is what's shown to the user, not used for anything else
bandwidths = These show up in the selector, stops users setting 20MHz bandwidth when the band is only 10MHz wide
earfcn = Low and high values of center frequency, used to determine band
*/
var lteBandData = {
1:{"type":"FDD","frequency":"2100","range":["1920-1980","2110-2170"],"bandwidths":[5,10,15,20],"earfcn":[0,599],"rel":8},
2:{"type":"FDD","frequency":"1900","range":["1850-1910","1930-1990"],"bandwidths":[1.4,3,5,10,15,20],"earfcn":[600,1199],"rel":8},
3:{"type":"FDD","frequency":"1800","range":["1710-1785","1805-1880"],"bandwidths":[1.4,3,5,10,15,20],"earfcn":[1200,1949],"rel":8},
4:{"type":"FDD","frequency":"1700","range":["1710-1755","2110-2155"],"bandwidths":[1.4,3,5,10,15,20],"earfcn":[1950,2399],"rel":8},
5:{"type":"FDD","frequency":"850","range":["824-849","869-894"],"bandwidths":[1.4,3,5,10],"earfcn":[2400,2649],"rel":8},
//6:{"type":"FDD","frequency":"850","range":["830-840","875-885"],"bandwidths":[5,10],"rel":8}, // UMTS Only Band
7:{"type":"FDD","frequency":"2600","range":["2500-2570","2620-2690"],"bandwidths":[5,10,15,20],"earfcn":[2750,3449],"rel":8},
8:{"type":"FDD","frequency":"900","range":["880-915","925-960"],"bandwidths":[1.4,3,5,10],"earfcn":[3450,3799],"rel":8},
9:{"type":"FDD","frequency":"1800","range":["1749.9-1784.9","1844.9-1879.9"],"bandwidths":[5,10,15,20],"earfcn":[3800,4149],"rel":8},
10:{"type":"FDD","frequency":"1700","range":["1710-1770","2110-2170"],"bandwidths":[5,10,15,20],"earfcn":[4150,4749],"rel":8},
11:{"type":"FDD","frequency":"1500","range":["1427.9-1447.9","1475.9-1495.9"],"bandwidths":[5,10],"earfcn":[4750,4949],"rel":8},
12:{"type":"FDD","frequency":"700","range":["699-716","729-746"],"bandwidths":[1.4,3,5,10],"earfcn":[5010,5179],"rel":8.4},
13:{"type":"FDD","frequency":"700","range":["777-787","746-756"],"bandwidths":[5,10],"earfcn":[5180,5279],"rel":8},
14:{"type":"FDD","frequency":"700","range":["788-798","758-768"],"bandwidths":[5,10],"earfcn":[5280,5370],"rel":8},
17:{"type":"FDD","frequency":"700","range":["704-716","734-746"],"bandwidths":[5,10],"earfcn":[5730,5849],"rel":8.3},
18:{"type":"FDD","frequency":"850","range":["815-830","860-875"],"bandwidths":[5,10,15],"earfcn":[5850,5999],"rel":9},
19:{"type":"FDD","frequency":"850","range":["830-845","875-890"],"bandwidths":[5,10,15],"earfcn":[6000,6149],"rel":9},
20:{"type":"FDD","frequency":"800","range":["832-862","791-821"],"bandwidths":[5,10,15,20],"earfcn":[6150,6449],"rel":9},
21:{"type":"FDD","frequency":"1500","range":["1447.9-1462.9","1495.9-1510.9"],"bandwidths":[5,10,15],"earfcn":[6450,6559],"rel":9},
22:{"type":"FDD","frequency":"3500","range":["3410-3490","3510-3590"],"bandwidths":[5,10,15,20],"earfcn":[6600,7399],"rel":10.4},
23:{"type":"FDD","frequency":"2000","range":["2000-2020","2180-2200"],"bandwidths":[1.4,3,5,10,15,20],"earfcn":[7500,7699],"rel":10.3},
24:{"type":"FDD","frequency":"1600","range":["1626.5-1660.5","1525-1559"],"bandwidths":[5,10],"earfcn":[7700,8039],"rel":10.1},
25:{"type":"FDD","frequency":"1900","range":["1850-1915","1930-1995"],"bandwidths":[1.4,3,5,10,15,20],"earfcn":[8040,8689],"rel":10.0},
26:{"type":"FDD","frequency":"850","range":["814-849","859-894"],"bandwidths":[1.4,3,5,10,15,20],"earfcn":[8690,9039],"rel":11.0},
27:{"type":"FDD","frequency":"800","range":["807-824","852-869"],"bandwidths":[1.4,3,5,10],"earfcn":[9040,9209],"rel":11.1},
28:{"type":"FDD","frequency":"700","range":["703-748","758-803"],"bandwidths":[3,5,10,15,20],"earfcn":[9210,9659],"rel":11.1},
29:{"type":"SDL","frequency":"700","range":["717-728"],"bandwidths":[3,5,10],"earfcn":[9660,9790],"rel":11.3},
30:{"type":"FDD","frequency":"2300","range":["2305-2315","2350-2360"],"bandwidths":[5,10],"earfcn":[9770,9869],"rel":12.0},
31:{"type":"FDD","frequency":"450","range":["452.5-457.5","462.5-467.5"],"bandwidths":[1.4,3,5],"earfcn":[9870,9919],"rel":12.0},
32:{"type":"SDL","frequency":"1500","range":["1452-1496"],"bandwidths":[5,10,15,20],"earfcn":[9920,10359],"rel":12.4},
33:{"type":"TDD","frequency":"2100","range":["1900-1920"],"bandwidths":[5,10,15,20],"earfcn":[36000,36199],"rel":8},
34:{"type":"TDD","frequency":"2100","range":["2010-2025"],"bandwidths":[5,10,15],"earfcn":[36200,36349],"rel":8},
35:{"type":"TDD","frequency":"1900","range":["1850-1910"],"bandwidths":[1.4,3,5,10,15,20],"earfcn":[36350,36949],"rel":8},
36:{"type":"TDD","frequency":"1900","range":["1930-1990"],"bandwidths":[1.4,3,5,10,15,20],"earfcn":[36950,37549],"rel":8},
37:{"type":"TDD","frequency":"1900","range":["1910-1930"],"bandwidths":[5,10,15,20],"earfcn":[37550,37749],"rel":8},
38:{"type":"TDD","frequency":"2600","range":["2570-2620"],"bandwidths":[5,10,15,20],"earfcn":[37750,38249],"rel":8},
39:{"type":"TDD","frequency":"1900","range":["1880-1920"],"bandwidths":[5,10,15,20],"earfcn":[38250,38649],"rel":8},
40:{"type":"TDD","frequency":"2300","range":["2300-2400"],"bandwidths":[5,10,15,20],"earfcn":[38650,39649],"rel":8},
41:{"type":"TDD","frequency":"2500","range":["2496-2690"],"bandwidths":[5,10,15,20],"earfcn":[39650,41589],"rel":10.0},
42:{"type":"TDD","frequency":"3400","range":["3400-3600","2110-2170"],"bandwidths":[5,10,15,20],"earfcn":[41590,43589],"rel":10.0},
43:{"type":"TDD","frequency":"3700","range":["3600-3800"],"bandwidths":[5,10,15,20],"earfcn":[43590,45589],"rel":10.0},
44:{"type":"TDD","frequency":"700","range":["703-803"],"bandwidths":[3,5,10,15,20],"earfcn":[45590,46589],"rel":11.1},
45:{"type":"TDD","frequency":"1500","range":["1447-1467"],"bandwidths":[5,10,15,20],"earfcn":[46590,46789],"rel":13.2},
46:{"type":"LAA","frequency":"5200","range":["5150-5925"],"bandwidths":[10,20],"earfcn":[46790,54539],"rel":13.2},
47:{"type":"TDD","frequency":"5900","range":["5855-5925"],"bandwidths":[10,20],"earfcn":[54540,55239],"rel":14.1},
48:{"type":"TDD","frequency":"3600","range":["3550-3700"],"bandwidths":[5,10,15,20],"earfcn":[55240,56739],"rel":14.2},
49:{"type":"TDD","frequency":"3600","range":["3550-3700"],"bandwidths":[10,20],"earfcn":[56740,58239],"rel":15.1},
50:{"type":"TDD","frequency":"1500","range":["1432-1517"],"bandwidths":[3,5,10,15,20],"earfcn":[58240,59089],"rel":15.0},
51:{"type":"TDD","frequency":"1500","range":["1427-1432"],"bandwidths":[3,5],"earfcn":[59090,59139],"rel":15.0},
52:{"type":"TDD","frequency":"3300","range":["3300-3400"],"bandwidths":[5,10,15,20],"earfcn":[59140,60139],"rel":15.2},
53:{"type":"TDD","frequency":"2500","range":["2483.35-2494.85"],"bandwidths":[1.4,3,5,10],"earfcn":[60140,60254],"rel":16.0},
65:{"type":"FDD","frequency":"2100","range":["1920-2010","2110-2200"],"bandwidths":[1.4,3,5,10,15,20],"earfcn":[65536,66425],"rel":13.2},
66:{"type":"FDD","frequency":"1700","range":["1710-1780","2110-2200"],"bandwidths":[1.4,3,5,10,15,20],"earfcn":[66436,67335],"rel":13.2},
67:{"type":"SDL","frequency":"700","range":["738-758"],"bandwidths":[5,10,15,20],"earfcn":[67336,67535],"rel":13.2},
68:{"type":"FDD","frequency":"700","range":["698-728","753-783"],"bandwidths":[5,10,15],"earfcn":[67536,67835],"rel":13.3},
69:{"type":"SDL","frequency":"2600","range":["2570-2620"],"bandwidths":[5,10,15,20],"earfcn":[67836,68335],"rel":14.0},
70:{"type":"FDD","frequency":"2000","range":["1695-1710","1995-2020"],"bandwidths":[5,10,15,20],"earfcn":[68336,68535],"rel":14.0},
71:{"type":"FDD","frequency":"600","range":["663-698","617-652"],"bandwidths":[5,10,15,20],"earfcn":[68586,68935],"rel":15.0},
72:{"type":"FDD","frequency":"450","range":["451-456","461-466"],"bandwidths":[1.4,3,5],"earfcn":[68936,68985],"rel":15.0},
73:{"type":"FDD","frequency":"450","range":["450-455","460-465"],"bandwidths":[1.4,3,5],"earfcn":[68986,69035],"rel":15.0},
74:{"type":"FDD","frequency":"1500","range":["1427-1470","1475-1518"],"bandwidths":[1.4,3,5,10,15,20],"earfcn":[69036,69465],"rel":15.0},
75:{"type":"SDL","frequency":"1500","range":["1432-1517"],"bandwidths":[5,10,15,20],"earfcn":[69466,70315],"rel":15.0},
76:{"type":"SDL","frequency":"1500","range":["1427-1432"],"bandwidths":[5],"earfcn":[70316,70365],"rel":15.0},
85:{"type":"FDD","frequency":"700","range":["698-716","728-746"],"bandwidths":[5,10],"earfcn":[70366,70545],"rel":15.2},
87:{"type":"FDD","frequency":"450","range":["410-415","420-425"],"bandwidths":[1.4,3,5],"earfcn":[70546,70595],"rel":16.2},
88:{"type":"FDD","frequency":"450","range":["412-417","422-427"],"bandwidths":[1.4,3,5],"earfcn":[70596,70645],"rel":16.2},
252:{"type":"SDL","frequency":"5200","range":["5150-5250"],"bandwidths":[20],"earfcn":[255144,256143],"rel":null},
255:{"type":"SDL","frequency":"5800","range":["5725-5850"],"bandwidths":[20],"earfcn":[260894,262143],"rel":null}
};
// A nice function for rounding to 2 dp
var sensibleRound = function(n){
return Math.round(n*100)/100;
};
var languageNumerics = function(a){
//a = a.toString().replace(/,/g, "{c}");
//a = a.toString().replace(/\./g, "{d}");
return a;
};
// Thanks to: https://stackoverflow.com/a/6786040
var commafy = function(num) {
var str = num.toString().split('.');
if (str[0].length >= 4) {
str[0] = str[0].replace(/(\d)(?=(\d{3})+$)/g, '$1,');
}
if (str[1] && str[1].length >= 5) {
str[1] = str[1].replace(/(\d{3})/g, '$1 ');
}
return str.join('.');
};
var rb = function(sw,bw){
// ( Bandwidth (Hz) - Guard % of Bandwidth (Hz) ) / Resource block size in frequency domain (Hz)
var gbp = (bw[sw] === 1.4 ? .23 : .1);
var rbs = Math.round(
(
bw[sw]*1000-(
bw[sw]*1000*gbp
)
)/180
);
return rbs;
};
var getRbsForCarrier = function(carrier){
return $("#rowopt_resblocks"+carrier).val();
};
var tdd = function(selWidth,bandWidths,selModulation,selMimo,selTddCnf,selTddCpl,selTddFrm,link,tddBase,carrier){
// TDD Sect 1
var symps = tcpl[selTddCpl]; // # of OFDM symbols per slot of 0.5ms [symbols]
var sympsfo = symps/tddBase/1000; // # of OFDM symbols per subframe of 1ms [symbols]
var sympsft = sympsfo*10; // # of OFDM symbols per frame of 10ms [symbols]
// TDD Sect 2
var linkoff = (link === "D" ? 0 : 2); // TDD Link Direction offset Download|Upload
// TDD Configuration Section
var tddsconf = tconf[selTddCnf]; // TDD Selected Config
var frames = tddsconf[linkoff];
var sect1t = frames*sympsfo;
// TDD Special Configuration Section
var ssubsconf = ssubconf[selTddCpl][selTddFrm]; // TDD Special Selected Config
var sframes = ssubsconf[linkoff];
var sect2t = sframes*tddsconf[1]; // Consider special frames
// TDD Total config
var totalc = sect1t + sect2t;
// Throughput per sub carrier
var dltpsc = (totalc*100*tddmod[selModulation]/1000);
// Sub carriers per RB
var scprb = dltpsc*(tscprb/1000);
// Rbs * Throughput per RBs
var tpea = getRbsForCarrier(carrier)*scprb;
// MiMo multipliers
var atm = tpea * mimo[selMimo];
// Take off 25% to account for RBs used in control channel
var ctrl = atm * .25;
var fin = atm-ctrl;
return fin;
};
var fdd = function(bw,sw,sm,si,ca){
//console.log(rb(sw,bw));
return base * getRbsForCarrier(ca) * mod[sm] * mimo[si];
};
var doCalc = function(carrier){
// Get the band
var caDivID = "#carrier_id_n" + carrier;
var selBand = $(caDivID + " .rowopt_band").val();
// Check that the band was set
if (selBand === "0"){
return _l["alert.selband"];
}
// Get the bandwidth
var selWidth = $(caDivID + " .rowopt_width").val();
var selDlModulation = $(caDivID + " .rowopt_dlmod").val();
var selUlModulation = $(caDivID + " .rowopt_ulmod").val();
var selMimo = $(caDivID + " .rowopt_mimo").val();
// Determine calculation type
var bandType = lteBandData[selBand].type;
var bandWidths = lteBandData[selBand].bandwidths;
// Initialise result containers
var uplink = 0;
var downlink = 0;
// Calculate result
if (bandType === "TDD"){
// Get TDD options
var selTddCpl = $(caDivID + " .rowopt_tddcpl").val();
var selTddCnf = $(caDivID + " .rowopt_tddcnf").val();
var selTddFrm = $(caDivID + " .rowopt_tddssf").val();
if (selTddCpl === undefined || selTddCnf === undefined || selTddFrm === undefined){
return _l["alert.selconf"];
}
// Get results
downlink = tdd(selWidth,bandWidths,selDlModulation,selMimo,selTddCnf,selTddCpl,selTddFrm,"D",defaultTddBase,carrier);
uplink = tdd(selWidth,bandWidths,selUlModulation,0,selTddCnf,selTddCpl,selTddFrm,"U",defaultTddBase,carrier);
} else if (bandType === "LAA") {
// LAA Band is not supported yet
return _l["alert.laaband"];
} else if (bandType === "FDD"){
// Get results
downlink = fdd(bandWidths,selWidth,selDlModulation,selMimo,carrier);
uplink = fdd(bandWidths,selWidth,selUlModulation,0,carrier);
} else if (bandType === "SDL"){
// Get L-Band direction
var selLBDir = $(caDivID + " .rowopt_lbdir").val();
if (selLBDir === "0"){
downlink = fdd(bandWidths,selWidth,selDlModulation,selMimo,carrier);
} else {
uplink = fdd(bandWidths,selWidth,selUlModulation,0,carrier);
}
} else {
console.error("Unknown type:",bandType);
}
var rDl = sensibleRound(downlink);
var rUl = sensibleRound(uplink);
return [rDl,rUl];
};
var tryCalculateSpeed = function(){
var items = $(".carrier_row");
var totalDownlink = 0, totalUplink = 0, errMsg = false;
for (var i = 0,l = items.length;i<l;i++){
caid = $(items[i]).data("caid");
calc = doCalc(caid);
if (typeof calc !== "object"){
$("#speeds").text(calc);
errMsg = true;
continue;
}
totalDownlink += calc[0];
if (uploadcarriers.indexOf(caid) !== -1 || caid === primary){
totalUplink += calc[1];
}
setCarrierTitle($("#carrier_id_n" + caid + " .rowopt_band").val(),caid,calc);
}
var dlTxt = languageNumerics(commafy(sensibleRound(totalDownlink)));
var ulTxt = languageNumerics(commafy(sensibleRound(totalUplink)));
if (!errMsg) $("#speeds").html(dlTxt + "Mbps ↓ & " + ulTxt + "Mbps ↑");
};
var generateResourceBlockSelector = function(caid){
var sel = $("<input/>",{
"type":"number",
"class":"rowopt_resblocks",
"placeholder":_l["label.resblocks"],
"id":"rowopt_resblocks"+caid,
"data-carrier":caid,
"min":"1"
}).on("input paste",doCustomResourceBlock);
return sel;
};
var generateWidthSelector = function(caid){
var sel = $("<select/>",{
"title":"Select LTE Bandwidth",
"class":"rowopt_width",
"id":"rowopt_width" + caid,
"data-carrier":caid
}).append(
$("<option/>",{"value":"0"}).text(_l["alert.selfirst"])
).on("change",function(){
$("#rowopt_resblocks"+$(this).data("carrier")).val(
$(this).find(":selected").data("rbcount")
);
$(this).css("opacity",1);
});
return sel;
};
var generateCenterFreqSelector = function(caid){
var sel = $("<input/>",{
"type":"number",
"class":"rowopt_earfcn",
"placeholder":_l["label.earfcn"],
"id":"rowopt_earfcn"+caid,
"data-carrier":caid
}).on("input paste",doCenterFreqSearch);
return sel;
};
var generateBandSelector = function(caid){
var sel = $("<select/>",{
"title":"Select LTE Band",
"class":"rowopt_band",
"id":"rowopt_band"+caid,
"data-carrier":caid
});
sel.append($("<option/>",{"value":0}).text(_l["alert.seltext"]))
var dKeys = Object.keys(lteBandData);
for (var i = 0, l = dKeys.length;i<l;i++){
if (lteBandData[dKeys[i]].frequency !== ""){
txt = _l["label.band"] + " " + dKeys[i];
txt += " | " + lteBandData[dKeys[i]].type;
txt += " (" + lteBandData[dKeys[i]].frequency + "MHz)";
sel.append(
$("<option/>",{
"value":dKeys[i]
}).text(txt)
);
}
}
return sel;
};
var generateBandSection = function(caid){
var opts = $("<div/>",{
"class":"rowsect",
"data-carrier":caid
}).append($("<span/>",{"class":"rowsectheader"}).text(_l["label.band"]));
opts.append(
$("<label/>",{"for":"rowopt_earfcn" + caid,"id":"rowlabel_earfcn"+caid}).text(_l["label.earfcn"]),
generateCenterFreqSelector(caid),
$("<label/>",{"for":"rowopt_band" + caid,"id":"rowlabel_band"+caid}).text(_l["label.band"]),
generateBandSelector(caid)
);
return opts;
};
var generateTddOptSelector = function(caid){
var opts = $("<div/>",{
"data-carrier":caid
});
// Cyclic Prefix Selector
opts.append(
$("<label/>",{"for":"tddconf_cpl" + caid}).text(_l["label.tddcpl"]),
$("<select/>",{"class":"rowopt_tddcpl","id":"tddconf_cpl" + caid,"title":"Select TDD Cyclic Prefix"}).append(
$("<option/>",{"value":"normal"}).text("Normal CP [6]"),
$("<option/>",{"value":"extended"}).text("Extended CP [7]")
)
);
// TDD Config Selector
opts.append(
$("<label/>",{"for":"tddconf_cnf" + caid}).text(_l["label.tddcnf"]),
$("<select/>",{"class":"rowopt_tddcnf","id":"tddconf_cnf" + caid,"title":"Select TDD Config"}).append(
$("<option/>",{"value":"0"}).text("TDD Config 0"),
$("<option/>",{"value":"1"}).text("TDD Config 1"),
$("<option/>",{"value":"2"}).text("TDD Config 2"),
$("<option/>",{"value":"3"}).text("TDD Config 3"),
$("<option/>",{"value":"4"}).text("TDD Config 4"),
$("<option/>",{"value":"5"}).text("TDD Config 5"),
$("<option/>",{"value":"6"}).text("TDD Config 6")
)
);
// Special Subframe Config Selector
opts.append(
$("<label/>",{"for":"tddconf_ssf" + caid}).text(_l["label.tddssf"]),
$("<select/>",{"class":"rowopt_tddssf","id":"tddconf_ssf" + caid,"title":"Select TDD Special Subframe Config"}).append(
$("<option/>",{"value":"0"}).text("Special Config 0"),
$("<option/>",{"value":"1"}).text("Special Config 1"),
$("<option/>",{"value":"2"}).text("Special Config 2"),
$("<option/>",{"value":"3"}).text("Special Config 3"),
$("<option/>",{"value":"4"}).text("Special Config 4"),
$("<option/>",{"value":"5"}).text("Special Config 5"),
$("<option/>",{"value":"6"}).text("Special Config 6"),
$("<option/>",{"value":"7"}).text("Special Config 7"),
$("<option/>",{"value":"8"}).text("Special Config 8")
)
);
return opts;
};
var generateLBandSelector = function(caid){
var opts = $("<div/>",{
"data-carrier":caid
});
// Cyclic Prefix Selector
opts.append(
$("<select/>",{"class":"rowopt_lbdir","id":"lband_dir" + caid,"data-carrier":caid}).append(
$("<option/>",{"value":"0"}).text(_l["label.sdl"]),
$("<option/>",{"value":"1"}).text(_l["label.sul"])
)
);
return opts;
};
var generateBandWidthSelector = function(caid){
var opts = $("<div/>",{
"class":"rowsect",
"data-carrier":caid
}).append($("<span/>",{"class":"rowsectheader"}).text(_l["label.bandwidth"]));;
opts.append(
$("<label/>",{"for":"rowopt_resblocks" + caid,"id":"rowlabel_resblocks"+caid}).text(_l["label.resblocks"]),
generateResourceBlockSelector(caid),
$("<label/>",{"for":"rowopt_width" + caid,"id":"rowlabel_width"+caid}).text(_l["label.bandwidth"]),
generateWidthSelector(caid)
);
return opts;
};
var generateModulationSelector = function(caid){
var opts = $("<div/>",{
"class":"rowsect",
"data-carrier":caid
}).append($("<span/>",{"class":"rowsectheader"}).text(_l["label.mod"]));
opts.append(
$("<label/>",{"for":"rowopt_dlmod" + caid,"id":"rowlabel_dlmod"+caid}).text(_l["label.dlmod"]),
$("<select/>",{
"title":"Select downlink modulation scheme",
"class":"rowopt_dlmod",
"id":"rowopt_dlmod" + caid,
"data-carrier":caid
}).append(
$("<option/>",{"value":"0"}).text(_l["alert.selfirst"])
),
$("<label/>",{"for":"rowopt_ulmod" + caid,"id":"rowlabel_ulmod"+caid}).text(_l["label.ulmod"]),
$("<select/>",{
"title":"Select uplink modulation scheme",
"class":"rowopt_ulmod",
"id":"rowopt_ulmod" + caid,
"data-carrier":caid
}).append(
$("<option/>",{"value":"0"}).text(_l["alert.selfirst"])
)
);
return opts;
};
var generateMiMoSelector = function(caid){
var opts = $("<div/>",{
"class":"rowsect",
"data-carrier":caid
}).append($("<span/>",{"class":"rowsectheader"}).text("MiMo"));;
opts.append(
$("<select/>",{
"title":"Select carrier MIMO",
"class":"rowopt_mimo",
"id":"rowopt_mimo" + caid,
"data-carrier":caid
}).append(
$("<option/>",{"value":0}).text(_l["alert.selfirst"])
),
$("<span/>",{
"id":"rowmsg_mimo" + caid,
"style":"display:none"
}).text("Upload can only be SISO")
);
return opts;
};
var generateRowOptions = function(caid){
var opts = $("<div/>",{
"class":"rowsect",
"data-carrier":caid
}).append($("<span/>",{"class":"rowsectheader"}).text("Options"));
// Every carrier should have this option
opts.append(
$("<button/>",{
"class":"b_rmrow",
"data-carrier":caid
}).text(_l["label.remca"])
);
// Options for carriers that aren't the primary
if (caid !== primary){
opts.append(
$("<button/>",{
"class":"b_aggupl",
"id":"rowbt_aggupl"+caid,
"data-carrier":caid
}).text(_l["label.aggupl"]),
$("<button/>",{
"class":"b_primaryc",
"data-carrier":caid,
"style":"display:none"
}).text(_l["label.setprim"])
);
}
return opts;
};
var doCenterFreqSearch = function(){
var earfcn = $(this).val();
var keys = Object.keys(lteBandData);
var band = 0;
if (earfcn.length !== 0){
for (var i = 0;i < keys.length;i++){
var bounds = lteBandData[keys[i]].earfcn;
if (earfcn >= bounds[0] && earfcn <= bounds[1]){
band = keys[i];
console.log(band);
break;
}
}
}
$("#rowopt_band"+$(this).data("carrier")).val(band).change();
};
var doCustomResourceBlock = function(){
if ($(this).val() === "") return;
if (window.strict3gpp === true){
if ($(this).val() > 100){
alert("Invalid number of resource blocks.\nIf you wish to override this, disable '"+_l["ux.adherespec"]+"' in settings.");
return;
}
}
$("#rowopt_width" + $(this).data("carrier")).css("opacity",0.5);
tryCalculateSpeed();
};
var bandSelect = function(){
var band = $(this).val();
var carrier = $(this).data("carrier");
if (band === "0"){
$("#rowopt_width"+carrier).empty().append($("<option/>",{"value":"0"}).text(_l["alert.seltext"]));
$("#rowopt_dlmod"+carrier).empty().append($("<option/>",{"value":"0"}).text(_l["alert.seltext"]));
$("#rowopt_ulmod"+carrier).empty().append($("<option/>",{"value":"0"}).text(_l["alert.seltext"]));
$("#rowopt_mimo"+carrier).empty().append($("<option/>",{"value":"0"}).text(_l["alert.seltext"]));
$("#band_title"+carrier).html("Carrier #"+(carrier+1) + " - Select a band");
} else {
setCarrierTitle(band,carrier,"");
populateSelectors(band,carrier);
bandOptions(band,carrier);
}
};
var bandOptions = function(band,carrier){
// Reset some stuff
$(" #rowopt_dlmod"+carrier+",\
#rowlabel_dlmod"+carrier+",\
#rowopt_ulmod"+carrier+",\
#rowlabel_ulmod"+carrier+",\
#rowopt_mimo"+carrier+",\
#rowbt_aggupl"+carrier).show();
// Band type specific configurations
if (lteBandData[band].type === "TDD"){
$("#row_extra"+carrier).empty().append(generateTddOptSelector(carrier));
$("#row_extra"+carrier+" select").on("change",tryCalculateSpeed).trigger("change");
} else if (lteBandData[band].type === "SDL"){
$("#row_extra"+carrier).empty().append(generateLBandSelector(carrier));
$("#row_extra"+carrier+" select").on("change",tryCalculateSpeed);
$("#rowbt_aggupl"+carrier).hide();
$("#row_extra"+carrier+" select.rowopt_lbdir").on("change",lbandUxModifier).trigger("change");
} else {
$("#row_extra"+carrier).empty().append($("<span/>").text(_l["msg.nofddopts"]));
}
};
var lbandUxModifier = function(){
var caid = $(this).data("carrier");
$("#rowlabel_ulmod" + caid + ",#rowlabel_dlmod" + caid).hide();
if ($(this).val() === "0"){
$("#rowopt_dlmod" + caid + ",#rowopt_mimo" + caid).show();
$("#rowopt_ulmod" + caid + ",#rowmsg_mimo" + caid).hide();
if (uploadcarriers.indexOf(caid) !== -1){
uploadcarriers.slice(uploadcarriers.indexOf(caid),1);
}
} else {
$("#rowopt_dlmod" + caid + ",#rowopt_mimo" + caid).hide();
$("#rowopt_ulmod" + caid + ",#rowmsg_mimo" + caid).show();
if (uploadcarriers.indexOf(caid) === -1){
uploadcarriers.push(caid);
}
}
tryCalculateSpeed();
};
var setCarrierTitle = function(band,carrier,speed){
var freqInf, caname, stext = "";
if (lteBandData[band].range.length === 2){
freqInf = _l["label.band"] + ": " + lteBandData[band].frequency + "MHz, Uplink: " + lteBandData[band].range[0] + "MHz, ";
freqInf += "Downlink: " + lteBandData[band].range[1] + "MHz";
} else {
freqInf = _l["label.band"] + ": " + lteBandData[band].frequency + "MHz, Range: " + lteBandData[band].range[0] + "MHz";
}
var uploadUsed = (uploadcarriers.indexOf(carrier) !== -1 || carrier === primary ? true : false);
if (speed[0] !== 0){
stext += "<strong>" + calc[0] + "Mbps ↓</strong>";
if (speed[1] !== 0){
stext += " & "
}
}
if (speed[1] !== 0){
stext += (uploadUsed ? "<strong>":"") + calc[1] + "Mbps ↑ " + (uploadUsed ? "</strong>":"");
}
$("#band_title"+carrier).html(freqInf + "<br />" + stext);
};
var populateSelectors = function(band,carrier){
// Populate bandwidth selector
$("#rowopt_width"+carrier).empty();
var bandwidthVals = (window.strict3gpp === true ? lteBandData[band].bandwidths : vBandwidths);
for (var i = 0, l = bandwidthVals.length;i<l;i++){
var iterRbs = rb(i,bandwidthVals);
$("#rowopt_width"+carrier).append(
$("<option/>",{
"value":i,
"data-rbcount":iterRbs
}).text(bandwidthVals[i] + "MHz" + " (" + iterRbs + "RBs)")
);
}
$("#rowopt_width" + carrier)[0].selectedIndex = bandwidthVals.length-1;
// Populate Modulation selector
$("#rowopt_dlmod"+carrier).empty().append(
$("<option/>",{"value":0}).text("QPSK"),
$("<option/>",{"value":1}).text("16QAM"),
$("<option/>",{"value":2,"selected":"selected"}).text("64QAM"),
$("<option/>",{"value":3}).text("256QAM")
);
$("#rowopt_ulmod"+carrier).empty().append(
$("<option/>",{"value":0}).text("QPSK"),
$("<option/>",{"value":1,"selected":"selected"}).text("16QAM"),
$("<option/>",{"value":2}).text("64QAM"),
$("<option/>",{"value":3}).text("256QAM")
);
// Populate MiMo selector
$("#rowopt_mimo"+carrier).empty().append(
$("<option/>",{"value":0}).text("1x1 SiSo"),
$("<option/>",{"value":1,"selected":"selected"}).text("2x2 MiMo"),
$("<option/>",{"value":2}).text("4x4 MiMo")
);
// Populate rb count
$("#rowopt_resblocks"+$("#rowopt_width"+carrier).data("carrier")).val(
$("#rowopt_width"+carrier).find(":selected").data("rbcount")
);
tryCalculateSpeed();
};
var assignSelectorEvents = function(caid){
$("#rowopt_band" + caid).on("change",bandSelect);
};
var addRow = function(){
var row = $("<div/>",{
"id":"carrier_id_n" + carriers,
"class":"carrier_row",
"data-caid":carriers
});
row.append(
$("<div/>",{"class":"row_header","id":"rhead_id"+carriers,"data-caid":carriers}).append(
$("<h2/>",{"class":"band_title","id":"band_title"+carriers}).text("Carrier #" + (carriers+1) + " - " + _l["alert.seltext"])
),
$("<div/>",{"class":"row_content","id":"rcont_id"+carriers}).append(
generateBandSection(carriers),
$("<div/>",{"class":"rowsect","id":"row_extra"+carriers}).append($("<span/>").text(_l["msg.nobandopts"])),
generateBandWidthSelector(carriers),
generateModulationSelector(carriers),
generateMiMoSelector(carriers),
generateRowOptions(carriers)
)
);
$("#ca_body").append(row);
// Assign selector events
$("#carrier_id_n" + carriers + " select").on("change",tryCalculateSpeed);
$("#carrier_id_n" + carriers + " .b_rmrow").on("click enter",removeRow);
$("#carrier_id_n" + carriers + " .b_aggupl").on("click enter",uplinkca);
$("#carrier_id_n" + carriers + " .b_primaryc").on("click enter",changePrimary);
$("#rhead_id" + carriers).on("click enter",toggleRowView);
assignSelectorEvents(carriers);
carriers++;
tryCalculateSpeed();
};
var toggleRowView = function(){
var id = $(this).data("caid");
if ($("#rcont_id"+id).is(":visible")){
$("#rcont_id"+id).slideUp(250);
} else {
$("#rcont_id"+id).slideDown(250);
}
};
var changePrimary = function(){
alert("Feature not added yet");
};
var uplinkca = function(){
var caid = $(this).data("carrier");
if (uploadcarriers.indexOf(caid) !== -1){
uploadcarriers.splice(uploadcarriers.indexOf(caid),1);
$(this).text(_l["label.aggupl"]);
} else {
uploadcarriers.push(caid);
$(this).text(_l["label.deaggupl"]);
}
tryCalculateSpeed();
};
var removeRow = function(){
// Check if it's the first carrier
if ($(this).data("carrier") === primary){
alert(_l["alert.remprim"]);
return;
}
// Remove the row
$("#carrier_id_n" + $(this).data("carrier")).remove();
// Re-calculate the speed
tryCalculateSpeed();
};
var modifySetting = function(){
var s = $(this).data("setting");
if (s === "language"){