def main(args):
  with open(args.input) as input_file:
    trace = parse(input_file)
    # TODO(cs): binary search instead of linear?
    while len(trace) > 0 and trace[0].label_id < args.ti_id:
      trace.pop(0)

    ti_event = trace[0]
    if type(ti_event) != replay_events.TrafficInjection:
      raise ValueError("Event %s with is not a TrafficInjection" % str(ti_event))

    pkt_fingerprint = DPFingerprint.from_pkt(ti_event.dp_event.packet)

    for event in trace:
      t = type(event)
      if t in dp_class_to_filter and dp_class_to_filter[t](event, pkt_fingerprint):
        for field in default_fields:
          field_formatters[field](event)
dataset/ETHPy150Open ucb-sts/sts/tools/trace_traffic_injection.py/main/original