Skip to content

Commit a3ae624

Browse files
committed
I think it now works gd
1 parent 9750bb6 commit a3ae624

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

mptcpanalyzer/cli.py

+35-18
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ def do_qualify_reinjections(self, line):
578578
)
579579

580580
# keep only those that matched both for now
581+
582+
df_all["redundant"] = False
581583
df = df_all[ df_all._merge == "both" ]
582584

583585
df.to_excel("temp.xls")
@@ -630,7 +632,6 @@ def _print_reinjection_comparison(original_packet, reinj):
630632
# df["best_reinjection"] = np.nan # or -1
631633

632634
# mark the
633-
df["redundant"] = False
634635

635636
# print(df.columns)
636637

@@ -643,7 +644,7 @@ def _print_reinjection_comparison(original_packet, reinj):
643644
# print("successful reinjections" % len(reinjected_in))
644645

645646
# select only packets that have been reinjected
646-
reinjected_packets = sender_df.dropna(axis='index', subset=[ _sender("reinjected_in") ])
647+
reinjected_packets = sender_df.dropna(axis='index', subset=[ _sender("reinjection_of") ])
647648

648649
print("%d reinjected packets" % len(reinjected_packets))
649650

@@ -655,25 +656,45 @@ def _print_reinjection_comparison(original_packet, reinj):
655656
for row in reinjected_packets.itertuples():
656657
# here we look at all the reinjected packets
657658

658-
print("full row %r" % (row,))
659+
# print("full row %r" % (row,))
659660

660661
# if there are packets in _receiver(reinjected_in), it means the reinjections
661662
# arrived before other similar segments and thus these segments are useless
662663
# it should work because
663-
useless_reinjections = getattr(row, _receiver("reinjected_in"), [])
664+
# useless_reinjections = getattr(row, _receiver("reinjected_in"), [])
664665

665-
print("useless_reinjections listing %r" % (useless_reinjections,))
666-
try:
667-
useless_reinjections = [] if math.isnan(useless_reinjections) else useless_reinjections
668-
except TypeError as e:
669-
# This value cannot be a list.
670-
pass
666+
# if it was correctly mapped
667+
# row._merge doesn't exist ?
668+
if row._1 != "both":
669+
# TODO count missed classifications ?
670+
log.debug("reinjection %d could not be mapped, giving up..." % (row.packetid))
671+
continue
672+
673+
initial_packetid = row.reinjection_of[0]
674+
# print("initial_packetid = %r %s" % (initial_packetid, type(initial_packetid)))
675+
676+
#
677+
original_packet = df_all.loc[ df_all.packetid == initial_packetid ].iloc[0]
678+
679+
if original_packet._merge != "both":
680+
# TODO count missed classifications ?
681+
log.debug("Original packet %d could not be mapped, giving up..." % (original_packet.packetid))
682+
continue
683+
684+
685+
orig_arrival = getattr(original_packet, _receiver("reltime"))
686+
reinj_arrival = getattr(row, _receiver("reltime"))
687+
688+
689+
# print("useless_reinjections listing %r" % (useless_reinjections,))
690+
691+
# for reinjection_pktid in useless_reinjections:
692+
# print("looking at receiver_pktid= %r %s" % (reinjection_pktid, type(reinjection_pktid)))
671693

672-
print("useless_reinjections listing %r" % (useless_reinjections,))
673694

674-
for reinjection_pktid in useless_reinjections:
675-
print("looking at receiver_pktid= %r %s" % (reinjection_pktid, type(reinjection_pktid)))
676-
sender_df.loc[ sender_df[ _receiver("packetid")] == reinjection_pktid, "redundant"] = True
695+
if orig_arrival < reinj_arrival:
696+
print("GOT A MATCH")
697+
sender_df.loc[ sender_df[ _sender("packetid")] == row.packetid, "redundant"] = True
677698

678699

679700
print("results: ", df[ df.redundant == True] )
@@ -702,11 +723,7 @@ def _print_reinjection_comparison(original_packet, reinj):
702723
# loc ? this is an array, sort it and take the first one ?
703724
# initial_packetid = getattr(row, _sender("reinjection_of")),
704725
initial_packetid = row.reinjection_of[0]
705-
# getattr(row, _sender("reinjection_of")),
706-
# print("initial_packetid = %r %s" % (row.reinjection_of, type(row.reinjection_of)))
707726
print("initial_packetid = %r %s" % (initial_packetid, type(initial_packetid)))
708-
# print("initial_packetid = %r" % (initial_packetid[0]))
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)
710727

711728
original_packet = df_all.loc[ df_all.packetid == initial_packetid ].iloc[0]
712729
print("original packet = %r %s" % (original_packet, type(original_packet)))

0 commit comments

Comments
 (0)