-
Notifications
You must be signed in to change notification settings - Fork 1
/
modelDatalink_FullDuplexTCP.tcl
1421 lines (1257 loc) · 52.6 KB
/
modelDatalink_FullDuplexTCP.tcl
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
#!$HOME/ns-allinone-2.35/ns-2.35/ns
# modelDatalink.tcl - based on tg.tcl example and ERG-UoA Aberdeen (UK), May 2008 VoIP and web traffic generation examples
# D. Fernández - November 2018
# Results: PLR and one-way delay statistics (avg delay, TD50, TD95 and TD99.9) in function of arrival rate of messages
# Testing the effect of TCP ACKs prioritization
#
if { $argc !=13 } {
puts stderr {usage: ns modelDatalink.tcl <RLC kbps> <FLC kbps> <RL UDP rate packets/s> <RL TCP rate packets/s> <FL UDP rate packets/s> <FL TCP rate packets/s> <RL message size> <FL message size> <no_terminals> <NbrRLC> <NbrFLC> <RL one-way delay ms> <FL one-way delay ms> }
puts stderr {e.g. Iris:}
puts stderr {ns modelDatalink.tcl 144 272 25 0 0 0 463 463 1 1 1 850 270}
puts stderr {e.g. ADSL ACK prio (https://www.benzedrine.ch/ackpri.html):}
puts stderr {ns modelDatalink.tcl 128 512 0 1 0 0 0 0 1 1 1 5 5}
puts stderr {ns modelDatalink.tcl 128 512 20 0 80 0 800 800 1 1 1 5 5}
puts stderr {ns modelDatalink.tcl 128 512 400 0 1600 0 40 40 1 1 1 5 5}
puts stderr {e.g. MTAILS GEO/C1:}
puts stderr {ns modelDatalink.tcl 4000 20000 0 1 0 0 0 0 1 1 1 260 260 }
exit 1
}
set testing 0
set num_pkts 10000
set fraction 0.1
set tx_capacity_per_RLC_kb [lindex $argv 0]
set tx_capacity_per_FLC_kb [lindex $argv 1]
set rl_UDP_packets_rate [lindex $argv 2]
set rl_TCP_packets_rate [lindex $argv 3]
set fl_UDP_packets_rate [lindex $argv 4]
set fl_TCP_packets_rate [lindex $argv 5]
set rl_msg_size [lindex $argv 6]
set fl_msg_size [lindex $argv 7]
set no_terminals [lindex $argv 8]
set NbrRLC [lindex $argv 9]
set NbrFLC [lindex $argv 10]
set delayRLms [lindex $argv 11]
set delayFLms [lindex $argv 12]
set bwRL_kb [expr [lindex $argv 0] * $NbrRLC]
set bwFL_kb [expr [lindex $argv 1] * $NbrFLC]
set tx_capacity_per_RLC [expr $tx_capacity_per_RLC_kb]kb
set tx_capacity_per_FLC [expr $tx_capacity_per_FLC_kb]kb
set tx_latency_per_FLC_ms [expr $delayFLms / 2]
set rx_latency_per_FLC [expr $delayFLms / 2]ms
set tx_latency_per_RLC_ms [expr $delayRLms / 2]
set rx_latency_per_RLC [expr $delayRLms / 2]ms
set tx_latency_per_FLC [expr $tx_latency_per_FLC_ms]ms
set tx_latency_per_RLC [expr $tx_latency_per_RLC_ms]ms
set ping_pkt_size 64
set onboard_net_delay_ms 10.0
set onboard_net_delay [expr $onboard_net_delay_ms]ms
set onboard_net_capacity_Mb 1000
set onboard_net_capacity [expr $onboard_net_capacity_Mb]Mb
# Rx capacity per FLC = bwRL_kb / NbrFL
# set rx_capacity_per_FLC [expr ceil(1.0 * $bwRL_kb / $NbrFLC)]kb
# set rx_capacity_per_RLC $tx_capacity_per_FLC
# Satellites are not store and forward: almost unlimited capacity hereafter
set rx_capacity_per_FLC_Mb $onboard_net_capacity_Mb
set rx_capacity_per_FLC [expr $rx_capacity_per_FLC_Mb]Mb
set rx_capacity_per_RLC_Mb $onboard_net_capacity_Mb
set rx_capacity_per_RLC [expr $rx_capacity_per_RLC_Mb]Mb
set per 0.0
# set per 0.5
# set per 1e-3
set ber 0.0
set rl_ber $ber
set fl_ber $ber
# Assuming RL L2 frames are ATM cells (53 bytes cells, 48 bytes payload)
# set rl_cell_size 53
# set rl_cell_size 200
# set rl_ber [expr 1-pow((1-$per),[expr 1/($rl_cell_size*8.0)])]
# Assuming FL L2 frames are MPEG packets (188 bytes cells, 184 bytes payload)
# set fl_cell_size 188
# set fl_cell_size 8100
# set fl_ber [expr 1-pow((1-$per),[expr 1/($fl_cell_size*8.0)])]
set mtu 1500
set ack_size 52
# set ack_size $mtu/5
set tcp_duration 240
# RFC 6928
set tcp_init_window 10
set tcp_window_size 100
# set tcp_window_size 65000
# 125 = 1 kbyte (1000 bytes) / 8 bytes
set max_bytes_rx_per_tcp_RL [expr $tcp_duration*125*$tx_capacity_per_RLC_kb]
set max_bytes_rx_per_tcp_FL [expr $tcp_duration*125*$tx_capacity_per_FLC_kb]
set rl_bdp_factor 3
set fl_bdp_factor 1
# QoS and CoS configuration
# Better avoid ugly set_prio 0 set_fid 0 and set_prio 1 set_fid 0 combinations.
# set set_prio 0
# Commented above and uncommented below => give priority to QoS 0 (TCP ACKs)
set set_prio 1
# set set_fid 0
# Commented above and uncommented below => TCP ACKs can have a different fid than TCP data packets
set set_fid 1
# Single CoS setup (all Best Effort)
# set ping_prio 46
set ping_prio 0
# set tcp_data_prio 0
set tcp_data_prio 0
set ack_prio 46
set udp_data_prio 0
set af_data_prio 10
set ef_data_prio 46
# set udp_data_prio 46
set num_cos 2
set qos1(deadline) 1.0
set qos2(deadline) 1.0
# set qos3(deadline) 1.0
# set qos3(deadline) [expr 4e-3*($tx_latency_per_FLC_ms + $tx_latency_per_RLC_ms)]
set qos3(deadline) [expr 1e-3*($delayRLms + $delayFLms)]
set qos3(factor) 1
# set minqlim $tcp_init_window
# set minqlim 50
set minqlim 100
# set minqlim 150
set finish_margin 10.0
set traffic_duration 0.0
if {$rl_TCP_packets_rate > 0 || $fl_TCP_packets_rate > 0} {
set traffic_duration $tcp_duration
}
if {$rl_UDP_packets_rate > 0 } {
set rl_udp_traffic_duration [expr $num_pkts / $rl_UDP_packets_rate ]
set traffic_duration $rl_udp_traffic_duration
}
if {$fl_UDP_packets_rate > 0} {
set fl_udp_traffic_duration [expr $num_pkts / $fl_UDP_packets_rate ]
if { $fl_udp_traffic_duration > $traffic_duration } {
set traffic_duration $fl_udp_traffic_duration
}
}
if {$rl_TCP_packets_rate > 0 } {
set rl_tcp_traffic_duration [expr $num_pkts / $rl_TCP_packets_rate ]
if { $rl_tcp_traffic_duration > $traffic_duration } {
set traffic_duration $rl_tcp_traffic_duration
}
}
if {$fl_TCP_packets_rate > 0 } {
set fl_tcp_traffic_duration [expr $num_pkts / $fl_TCP_packets_rate ]
if { $fl_tcp_traffic_duration > $traffic_duration } {
set traffic_duration $fl_tcp_traffic_duration
}
}
set rltcpexp(index) 0
set fltcpexp(index) 0
set rltcp(index) 0
set fltcp(index) 0
set rlftp(index) 0
set flftp(index) 0
set rsink(index) 0
set fsink(index) 0
set start 1.0
set currTime $start
set pingTime $start
set rpingstime0 $start
set fpingstime0 [expr $rpingstime0 + 1.0]
set reset [expr $fpingstime0 + 1.0]
set stop [expr $reset + $traffic_duration]
puts "Running test with $no_terminals terminal(s), $tx_capacity_per_RLC per RL carrier and $tx_capacity_per_FLC per FL carrier"
puts "$rl_msg_size bytes messages in the RL, $fl_msg_size bytes messages in the FL"
puts "$NbrRLC RL carriers and $NbrFLC FL carriers"
# puts "PER = $per"
puts "PER = $per (RL BER $rl_ber, FL BER $fl_ber)"
if { $rl_msg_size > 0 } {
set rl_req_ber [expr 1-pow((1-1e-3),(1/($rl_msg_size*8.0)))]
puts "Required RL BER: $rl_req_ber"
}
if { $fl_msg_size > 0 } {
set fl_req_ber [expr 1-pow((1-1e-3),(1/($fl_msg_size*8.0)))]
puts "Required FL BER: $fl_req_ber"
}
puts "Rx capacity per FLC $rx_capacity_per_FLC"
if { $rl_UDP_packets_rate > 0 } {
puts "$rl_UDP_packets_rate UDP packets/s in the RL"
set rl_service_rate [expr 1e3*$tx_capacity_per_RLC_kb/($rl_msg_size*8.0)]
puts "Service rate per RL carrier (mu) UDP packets/s: $rl_service_rate"
set rl_rho [expr 1.0*$rl_UDP_packets_rate/($rl_service_rate*$NbrRLC)]
puts "RL carrier occupation %: [expr 100*$rl_rho]"
if {$rl_rho < 1} {
set rl_tq [expr $rl_rho/(2*$rl_service_rate*(1-$rl_rho))]
puts "RL expected (M/D/1 model) average queueing time (s): $rl_tq"
set rl_tq95 [expr log(100/(100-95.0))*$rl_tq]
puts "RL expected (M/D/1 model) percentil 95 of queueing time (s): $rl_tq95"
set rl_tq999 [expr log(100/(100-99.9))*$rl_tq]
puts "RL expected (M/D/1 model) percentil 99.9 of queueing time (s): $rl_tq999"
set rl_td [expr 1e-3*$delayRLms + 1/$rl_service_rate + $rl_tq]
puts "RL expected (M/D/1 model) average one-way delay (s): $rl_td"
set rl_td95 [expr 1e-3*$delayRLms + 1/$rl_service_rate + $rl_tq95]
puts "RL expected (M/D/1 model) percentil 95 one-way delay (s): $rl_td95"
set rl_td999 [expr 1e-3*$delayRLms + 1/$rl_service_rate + $rl_tq999]
puts "RL expected (M/D/1 model) percentil 99.9 one-way delay (s): $rl_td999"
}
puts "RL UDP traffic duration for $num_pkts packets (s): $rl_udp_traffic_duration"
}
if { $fl_UDP_packets_rate > 0 } {
puts "$fl_UDP_packets_rate UDP packets/s in the FL"
set fl_service_rate [expr 1e3*$tx_capacity_per_FLC_kb/($fl_msg_size*8.0)]
puts "Service rate per FL carrier (mu) UDP packets/s: $fl_service_rate"
set fl_rho [expr 1.0*$fl_UDP_packets_rate/($fl_service_rate*$NbrFLC)]
puts "FL carrier occupation %: [expr 100*$fl_rho]"
if {$fl_rho < 1} {
set fl_tq [expr $fl_rho/(2*$fl_service_rate*(1-$fl_rho))]
puts "FL expected (M/D/1 model) average queueing time (s): $fl_tq"
set fl_tq95 [expr log(100/(100-95.0))*$fl_tq]
puts "FL expected (M/D/1 model) percentil 95 of queueing time (s): $fl_tq95"
set fl_tq999 [expr log(100/(100-99.9))*$fl_tq]
puts "FL expected (M/D/1 model) percentil 99.9 of queueing time (s): $fl_tq999"
set fl_td [expr 1e-3*$delayFLms + 1/$fl_service_rate + $fl_tq]
puts "FL expected (M/D/1 model) average one-way delay (s): $fl_td"
set fl_td95 [expr 1e-3*$delayFLms + 1/$fl_service_rate + $fl_tq95]
puts "FL expected (M/D/1 model) percentil 95 one-way delay (s): $fl_td95"
set fl_td999 [expr 1e-3*$delayFLms + 1/$fl_service_rate + $fl_tq999]
puts "FL expected (M/D/1 model) percentil 99.9 one-way delay (s): $fl_td999"
}
puts "FL UDP traffic duration for $num_pkts packets (s): $fl_udp_traffic_duration"
}
if { $rl_TCP_packets_rate > 0 } {
puts "$rl_TCP_packets_rate TCP packets/s in the RL"
}
if { $fl_TCP_packets_rate > 0 } {
puts "$fl_TCP_packets_rate TCP packets/s in the FL"
}
puts "Traffic duration(s): $traffic_duration, from t=$reset to t=$stop"
# Satellite is considered a store and forward node (not transparent)
set ping_rtt_ms [expr $ping_pkt_size*8*2.0/(1000.0*$onboard_net_capacity_Mb) + $ping_pkt_size*8*2.0/$tx_capacity_per_RLC_kb + $ping_pkt_size*8*2.0/$tx_capacity_per_FLC_kb + $delayRLms + $delayFLms + $onboard_net_delay_ms*2]
puts "Theoretical store and forward RTT ms: $ping_rtt_ms"
set ping_rtt_ms [expr $ping_pkt_size*2.0*8/(1000.0*$onboard_net_capacity_Mb) + $ping_pkt_size*8/$tx_capacity_per_RLC_kb + $ping_pkt_size*8/$tx_capacity_per_FLC_kb + $delayRLms + $delayFLms + $onboard_net_delay_ms*2]
puts "Theoretical transparent RTT ms: $ping_rtt_ms"
# Uncomment if you are just interested in theoretical values
# exit
ns-random 0
set ns [new Simulator]
$ns color 0 Blue
$ns color 1 Red
# set udp_fid 0
# Single CoS setup (all Best Effort)
set udp_fid 1
set tcp_fid 1
set ack_fid 0
# In order to make plots look good do some pings with the same fid you are plotting just after the flow end
set ping_fid 1
# Full tracing can increase the runtime 10-fold: http://intronetworks.cs.luc.edu/current/html/ns2.html
set f [open modelDatalink.tr w]
$ns trace-all $f
set nf [open modelDatalink.nam w]
$ns namtrace-all $nf
# UDP CBR Traffic
proc new-rl-udpCBR_custom { i k t msg_rate msg_size prio fid duration} {
global ns rludpCBR h n mtu
global NbrFLC
set rludpCBR($i) [new Application/Traffic/CBR]
set null [new Agent/Null]
set udp [new Agent/UDP]
$rludpCBR($i) attach-agent $udp
$rludpCBR($i) set rate_ [expr $msg_rate*$msg_size*8]
$rludpCBR($i) set packetSize_ $msg_size
$udp set index $i
$udp set fid_ $fid
$udp set prio_ $prio
$udp set packetSize_ $mtu
set h_n [expr $i % $NbrFLC]
$ns attach-agent $n($k) $udp
$ns attach-agent $h($h_n) $null
$ns connect $udp $null
$ns at $t "$rludpCBR($i) start"
$ns at [expr $t + $duration] "$rludpCBR($i) stop"
}
proc new-rl-udpCBR { i k t } {
global ns rludpCBR h n udp_data_prio mtu udp_fid rl_UDP_packets_rate rl_msg_size
global NbrFLC rl_udp_traffic_duration
set rludpCBR($i) [new Application/Traffic/CBR]
set null [new Agent/Null]
set udp [new Agent/UDP]
$rludpCBR($i) attach-agent $udp
$rludpCBR($i) set rate_ [expr $rl_UDP_packets_rate*$rl_msg_size*8]
$rludpCBR($i) set packetSize_ $rl_msg_size
$udp set index $i
$udp set fid_ $udp_fid
$udp set prio_ $udp_data_prio
$udp set packetSize_ $mtu
set h_n [expr $i % $NbrFLC]
$ns attach-agent $n($k) $udp
$ns attach-agent $h($h_n) $null
$ns connect $udp $null
$ns at $t "$rludpCBR($i) start"
$ns at [expr $t + $rl_udp_traffic_duration] "$rludpCBR($i) stop"
}
proc new-fl-udpCBR_custom { i k t msg_rate msg_size prio fid duration} {
global ns fludpCBR h n mtu
global NbrFLC
set fludpCBR($i) [new Application/Traffic/CBR]
set null [new Agent/Null]
set udp [new Agent/UDP]
$fludpCBR($i) attach-agent $udp
$fludpCBR($i) set rate_ [expr $msg_rate*$msg_size*8]
$fludpCBR($i) set packetSize_ $msg_size
$udp set index $i
$udp set fid_ $fid
$udp set prio_ $prio
$udp set packetSize_ $mtu
set h_n [expr $i % $NbrFLC]
$ns attach-agent $h($h_n) $udp
$ns attach-agent $n($k) $null
$ns connect $udp $null
$ns at $t "$fludpCBR($i) start"
$ns at [expr $t + $duration] "$fludpCBR($i) stop"
}
proc new-fl-udpCBR { i k t } {
global ns fludpCBR h n udp_data_prio mtu udp_fid fl_UDP_packets_rate fl_msg_size
global NbrFLC fl_udp_traffic_duration
set fludpCBR($i) [new Application/Traffic/CBR]
set null [new Agent/Null]
set udp [new Agent/UDP]
$fludpCBR($i) attach-agent $udp
$fludpCBR($i) set rate_ [expr $fl_UDP_packets_rate*$fl_msg_size*8]
$fludpCBR($i) set packetSize_ $fl_msg_size
$udp set index $i
$udp set fid_ $udp_fid
$udp set prio_ $udp_data_prio
$udp set packetSize_ $mtu
set h_n [expr $i % $NbrFLC]
$ns attach-agent $h($h_n) $udp
$ns attach-agent $n($k) $null
$ns connect $udp $null
$ns at $t "$fludpCBR($i) start"
$ns at [expr $t + $fl_udp_traffic_duration] "$fludpCBR($i) stop"
}
# UDP Poisson traffic #########################################################
proc new-rl-udpExpo { i k t } {
global ns rludpExpo h n udp_data_prio mtu udp_fid rl_UDP_packets_rate rl_msg_size
global NbrFLC traffic_duration
set rludpExpo($i) [new Application/Traffic/Exponential]
set null [new Agent/Null]
set udp [new Agent/UDP]
$rludpExpo($i) attach-agent $udp
$rludpExpo($i) set rate_ 10000Mb
$rludpExpo($i) set burst_time_ 0
$rludpExpo($i) set idle_time_ [expr 1.0 / $rl_UDP_packets_rate]
$rludpExpo($i) set packetSize_ $rl_msg_size
$udp set index $i
$udp set fid_ $udp_fid
$udp set prio_ $udp_data_prio
$udp set packetSize_ $mtu
set h_n [expr $i % $NbrFLC]
$ns attach-agent $n($k) $udp
$ns attach-agent $h($h_n) $null
$ns connect $udp $null
$ns at $t "$rludpExpo($i) start"
$ns at [expr $t + $traffic_duration] "$rludpExpo($i) stop"
}
proc new-fl-udpExpo { i k t } {
global ns fludpExpo h n udp_data_prio mtu udp_fid fl_UDP_packets_rate fl_msg_size
global NbrFLC traffic_duration
set fludpExpo($i) [new Application/Traffic/Exponential]
set null [new Agent/Null]
set udp [new Agent/UDP]
$fludpExpo($i) attach-agent $udp
$fludpExpo($i) set rate_ 10000Mb
$fludpExpo($i) set burst_time_ 0
$fludpExpo($i) set idle_time_ [expr 1.0 / $fl_UDP_packets_rate]
$fludpExpo($i) set packetSize_ $fl_msg_size
$udp set index $i
$udp set fid_ $udp_fid
$udp set prio_ $udp_data_prio
$udp set packetSize_ $mtu
set h_n [expr $i % $NbrFLC]
$ns attach-agent $h($h_n) $udp
$ns attach-agent $n($k) $null
$ns connect $udp $null
$ns at $t "$fludpExpo($i) start"
$ns at [expr $t + $traffic_duration] "$fludpExpo($i) stop"
}
# ICMP traffic
#Define a 'recv' function for the class 'Agent/Ping'
Agent/Ping instproc recv {from rtt} {
global ns
$self instvar node_
puts "t=[$ns now]: node [$node_ id] received ping answer from \
$from with round-trip-time $rtt ms."
}
proc new-pings { i k t fid prio } {
global ns ping h n num_cos ping_pkt_size
global NbrFLC
set ping(r$i) [new Agent/Ping]
$ping(r$i) set packetSize_ $ping_pkt_size
$ping(r$i) set fid_ $fid
$ping(r$i) set prio_ $prio
set h_n [expr $i % $NbrFLC]
$ns attach-agent $n($k) $ping(r$i)
$ns at $t "$ping(r$i) send"
set ping(f$i) [new Agent/Ping]
$ping(f$i) set packetSize_ $ping_pkt_size
$ping(f$i) set fid_ $fid
$ping(f$i) set prio_ $prio
$ns attach-agent $h($h_n) $ping(f$i)
$ns connect $ping(f$i) $ping(r$i)
}
# Markovian on/off TCP traffic
proc new-rl-tcp-exp { i k t } {
global ns rltcpexp h n mtu tcp_data_prio tcp_fid set_prio ack_prio set_fid ack_fid tcp_window_size tcp_init_window
global traffic_duration NbrFLC
set rs [new Agent/TCP/Linux]
# set rs [new Agent/TCP/FullTcp/Sack]
# Print TCP parameters
# Window_ sets the ssthreshold. Terrestrial TCP senders use as
# initial ssthreshold value of 38 pkts as it is common.
# Since the advwindow is implemented this value is only used to initialize the value of
# ssthreshold and must be sufficient high to not disturb the operation of TCP sender
# Note that cwnd_ is bounded by min (window_, advwindow_, maxcwnd_)
# For Satelite TCP sender a high value is set to analize in TCP SACk baseline the Slow Start
# behaviour over LFN satelite networks preventing the smooth transition between Slow Start
# and Congestion Avoidance phases.
# $rs set window_ 20
$rs set window_ $tcp_window_size
# $rs set window_ $buff_size_pkts
if { $rltcpexp(index) == 0 } {
puts "TCP slow start threshold: [$rs set window_]"
}
# $rs set tcpTick_ 0.01
if { $rltcpexp(index) == 0 } {
puts "TCP tick: [$rs set tcpTick_]"
}
# default value
# $rs set windowInit_ 2
# $rs set windowInit_ 3
$rs set windowInit_ $tcp_init_window
# $rs set windowInit_ $buff_size_pkts
if { $rltcpexp(index) == 0 } {
puts "TCP initial window size: [$rs set windowInit_]"
}
# puts "TCP initial window size: [$rs set wnd_init_]"
# The advwindow_ initial value is set the initial ssthreshold value in TCP senders. This
# value is used by TCP sender until the receiver updates its value to the advertize receiver
# window
# $rs set advwindow_ [$rs set window_]
# puts "TCP advertised window size: [$rs set advwindow_]"
# The advertised window is simulated by simply telling the sender a bound on the window size (wnd_).
# In real TCP, a user process performing a read (via PRU_RCVD) calls tcp_output each time to (possibly) send a window
# update. Here we don't have a user process, so we simulate a user process always ready to consume all the receive buffer *
# Notes: wnd_, wnd_init_, cwnd_, ssthresh_ are in segment units, sequence and ack numbers are in byte units
# puts "TCP advertised window size: [$rs set wnd_]"
# maxcwnd_ is the upper bound of TCP sender cwnd_ . The cwnd_ is bounded by
# min (advwindow_, maxcwnd_)
# $rs set maxcwnd_ 5000
if { $rltcpexp(index) == 0 } {
puts "TCP maximum congestion window size: [$rs set maxcwnd_]"
}
$rs set tcpip_base_hdr_size_ 40
$rs set segsize_ [expr $mtu-[$rs set tcpip_base_hdr_size_]]
$rs set packetSize_ [expr $mtu-[$rs set tcpip_base_hdr_size_]]
$rs set fid_ $tcp_fid
$rs set prio_ $tcp_data_prio
set h_n [expr $i % $NbrFLC]
$ns attach-agent $n($k) $rs
set rsink [new Agent/TCPSink]
$rsink set set_prio_ $set_prio
$rsink set ack_prio_ $ack_prio
$rsink set set_fid_ $set_fid
$rsink set ack_fid_ $ack_fid
$ns attach-agent $h($h_n) $rsink
$ns connect $rs $rsink
set rltcpexp(s$i) [new Application/Traffic/Exponential]
$rltcpexp(s$i) attach-agent $rs
# This is the default packetSize value
# $rltcpexp(s$i) set packetSize_ $mtu
$rltcpexp(s$i) set packetSize_ [expr $mtu-[$rs set tcpip_base_hdr_size_]]
$rltcpexp(s$i) set rate_ [expr $rl_TCP_packets_rate*8*$rl_msg_size]
$rltcpexp(s$i) set burst_time_ 0.001
$rltcpexp(s$i) set idle_time_ [expr 1/$rl_TCP_packets_rate]
$ns at $t "$rltcpexp(s$i) start"
$ns at [expr $t + $traffic_duration] "$rltcpexp(s$i) stop"
set rltcpexp(index) [expr $rltcpexp(index) + 1]
}
proc new-fl-tcp-exp { i k t } {
global ns fltcpexp h n mtu tcp_data_prio tcp_fid set_prio ack_prio set_fid ack_fid tcp_window_size tcp_init_window
global traffic_duration NbrFLC
set fs [new Agent/TCP/Linux]
# set fs [new Agent/TCP/FullTcp/Sack]
$fs set windowInit_ $tcp_init_window
$fs set window_ $tcp_window_size
$fs set tcpip_base_hdr_size_ 40
$fs set segsize_ [expr $mtu-[$fs set tcpip_base_hdr_size_]]
$fs set packetSize_ [expr $mtu-[$fs set tcpip_base_hdr_size_]]
# $fs set fid_ [expr 1 + ($i % ($num_cos-1))]
$fs set fid_ $tcp_fid
$fs set prio_ $tcp_data_prio
set h_n [expr $i % $NbrFLC]
$ns attach-agent $h($h_n) $fs
set fsink [new Agent/TCPSink]
$fsink set set_prio_ $set_prio
$fsink set ack_prio_ $ack_prio
$fsink set set_fid_ $set_fid
$fsink set ack_fid_ $ack_fid
$ns attach-agent $n($k) $fsink
$ns connect $fs $fsink
set fltcpexp(s$i) [new Application/Traffic/Exponential]
$fltcpexp(s$i) attach-agent $fs
# This is the default packetSize value
$fltcpexp(s$i) set packetSize_ [expr $mtu-[$fs set tcpip_base_hdr_size_]]
$fltcpexp(s$i) set rate_ [expr $fl_TCP_packets_rate*8*$fl_msg_size]
$fltcpexp(s$i) set burst_time_ 0.001
$fltcpexp(s$i) set idle_time_ [expr 1/$fl_TCP_packets_rate]
$ns at $t "$fltcpexp(s$i) start"
$ns at [expr $t + $traffic_duration] "$fltcpexp(s$i) stop"
set fltcpexp(index) [expr $fltcpexp(index) + 1]
}
# Bulk TCP Poisson traffic
proc new-rl-tcp-poisson { i k t } {
global ns rltcpexp h n mtu tcp_data_prio tcp_fid set_prio ack_prio set_fid ack_fid tcp_window_size tcp_init_window
global traffic_duration NbrFLC
set rs [new Agent/TCP/Linux]
# set rs [new Agent/TCP/FullTcp/Sack]
# Print TCP parameters
# Window_ sets the ssthreshold. Terrestrial TCP senders use as
# initial ssthreshold value of 38 pkts as it is common.
# Since the advwindow is implemented this value is only used to initialize the value of
# ssthreshold and must be sufficient high to not distub the operation of TCP sender
# Note that cwnd_ is bounded by min (window_, advwindow_, maxcwnd_)
# For Satelite TCP sender a high value is set to analize in TCP SACk baseline the Slow Start
# behaviour over LFN satelite networks preventing the smooth transition between Slow Start
# and Congestion Avoidance phases.
# $rs set window_ 20
$rs set window_ $tcp_window_size
# $rs set window_ $buff_size_pkts
if { $rltcpexp(index) == 0 } {
puts "TCP slow start threshold: [$rs set window_]"
}
# $rs set tcpTick_ 0.01
if { $rltcpexp(index) == 0 } {
puts "TCP tick: [$rs set tcpTick_]"
}
# default value
# $rs set windowInit_ 2
# $rs set windowInit_ 3
$rs set windowInit_ $tcp_init_window
# $rs set windowInit_ $buff_size_pkts
if { $rltcpexp(index) == 0 } {
puts "TCP initial window size: [$rs set windowInit_]"
}
# puts "TCP initial window size: [$rs set wnd_init_]"
# The advwindow_ initial value is set the initial ssthreshold value in TCP senders. This
# value is used by TCP sender until the receiver updates its value to the advertize receiver
# window
# $rs set advwindow_ [$rs set window_]
# puts "TCP advertised window size: [$rs set advwindow_]"
# The advertised window is simulated by simply telling the sender a bound on the window size (wnd_).
# In real TCP, a user process performing a read (via PRU_RCVD) calls tcp_output each time to (possibly) send a window
# update. Here we don't have a user process, so we simulate a user process always ready to consume all the receive buffer *
# Notes: wnd_, wnd_init_, cwnd_, ssthresh_ are in segment units, sequence and ack numbers are in byte units
# puts "TCP advertised window size: [$rs set wnd_]"
# maxcwnd_ is the upper bound of TCP sender cwnd_ . The cwnd_ is bounded by
# min (advwindow_, maxcwnd_)
# $rs set maxcwnd_ 5000
if { $rltcpexp(index) == 0 } {
puts "TCP maximum congestion window size: [$rs set maxcwnd_]"
}
$rs set tcpip_base_hdr_size_ 40
$rs set segsize_ [expr $mtu-[$rs set tcpip_base_hdr_size_]]
$rs set packetSize_ [expr $mtu-[$rs set tcpip_base_hdr_size_]]
$rs set fid_ $tcp_fid
$rs set prio_ $tcp_data_prio
set h_n [expr $i % $NbrFLC]
$ns attach-agent $n($k) $rs
set rsink [new Agent/TCPSink]
$rsink set set_prio_ $set_prio
$rsink set ack_prio_ $ack_prio
$rsink set set_fid_ $set_fid
$rsink set ack_fid_ $ack_fid
$ns attach-agent $h($h_n) $rsink
$ns connect $rs $rsink
set rltcpexp(s$i) [new Application/Traffic/Exponential]
$rltcpexp(s$i) attach-agent $rs
# This is the default packetSize value
# $rltcpexp(s$i) set packetSize_ $mtu
# $rltcpexp(s$i) set packetSize_ [expr $mtu-[$rs set tcpip_base_hdr_size_]]
# $rltcpexp(s$i) set packetSize_ 156250
$rltcpexp(s$i) set packetSize_ $rl_packet_size
# $rltcpexp(s$i) set packetSize_ [expr 1 + [ns-random] % [$rs set packetSize_]]
# The Exponential On/Off generator can be configured to behave as a Poisson process by setting the variable burst_time
# to 0 and the variable rate_ to a very large value. The C++ code guarantees that even if the burst time is zero, at least one
# packet is sent. Additionally, the next interarrival time is the sum of the assumed packet transmission time (governed by the
# variable rate_) and the random variate corresponding to idle_time_. Therefore, to make the first term in the sum very
# small, make the burst rate very large so that the transmission time is negligible compared to the typical idle times.
$rltcpexp(s$i) set rate_ 10000Mb
$rltcpexp(s$i) set burst_time_ 0
$rltcpexp(s$i) set idle_time_ [expr 1/$rl_TCP_packets_rate]
$ns at $t "$rltcpexp(s$i) start"
$ns at [expr $t + $traffic_duration] "$rltcpexp(s$i) stop"
set rltcpexp(index) [expr $rltcpexp(index) + 1]
}
proc new-fl-tcp-poisson { i k t } {
global ns fltcpexp h n mtu tcp_data_prio tcp_fid set_prio ack_prio set_fid ack_fid tcp_window_size tcp_init_window
global traffic_duration no_terminals NbrFLC
set fs [new Agent/TCP/Linux]
# set fs [new Agent/TCP/FullTcp/Sack]
$fs set windowInit_ $tcp_init_window
$fs set window_ $tcp_window_size
$fs set tcpip_base_hdr_size_ 40
$fs set segsize_ [expr $mtu-[$fs set tcpip_base_hdr_size_]]
$fs set packetSize_ [expr $mtu-[$fs set tcpip_base_hdr_size_]]
$fs set fid_ $tcp_fid
$fs set prio_ $tcp_data_prio
set h_n [expr $i % $NbrFLC]
$ns attach-agent $h($h_n) $fs
set fsink [new Agent/TCPSink]
$fsink set set_prio_ $set_prio
$fsink set ack_prio_ $ack_prio
$fsink set set_fid_ $set_fid
$fsink set ack_fid_ $ack_fid
$ns attach-agent $n($k) $fsink
$ns connect $fs $fsink
set fltcpexp(s$i) [new Application/Traffic/Exponential]
$fltcpexp(s$i) attach-agent $fs
# This is the default packetSize value
# $fltcpexp(s$i) set packetSize_ 156250
$fltcpexp(s$i) set packetSize_ $fl_packet_size
# $fltcpexp(s$i) set packetSize_ [expr $mtu-[$fs set tcpip_base_hdr_size_]]
# $fltcpexp(s$i) set packetSize_ [expr 1 + [ns-random] % [$fs set packetSize_]]
# The Exponential On/Off generator can be configured to behave as a Poisson process by setting the variable burst_time
# to 0 and the variable rate_ to a very large value. The C++ code guarantees that even if the burst time is zero, at least one
# packet is sent. Additionally, the next interarrival time is the sum of the assumed packet transmission time (governed by the
# variable rate_) and the random variate corresponding to idle_time_. Therefore, to make the first term in the sum very
# small, make the burst rate very large so that the transmission time is negligible compared to the typical idle times.
$fltcpexp(s$i) set rate_ 10000Mb
$fltcpexp(s$i) set burst_time_ 0
$fltcpexp(s$i) set idle_time_ [expr 1/$fl_TCP_packets_rate]
$ns at $t "$fltcpexp(s$i) start"
$ns at [expr $t + $traffic_duration] "$fltcpexp(s$i) stop"
set fltcpexp(index) [expr $fltcpexp(index) + 1]
}
## Bulk TCP traffic ##
proc new-rl-tcp { i k t } {
global ns rltcp rlftp rsink f h n mtu tcp_data_prio tcp_fid set_prio ack_prio set_fid ack_fid tcp_window_size tcp_init_window
global NbrFLC tcp_duration
set rltcp($rltcp(index)) [new Agent/TCP/Linux]
# set rltcp($rltcp(index)) [new Agent/TCP/FullTcp/Sack]
$rltcp($rltcp(index)) set class_ $tcp_fid
# Print TCP parameters
# Window_ sets the ssthreshold. Terrestrial TCP senders use as
# initial ssthreshold value of 38 pkts as it is common.
# Since the advwindow is implemented this value is only used to initialize the value of
# ssthreshold and must be sufficient high to not distub the operation of TCP sender
# Note that cwnd_ is bounded by min (window_, advwindow_, maxcwnd_)
# For Satelite TCP sender a high value is set to analize in TCP SACk baseline the Slow Start
# behaviour over LFN satelite networks preventing the smooth transition between Slow Start
# and Congestion Avoidance phases.
# $rltcp($rltcp(index)) set window_ 20
$rltcp($rltcp(index)) set window_ $tcp_window_size
# $rltcp($rltcp(index)) set window_ $buff_size_pkts
if { $rltcp(index) == 0 } {
puts "TCP slow start threshold: [$rltcp($rltcp(index)) set window_]"
}
# $rltcp($rltcp(index)) set tcpTick_ 0.01
if { $rltcp(index) == 0 } {
puts "TCP tick: [$rltcp($rltcp(index)) set tcpTick_]"
}
# default value
# $rltcp($rltcp(index)) set windowInit_ 2
# $rltcp($rltcp(index)) set windowInit_ 3
$rltcp($rltcp(index)) set windowInit_ $tcp_init_window
# $rltcp($rltcp(index)) set windowInit_ $buff_size_pkts
if { $rltcp(index) == 0 } {
puts "TCP initial window size: [$rltcp($rltcp(index)) set windowInit_]"
}
# puts "TCP initial window size: [$rltcp($rltcp(index)) set wnd_init_]"
# The advwindow_ initial value is set the initial ssthreshold value in TCP senders. This
# value is used by TCP sender until the receiver updates its value to the advertize receiver
# window
# $rltcp($rltcp(index)) set advwindow_ [$rltcp($rltcp(index)) set window_]
# puts "TCP advertised window size: [$rltcp($rltcp(index)) set advwindow_]"
# The advertised window is simulated by simply telling the sender a bound on the window size (wnd_).
# In real TCP, a user process performing a read (via PRU_RCVD) calls tcp_output each time to (possibly) send a window
# update. Here we don't have a user process, so we simulate a user process always ready to consume all the receive buffer *
# Notes: wnd_, wnd_init_, cwnd_, ssthresh_ are in segment units, sequence and ack numbers are in byte units
# puts "TCP advertised window size: [$rltcp($rltcp(index)) set wnd_]"
# maxcwnd_ is the upper bound of TCP sender cwnd_ . The cwnd_ is bounded by
# min (advwindow_, maxcwnd_)
# $rltcp($rltcp(index)) set maxcwnd_ 5000
if { $rltcp(index) == 0 } {
puts "TCP maximum congestion window size: [$rltcp($rltcp(index)) set maxcwnd_]"
}
$rltcp($rltcp(index)) set tcpip_base_hdr_size_ 40
$rltcp($rltcp(index)) set segsize_ [expr $mtu-[$rltcp($rltcp(index)) set tcpip_base_hdr_size_]]
$rltcp($rltcp(index)) set packetSize_ [expr $mtu-[$rltcp($rltcp(index)) set tcpip_base_hdr_size_]]
$rltcp($rltcp(index)) set fid_ $tcp_fid
$rltcp($rltcp(index)) set prio_ $tcp_data_prio
set h_n [expr $i % $NbrFLC]
$ns attach-agent $n($k) $rltcp($rltcp(index))
# Let's trace some TCP variables
# $rltcp($rltcp(index)) attach $f
# $rltcp($rltcp(index)) tracevar cwnd_
# $rltcp($rltcp(index)) tracevar ssthresh_
# $rltcp($rltcp(index)) tracevar ack_
# $rltcp($rltcp(index)) tracevar maxseq_
set rsink($rltcp(index)) [new Agent/TCPSink]
$rsink($rltcp(index)) set set_prio_ $set_prio
$rsink($rltcp(index)) set ack_prio_ $ack_prio
$rsink($rltcp(index)) set set_fid_ $set_fid
$rsink($rltcp(index)) set ack_fid_ $ack_fid
$ns attach-agent $h($h_n) $rsink($rltcp(index))
$ns connect $rltcp($rltcp(index)) $rsink($rltcp(index))
set rlftp($rltcp(index)) [new Application/FTP]
$rlftp($rltcp(index)) attach-agent $rltcp($rltcp(index))
$ns at $t "$rlftp($rltcp(index)) start"
$ns at [expr $t + $tcp_duration] "$rlftp($rltcp(index)) stop"
set rltcp(index) [expr $rltcp(index) + 1]
}
proc new-fl-tcp { i k t } {
global ns fltcp flftp fsink f h n mtu tcp_data_prio tcp_fid set_prio ack_prio set_fid ack_fid tcp_window_size tcp_init_window
global no_terminals NbrFLC tcp_duration
set fltcp($fltcp(index)) [new Agent/TCP/Linux]
# set fltcp($fltcp(index)) [new Agent/TCP/FullTcp/Sack]
$fltcp($fltcp(index)) set class_ $tcp_fid
$fltcp($fltcp(index)) set windowInit_ $tcp_init_window
$fltcp($fltcp(index)) set window_ $tcp_window_size
$fltcp($fltcp(index)) set tcpip_base_hdr_size_ 40
$fltcp($fltcp(index)) set segsize_ [expr $mtu-[$fltcp($fltcp(index)) set tcpip_base_hdr_size_]]
$fltcp($fltcp(index)) set packetSize_ [expr $mtu-[$fltcp($fltcp(index)) set tcpip_base_hdr_size_]]
$fltcp($fltcp(index)) set fid_ $tcp_fid
$fltcp($fltcp(index)) set prio_ $tcp_data_prio
set h_n [expr $i % $NbrFLC]
$ns attach-agent $h($h_n) $fltcp($fltcp(index))
# Let's trace some TCP variables
# $fltcp($fltcp(index)) attach $f
# $fltcp($fltcp(index)) tracevar cwnd_
# $fltcp($fltcp(index)) tracevar ssthresh_
# $fltcp($fltcp(index)) tracevar ack_
# $fltcp($fltcp(index)) tracevar maxseq_
set fsink($fltcp(index)) [new Agent/TCPSink]
$fsink($fltcp(index)) set set_prio_ $set_prio
$fsink($fltcp(index)) set ack_prio_ $ack_prio
$fsink($fltcp(index)) set set_fid_ $set_fid
$fsink($fltcp(index)) set ack_fid_ $ack_fid
$ns attach-agent $n($k) $fsink($fltcp(index))
$ns connect $fltcp($fltcp(index)) $fsink($fltcp(index))
set flftp($fltcp(index)) [new Application/FTP]
$flftp($fltcp(index)) attach-agent $fltcp($fltcp(index))
$ns at $t "$flftp($fltcp(index)) start"
$ns at [expr $t + $tcp_duration] "$flftp($fltcp(index)) stop"
set fltcp(index) [expr $fltcp(index) + 1]
}
######### Web Traffic ######################################
# https://www.keycdn.com/support/the-growth-of-web-page-size/
# set num_conn 7
set num_conn 1
set req_size 320
# set objnum 43
set objnum 0
set obj_size [new RandomVariable/Pareto]
set obj_maxsize 15000
set last_web_done -1
set num_webs 0
$obj_size set shape_ 1.2
$obj_size set avg_ 7187
set request_time [new RandomVariable/Uniform]
$request_time set min_ 0
$request_time set max_ $traffic_duration
set min_web_duration 10000
set max_web_duration 0
set web_duration_filename "web_durations.txt"
Application/TcpApp instproc http-send-req-index {} {
global ns req_size objnum obj_num duration testing
global page_req_time page_time num_conn page_req_time
$self instvar apps tcp id
set page_req_time($id) [$ns now]
if { $testing == "1" } {
puts "[$ns now] $objnum $id + INDEX"
}
$ns at [$ns now] "$self send $req_size \"$apps http-req-recv-index\""
}
Application/TcpApp instproc http-req-recv-index { } {
global ns obj_size obj_maxsize
$self instvar appc
set size [expr int([$obj_size value])]
if {$size > $obj_maxsize} {
set size $obj_maxsize
}
$ns at [$ns now] "$self send $size \"$appc http-recv-index\""
}
Application/TcpApp instproc http-send-req {objid} {
global ns req_size objnum obj_num web_duration testing min_web_duration
global page_req_time page_time num_conn last_web_done max_web_duration num_webs
$self instvar apps tcp id
if { $objid != "NULL" && $testing == "1" } {
puts "[$ns now] $objid $id - $obj_num($id)"
}
incr obj_num($id) -1
if { $obj_num($id) >= 0} {
if { $testing == "1" } {
puts "[$ns now] $obj_num($id) $id +"
}
$ns at [$ns now] "$self send $req_size \"$apps http-req-recv $obj_num($id)\""
return
}
[$self set tcp] close
if { $obj_num($id) == [expr -$num_conn-1]} {
set last_web_done $num_webs
set web_duration($num_webs) [expr [$ns now] - $page_req_time($id)]
if { $web_duration($num_webs) < $min_web_duration } {
set min_web_duration $web_duration($num_webs)
}
if { $web_duration($num_webs) > $max_web_duration } {
set max_web_duration $web_duration($num_webs)
}
if { $testing == "1" } {
puts "end $id $web_duration($num_webs) [$ns now] $page_req_time($id)"
}
set num_webs [expr $num_webs + 1]
}
}
Application/TcpApp instproc http-recv-index {} {
global ns objnum testing
$self instvar id
if { $testing == "1" } {
puts "[$ns now] $objnum $id - INDEX"
}
$ns at [$ns now] "$self new-http-session"
$ns at [$ns now] "$self http-send-req NULL"
}
Application/TcpApp instproc http-req-recv {obj_id} {
global ns obj_size obj_num obj_maxsize
$self instvar appc id
set size [expr int([$obj_size value])]
if { $size > $obj_maxsize } {
set size $obj_maxsize
}
$ns at [$ns now] "$self send $size \"$appc http-send-req $obj_id\""
}
Application/TcpApp instproc new-http-session { } {
global ns objnum tcp num_conn obj_num mtu data_prio tcp_fid
global page_req_time
$self instvar id n1 n2
set now [$ns now]
for {set i 0} {$i< $num_conn} {incr i} {
set tcpc [new Agent/TCP/FullTcp/Sack]
$tcpc set tcpip_base_hdr_size_ 40
$tcpc set segsize_ [expr $mtu-[$tcpc set tcpip_base_hdr_size_]]
# $tcpc set fid_ $id
$tcpc set fid_ $tcp_fid
$tcpc set prio_ $data_prio
set tcps [new Agent/TCP/FullTcp/Sack]
$tcps set tcpip_base_hdr_size_ 40
$tcps set segsize_ [expr $mtu-[$tcps set tcpip_base_hdr_size_]]
# $tcps set fid_ $id
$tcps set fid_ $tcp_fid
$tcps set prio_ $data_prio
set appc [new Application/TcpApp $tcpc]
set apps [new Application/TcpApp $tcps]
$ns attach-agent $n1 $tcpc
$ns attach-agent $n2 $tcps
$ns connect $tcpc $tcps
$tcps listen
$appc connect $apps
$appc set apps $apps
$apps set appc $appc
$appc set tcp $tcpc
$appc set id $id
$apps set id $id
$ns at $now "$appc http-send-req NULL"
}
set obj_num($id) $objnum
}
proc new-http-session { id n1 n2 } {
global ns mtu data_prio tcp_fid
set now [$ns now]
set tcpc [new Agent/TCP/FullTcp/Sack]
$tcpc set tcpip_base_hdr_size_ 40
$tcpc set segsize_ [expr $mtu-[$tcpc set tcpip_base_hdr_size_]]
$tcpc set fid_ $id
$tcpc set prio_ $data_prio
set tcps [new Agent/TCP/FullTcp/Sack]
$tcps set tcpip_base_hdr_size_ 40
$tcps set segsize_ [expr $mtu-[$tcps set tcpip_base_hdr_size_]]
# $tcps set fid_ $id
$tcps set fid_ $tcp_fid
$tcps set prio_ $data_prio
set appc [new Application/TcpApp $tcpc]
set apps [new Application/TcpApp $tcps]
$ns attach-agent $n1 $tcpc
$ns attach-agent $n2 $tcps
$ns connect $tcpc $tcps
$tcps listen