@@ -568,7 +568,7 @@ def do_qualify_reinjections(self, line):
568
568
569
569
args = parser .parse_args (shlex .split (line ))
570
570
571
- df = load_merged_streams_into_pandas (
571
+ df_all = load_merged_streams_into_pandas (
572
572
args .pcap1 ,
573
573
args .pcap2 ,
574
574
args .mptcpstream ,
@@ -577,6 +577,34 @@ def do_qualify_reinjections(self, line):
577
577
tshark_config = self .tshark_config
578
578
)
579
579
580
+ # keep only those that matched both for now
581
+ df = df_all [ df_all ._merge == "both" ]
582
+
583
+ df .to_excel ("temp.xls" )
584
+
585
+ def _print_reinjection_comparison (original_packet , reinj ):
586
+ """
587
+ Expects tuples of original and reinjection packets
588
+ """
589
+ # original_packet = sender_df.loc[ sender_df.packetid == initial_packetid, ].iloc[0]
590
+ row = reinj
591
+ # print(original_packet["packetid"])
592
+ print ("packet {pktid} is a successful_reinjection of {initial_packetid}."
593
+ " It arrived at {reinjection_arrival} to compare with {original_arrival}"
594
+ " while being transmitted at {reinjection_start} to compare with {original_start}"
595
+ .format (
596
+ pktid = getattr (row , _sender ("packetid" )),
597
+ initial_packetid = initial_packetid ,
598
+
599
+ reinjection_start = getattr (row , _sender ("abstime" )),
600
+ reinjection_arrival = getattr (row , _receiver ("abstime" )),
601
+ original_start = original_packet [ _sender ("abstime" ) ],
602
+ original_arrival = original_packet [ _receiver ("abstime" ) ]
603
+ ))
604
+
605
+ if getattr (row , _receiver ("abstime" )) > original_packet [ _receiver ("abstime" ) ]:
606
+ print ("BUG: this is not a valid reinjection after all ?" )
607
+
580
608
print ("debugging " )
581
609
print ("dataframe size = %d" % len (df ))
582
610
@@ -609,34 +637,29 @@ def do_qualify_reinjections(self, line):
609
637
for destination in ConnectionRoles :
610
638
self .poutput ("looking for reinjections towards mptcp %s" % destination )
611
639
612
- receiver_df = df [ df .mptcpdest == destination ]
613
- sender_df = df [ df .mptcpdest == swap_role (destination )]
614
- # sender_df = df[ df.mptcpdest == swap_role(destination)]
615
-
616
- print (sender_df [ sender_df .reinjected_in .notna () ][["packetid" , "reinjected_in" ]])
640
+ sender_df = df [df .mptcpdest == destination ]
617
641
642
+ # print(sender_df[ sender_df.reinjected_in.notna() ][["packetid", "reinjected_in"]])
618
643
# print("successful reinjections" % len(reinjected_in))
619
644
620
645
# select only packets that have been reinjected
621
646
reinjected_packets = sender_df .dropna (axis = 'index' , subset = [ _sender ("reinjected_in" ) ])
622
647
623
648
print ("%d reinjected packets" % len (reinjected_packets ))
624
- # packetid=762, packetid_receiver=783
625
- with pd .option_context ('display.max_rows' , None , 'display.max_columns' , 3 ):
626
649
627
- # print( "%r %r" % _receiver(["reinjected_in", "reinjection_of"]))
650
+ with pd . option_context ( 'display.max_rows' , None , 'display.max_columns' , 300 ):
628
651
629
652
print (reinjected_packets [["packetid" , "packetid_receiver" , * _receiver (["reinjected_in" , "reinjection_of" ])]].head ())
630
653
631
654
632
655
for row in reinjected_packets .itertuples ():
633
656
# here we look at all the reinjected packets
634
- #
635
657
636
658
print ("full row %r" % (row ,))
637
659
638
660
# if there are packets in _receiver(reinjected_in), it means the reinjections
639
661
# arrived before other similar segments and thus these segments are useless
662
+ # it should work because
640
663
useless_reinjections = getattr (row , _receiver ("reinjected_in" ), [])
641
664
642
665
print ("useless_reinjections listing %r" % (useless_reinjections ,))
@@ -646,24 +669,17 @@ def do_qualify_reinjections(self, line):
646
669
# This value cannot be a list.
647
670
pass
648
671
649
- print ("useless_reinjections listing %r" % (useless_reinjections ,))
672
+ print ("useless_reinjections listing %r" % (useless_reinjections ,))
650
673
651
674
for reinjection_pktid in useless_reinjections :
652
- # receiver_pktid
653
675
print ("looking at receiver_pktid= %r %s" % (reinjection_pktid , type (reinjection_pktid )))
654
- sender_df .loc [ sender_df [ _sender ("packetid" )] == reinjection_pktid ]["redundant" ] = True
655
- # print("found:", )
656
- # redundant = 1
657
- # print("result =", df["packetid" + RECEIVER_SUFFIX == receiver_pktid, "redundant"])
676
+ sender_df .loc [ sender_df [ _receiver ("packetid" )] == reinjection_pktid , "redundant" ] = True
658
677
659
678
660
679
print ("results: " , df [ df .redundant == True ] )
661
680
662
-
663
681
# TODO we now need to display successful reinjections
664
- reinjections = sender_df [ pd .notnull (
665
- sender_df [ _sender ("reinjection_of" ) ]
666
- ) ]
682
+ reinjections = sender_df [ pd .notnull (sender_df [ _sender ("reinjection_of" ) ]) ]
667
683
668
684
print ("=================================="
669
685
"===== TESTING ====="
@@ -675,6 +691,7 @@ def do_qualify_reinjections(self, line):
675
691
successful_reinjections = reinjections [ reinjections .redundant == False ]
676
692
677
693
print ("%d successful reinjections" % len (successful_reinjections ))
694
+ print (successful_reinjections [ _sender (["packetid" , "reinjection_of" ]) + _receiver (["packetid" ]) ])
678
695
679
696
# res2 = res2[pd.notnull(res["reinjected_in"])]
680
697
# df[ df.redundant == False] && df["reinjected_in" + RECEIVER_SUFFIX])
@@ -689,21 +706,12 @@ def do_qualify_reinjections(self, line):
689
706
# print("initial_packetid = %r %s" % (row.reinjection_of, type(row.reinjection_of)))
690
707
print ("initial_packetid = %r %s" % (initial_packetid , type (initial_packetid )))
691
708
# print("initial_packetid = %r" % (initial_packetid[0]))
692
- original_packet = sender_df .loc [ sender_df .packetid == initial_packetid , ].iloc [0 ]
693
- print (original_packet ["packetid" ])
694
- print ("packet {pktid} is a successful_reinjection of {initial_packetid}."
695
- " It arrived at {reinjection_arrival} to compare with {original_arrival}"
696
- " while being transmitted at {reinjection_start} to compare with {original_start}"
697
- .format (
698
- pktid = getattr (row , _sender ("packetid" )),
699
- initial_packetid = initial_packetid ,
700
- reinjection_start = getattr (row , _sender ("abstime" )),
701
- reinjection_arrival = getattr (row , _receiver ("abstime" )),
702
- original_start = original_packet [ _sender ("abstime" ) ],
703
- original_arrival = original_packet [ _receiver ("abstime" ) ]
704
- ))
705
-
706
- if
709
+ # packet 892 is a successful_reinjection of 627. It arrived at 1529916731.5988212 to compare with Series([], Name: abstime_receiver, dtype: float64) while being transmitted at 1529916731.5480695 to compare with Series([], Name: abstime, dtype: float64)
710
+
711
+ original_packet = df_all .loc [ df_all .packetid == initial_packetid ].iloc [0 ]
712
+ print ("original packet = %r %s" % (original_packet , type (original_packet )))
713
+
714
+ _print_reinjection_comparison (original_packet , row )
707
715
708
716
# # set it to the maximum possible value
709
717
# min_rcvtime = sys.maxsize
0 commit comments