Beispiel #1
0
  def show_flow_table(self, dpid):
    topology = self.simulation.topology
    switch = topology.get_switch(dpid)

    dl_types = { 0x0800: "IP",
                 0x0806: "ARP",
                 0x8100: "VLAN",
                 0x88cc: "LLDP",
                 0x888e: "PAE"
                 }
    nw_protos = { 1 : "ICMP", 6 : "TCP", 17 : "UDP" }

    ports = { v: k.replace("OFPP_","") for (k,v) in of.ofp_port_rev_map.iteritems() }

    def dl_type(e):
      d = e.match.dl_type
      if d is None:
        return d
      else:
        return dl_types[d] if d in dl_types else "%x" %d

    def nw_proto(e):
      p = e.match.nw_proto
      return nw_protos[p] if p in nw_protos else p

    def action(a):
      if isinstance(a, ofp_action_output):
        return ports[a.port] if a.port in ports else "output(%d)" % a.port
      else:
        return str(a)
    def actions(e):
      if len(e.actions) == 0:
        return "(drop)"
      else:
        return ", ".join(action(a) for a in e.actions)


    t = Tabular( ("Prio", lambda e: e.priority),
                ("in_port", lambda e: e.match.in_port),
                ("dl_type", dl_type),
                ("dl_src", lambda e: e.match.dl_src),
                ("dl_dst", lambda e: e.match.dl_dst),
                ("nw_proto", nw_proto),
                ("nw_src", lambda e: e.match.nw_src),
                ("nw_dst", lambda e: e.match.nw_dst),
                ("tp_src", lambda e: e.match.tp_src),
                ("tp_dst", lambda e: e.match.tp_dst),
                ("actions", actions),
                )
    t.show(switch.table.entries)
Beispiel #2
0
def main(args):
    # Grab JSON of which subsequences triggered a bug.
    replay_idx_to_violation = parse_json(args.subsequence_violations)

    subsequence_dirs = [
        InterReplayDirectory(d)
        for d in glob.glob(args.directory + "/interreplay_*")
    ]
    assert (subsequence_dirs != [])
    subsequence_dirs.sort(key=lambda d: d.index)

    # First, grab all inputs so we know how to format
    repro_dir = subsequence_dirs.pop(0)
    assert (os.path.basename(
        str(repro_dir)) == "interreplay_0_reproducibility")
    full_trace = parse_event_trace(str(repro_dir) + "/events.trace")
    trace_formatter = TraceFormatter(full_trace)

    # Now format each subsequence
    columns = []
    columns.append(["subsequence", lambda row: row[0]])
    columns.append(["# inputs", lambda row: row[1]])
    columns.append(["MCS size", lambda row: row[2]])
    for idx, e in enumerate(full_trace.input_events):
        # See: http://stackoverflow.com/questions/233673/lexical-closures-in-python
        def bind_closure(index):
            return lambda row: row[index + 3]

        columns.append([e.label, bind_closure(idx)])
    t = Tabular(columns)
    rows = []
    for subsequence_dir in subsequence_dirs:
        try:
            if "_final_mcs" in str(subsequence_dir):
                # Make sure to always print the final MCS
                trace = parse_event_trace(
                    str(subsequence_dir) + "/events.trace")
                rows.append(trace_formatter.format_trace("MCS", trace))
            elif replay_idx_to_violation[subsequence_dir.index]:
                # Otherwise only consider subsequences that resulted in a violation
                trace = parse_event_trace(
                    str(subsequence_dir) + "/events.trace")
                rows.append(
                    trace_formatter.format_trace(subsequence_dir.index, trace))
        except KeyError as e:
            print >> sys.stderr, "WARN: No such subsequence: %s" % str(e)

    t.show(rows)
Beispiel #3
0
  def show_flow_table(self):
    dl_types = { 0x0800: "IP",
                 0x0806: "ARP",
                 0x8100: "VLAN",
                 0x88cc: "LLDP",
                 0x888e: "PAE"
                 }
    nw_protos = { 1 : "ICMP", 6 : "TCP", 17 : "UDP" }

    ports = { v: k.replace("OFPP_","") for (k,v) in of.ofp_port_rev_map.iteritems() }

    def dl_type(e):
      d = e.match.dl_type
      if d is None:
        return d
      else:
        return dl_types[d] if d in dl_types else "%x" %d

    def nw_proto(e):
      p = e.match.nw_proto
      return nw_protos[p] if p in nw_protos else p

    def action(a):
      if isinstance(a, ofp_action_output):
        return ports[a.port] if a.port in ports else "output(%d)" % a.port
      else:
        return str(a)
    def actions(e):
      if len(e.actions) == 0:
        return "(drop)"
      else:
        return ", ".join(action(a) for a in e.actions)

    t = Tabular((("Prio", lambda e: e.priority),
                 ("in_port", lambda e: e.match.in_port),
                 ("dl_type", dl_type),
                 ("dl_src", lambda e: e.match.dl_src),
                 ("dl_dst", lambda e: e.match.dl_dst),
                 ("nw_proto", nw_proto),
                 ("nw_src", lambda e: e.match.nw_src),
                 ("nw_dst", lambda e: e.match.nw_dst),
                 ("tp_src", lambda e: e.match.tp_src),
                 ("tp_dst", lambda e: e.match.tp_dst),
                 ("actions", actions),
                ))
    t.show(self.table.entries)
def main(args):
  # Grab JSON of which subsequences triggered a bug.
  replay_idx_to_violation = parse_json(args.subsequence_violations)

  subsequence_dirs = [ InterReplayDirectory(d) for d in
                       glob.glob(args.directory + "/interreplay_*") ]
  assert(subsequence_dirs != [])
  subsequence_dirs.sort(key=lambda d: d.index)

  # First, grab all inputs so we know how to format
  repro_dir = subsequence_dirs.pop(0)
  assert(os.path.basename(str(repro_dir)) == "interreplay_0_reproducibility")
  full_trace = parse_event_trace(str(repro_dir) + "/events.trace")
  trace_formatter = TraceFormatter(full_trace)

  # Now format each subsequence
  columns = []
  columns.append(["subsequence", lambda row: row[0]])
  columns.append(["# inputs", lambda row: row[1]])
  columns.append(["MCS size", lambda row: row[2]])
  for idx, e in enumerate(full_trace.input_events):
    # See: http://stackoverflow.com/questions/233673/lexical-closures-in-python
    def bind_closure(index):
      return lambda row: row[index+3]
    columns.append([e.label, bind_closure(idx)])
  t = Tabular(columns)
  rows = []
  for subsequence_dir in subsequence_dirs:
    try:
      if "_final_mcs" in str(subsequence_dir):
        # Make sure to always print the final MCS
        trace = parse_event_trace(str(subsequence_dir) + "/events.trace")
        rows.append(trace_formatter.format_trace("MCS", trace))
      elif replay_idx_to_violation[subsequence_dir.index]:
        # Otherwise only consider subsequences that resulted in a violation
        trace = parse_event_trace(str(subsequence_dir) + "/events.trace")
        rows.append(trace_formatter.format_trace(subsequence_dir.index, trace))
    except KeyError as e:
      print >> sys.stderr, "WARN: No such subsequence: %s" % str(e)

  t.show(rows)