Skip to content

Commit 9750bb6

Browse files
committed
committing before changing the classification system
1 parent 3b9f406 commit 9750bb6

File tree

1 file changed

+43
-35
lines changed

1 file changed

+43
-35
lines changed

mptcpanalyzer/cli.py

+43-35
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ def do_qualify_reinjections(self, line):
568568

569569
args = parser.parse_args(shlex.split(line))
570570

571-
df = load_merged_streams_into_pandas(
571+
df_all = load_merged_streams_into_pandas(
572572
args.pcap1,
573573
args.pcap2,
574574
args.mptcpstream,
@@ -577,6 +577,34 @@ def do_qualify_reinjections(self, line):
577577
tshark_config=self.tshark_config
578578
)
579579

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+
580608
print("debugging ")
581609
print("dataframe size = %d" % len(df))
582610

@@ -609,34 +637,29 @@ def do_qualify_reinjections(self, line):
609637
for destination in ConnectionRoles:
610638
self.poutput("looking for reinjections towards mptcp %s" % destination)
611639

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]
617641

642+
# print(sender_df[ sender_df.reinjected_in.notna() ][["packetid", "reinjected_in"]])
618643
# print("successful reinjections" % len(reinjected_in))
619644

620645
# select only packets that have been reinjected
621646
reinjected_packets = sender_df.dropna(axis='index', subset=[ _sender("reinjected_in") ])
622647

623648
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):
626649

627-
# print( "%r %r" % _receiver(["reinjected_in", "reinjection_of"]))
650+
with pd.option_context('display.max_rows', None, 'display.max_columns', 300):
628651

629652
print(reinjected_packets[["packetid", "packetid_receiver", *_receiver(["reinjected_in", "reinjection_of"])]].head())
630653

631654

632655
for row in reinjected_packets.itertuples():
633656
# here we look at all the reinjected packets
634-
#
635657

636658
print("full row %r" % (row,))
637659

638660
# if there are packets in _receiver(reinjected_in), it means the reinjections
639661
# arrived before other similar segments and thus these segments are useless
662+
# it should work because
640663
useless_reinjections = getattr(row, _receiver("reinjected_in"), [])
641664

642665
print("useless_reinjections listing %r" % (useless_reinjections,))
@@ -646,24 +669,17 @@ def do_qualify_reinjections(self, line):
646669
# This value cannot be a list.
647670
pass
648671

649-
print("useless_reinjections listing %r" % (useless_reinjections,))
672+
print("useless_reinjections listing %r" % (useless_reinjections,))
650673

651674
for reinjection_pktid in useless_reinjections:
652-
# receiver_pktid
653675
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
658677

659678

660679
print("results: ", df[ df.redundant == True] )
661680

662-
663681
# 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") ]) ]
667683

668684
print("=================================="
669685
"===== TESTING ====="
@@ -675,6 +691,7 @@ def do_qualify_reinjections(self, line):
675691
successful_reinjections = reinjections[ reinjections.redundant == False ]
676692

677693
print("%d successful reinjections" % len(successful_reinjections))
694+
print(successful_reinjections[ _sender(["packetid", "reinjection_of"]) + _receiver(["packetid"]) ])
678695

679696
# res2 = res2[pd.notnull(res["reinjected_in"])]
680697
# df[ df.redundant == False] && df["reinjected_in" + RECEIVER_SUFFIX])
@@ -689,21 +706,12 @@ def do_qualify_reinjections(self, line):
689706
# print("initial_packetid = %r %s" % (row.reinjection_of, type(row.reinjection_of)))
690707
print("initial_packetid = %r %s" % (initial_packetid, type(initial_packetid)))
691708
# 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)
707715

708716
# # set it to the maximum possible value
709717
# min_rcvtime = sys.maxsize

0 commit comments

Comments
 (0)