summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/pipe
AgeCommit message (Expand)AuthorFilesLines
2019-04-08fixing typosJim Thompson1-1/+1
2019-04-08minor spelling errors (both in comments)Jim Thompson1-1/+1
2019-04-06Pipe: fix double count on TX (TX counting is done in interface-output)Neale Ranns1-11/+1
2019-02-14Add -fno-common compile optionBenoƮt Ganne1-1/+1
2018-11-14Remove c-11 memcpy checks from perf-critical codeDave Barach1-1/+1
2018-11-13vlib rename vlib_frame_args(...) to vlib_frame_scalar_args(..)Damjan Marion1-1/+1
2018-10-23c11 safe string handling supportDave Barach1-2/+2
2018-10-20pipes: fix the l2.l2_len and the l[23]_hdr_offset setting behavior of pipe-rx...Andrew Yourtchenko1-29/+30
2018-08-17Fix a bug in function pipe_rxLijian Zhang1-1/+1
2018-07-17VOM: support for pipesNeale Ranns2-10/+10
2018-07-09new pipe code does not use stdintsNeale Ranns1-2/+2
2018-07-07PipesNeale Ranns4-0/+1141
color: #f92672 } /* Keyword.Namespace */ .highlight .kp { color: #66d9ef } /* Keyword.Pseudo */ .highlight .kr { color: #66d9ef } /* Keyword.Reserved */ .highlight .kt { color: #66d9ef } /* Keyword.Type */ .highlight .ld { color: #e6db74 } /* Literal.Date */ .highlight .m { color: #ae81ff } /* Literal.Number */ .highlight .s { color: #e6db74 } /* Literal.String */ .highlight .na { color: #a6e22e } /* Name.Attribute */ .highlight .nb { color: #f8f8f2 } /* Name.Builtin */ .highlight .nc { color: #a6e22e } /* Name.Class */ .highlight .no { color: #66d9ef } /* Name.Constant */ .highlight .nd { color: #a6e22e } /* Name.Decorator */ .highlight .ni { color: #f8f8f2 } /* Name.Entity */ .highlight .ne { color: #a6e22e } /* Name.Exception */ .highlight .nf { color: #a6e22e } /* Name.Function */ .highlight .nl { color: #f8f8f2 } /* Name.Label */ .highlight .nn { color: #f8f8f2 } /* Name.Namespace */ .highlight .nx { color: #a6e22e } /* Name.Other */ .highlight .py { color: #f8f8f2 } /* Name.Property */ .highlight .nt { color: #f92672 } /* Name.Tag */ .highlight .nv { color: #f8f8f2 } /* Name.Variable */ .highlight .ow { color: #f92672 } /* Operator.Word */ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#!/usr/bin/env python3

import sys
import re
import argparse
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D

class Point():
    "CC event"
    def __init__(self, x, y):
        self.x = x
        self.y = y

def listx(points):
  return list(map(lambda pt: pt.x, points))

def listy(points):
  return list(map(lambda pt: pt.y, points))

def plot_data(d):

  plt.figure(1)

  cwndx = listx(d["cwnd"])
  cwndy = listy(d["cwnd"])
  congx = listx(d["congestion"])
  congy = listy(d["congestion"])
  rcvrdx = listx(d["recovered"])
  rcvrdy = listy(d["recovered"])
  rxttx = listx(d["rxtTimeout"])
  rxtty = listy(d["rxtTimeout"])

  # cwnd/ssthresh/cc events
  plt.subplot(311)
  plt.title("cwnd/ssthresh")
  pcwnd = plt.plot(cwndx, cwndy, 'r')
  psst = plt.plot(cwndx, d["ssthresh"], 'y-')
  pcong = plt.plot(congx, congy,'yo')
  precov = plt.plot(rcvrdx, rcvrdy,'co')
  prxtt = plt.plot(rxttx, rxtty,'mo')

  marker1 = Line2D(range(1), range(1), color="r")
  marker2 = Line2D(range(1), range(1), color="y")
  marker3 = Line2D(range(1), range(1), color="w", marker="o", markerfacecolor="y")
  marker4 = Line2D(range(1), range(1), color="w", marker="o", markerfacecolor="c")
  marker5 = Line2D(range(1), range(1), color="w", marker="o", markerfacecolor="m")
  plt.legend((marker1, marker2, marker3, marker4, marker5),
             ('cwnd', 'ssthresh', 'congestion', 'recovered', 'rxt-timeout'),
             loc=4)
  axes = plt.gca()
  axes.set_ylim([-20e4, max(cwndy) + 20e4])

  # snd variables
  plt.subplot(312)
  plt.title("cc variables")
  plt.plot(cwndx, d["space"], 'g-', markersize=1)
  plt.plot(cwndx, d["flight"], 'b-', markersize=1)
  plt.plot(cwndx, d["sacked"], 'm:', markersize=1)
  plt.plot(cwndx, d["lost"], 'y:', markersize=1)
  plt.plot(cwndx, d["cc-space"], 'k:', markersize=1)
  plt.plot(cwndx, cwndy, 'ro', markersize=2)

  plt.plot(congx, congy, 'y^', markersize=10, markerfacecolor="y")
  plt.plot(rcvrdx, rcvrdy, 'c^', markersize=10, markerfacecolor="c")
  plt.plot(rxttx, rxtty, 'm^', markersize=10, markerfacecolor="m")

  #plt.plot(cwndx, d["snd_wnd"], 'ko', markersize=1)
  plt.legend(("snd-space", "flight", "sacked", "lost", "cc-space", "cwnd",
              "congestion", "recovered", "rxt-timeout"),
             loc=1)

  # rto/srrt/rttvar
  plt.subplot(313)
  plt.title("rtt")
  plt.plot(cwndx, d["srtt"], 'g-')
  plt.plot(cwndx, [x/1000 for x in d["mrtt-us"]], 'r-')
  plt.plot(cwndx, d["rttvar"], 'b-')
  plt.legend(["srtt", "mrtt-us", "rttvar"])
  axes = plt.gca()
  #plt.plot(cwndx, rto, 'r-')
  #axes.set_ylim([0, int(max(rto[2:len(rto)])) + 50])

  # show
  plt.show()

def find_pattern(file_path,session_idx):
    is_active_open = 1
    listener_pattern = "l\[\d\]"
    if (is_active_open):
      initial_pattern = "\[\d\](\.\d+:\d+\->\.\d+:\d+)\s+open:\s"
    else:
      initial_pattern = "\[\d\](\.\d+:\d+\->\.\d+:\d+)\s"
    idx = 0
    f = open(file_path, 'r')
    for line in f:
      # skip listener lines (server)
      if (re.search(listener_pattern, line) != None):
        continue
      match = re.search(initial_pattern, line)
      if (match == None):
        continue
      if (idx < session_idx):
        idx += 1
        continue
      filter_pattern = str(match.group(1)) + "\s+(.+)"
      print ("pattern is %s" % filter_pattern)
      f.close()
      return filter_pattern
    raise Exception ("Could not find initial pattern")

def compute_time(min, sec, msec):
  return int(min)*60 + int(sec) + int(msec)/1000.0

def run(file_path, session_idx):
    filter_sessions = 1
    filter_pattern = ""

    patterns = {
      "time"      : "^\d+:(\d+):(\d+):(\d+):\d+",
      "listener"  : "l\[\d\]",
      "cc"        : "cwnd (\d+) flight (\d+) space (\d+) ssthresh (\d+) snd_wnd (\d+)",
      "cc-snd"    : "cc_space (\d+) sacked (\d+) lost (\d+)",
      "rtt"       : "rto (\d+) srtt (\d+) mrtt-us (\d+) rttvar (\d+)",
      "rxtt"      : "rxt-timeout",
      "congestion": "congestion",
      "recovered" : "recovered",
    }
    d = {
      "cwnd"        : [],
      "space"       : [],
      "flight"      : [],
      "ssthresh"    : [],
      "snd_wnd"     : [],
      "cc-space"    : [],
      "lost"        : [],
      "sacked"      : [],
      "rto"         : [],
      "srtt"        : [],
      "mrtt-us"     : [],
      "rttvar"      : [],
      "rxtTimeout"  : [],
      "congestion"  : [],
      "recovered"   : [],
    }

    if (filter_sessions):
        filter_pattern = find_pattern(file_path, session_idx)
    f = open(file_path, 'r')

    stats_index = 0
    start_time = 0

    for line in f:
        # skip listener lines (server)
        if (re.search(patterns["listener"], line) != None):
            continue
        # filter sessions
        if (filter_sessions):
            match = re.search(filter_pattern, line)
            if (match == None):
                continue

        original_line = line
        line = match.group(1)
        match = re.search (patterns["time"], original_line)
        if (match == None):
          print "something went wrong! no time!"
          continue
        time = compute_time (match.group(1), match.group(2), match.group(3))
        if (start_time == 0):
          start_time = time

        time = time - start_time
        match = re.search(patterns["cc"], line)
        if (match != None):
          d["cwnd"].append(Point(time, int(match.group(1))))
          d["flight"].append(int(match.group(2)))
          d["space"].append(int(match.group(3)))
          d["ssthresh"].append(int(match.group(4)))
          d["snd_wnd"].append(int(match.group(5)))
          stats_index += 1
          continue
        match = re.search(patterns["cc-snd"], line)
        if (match != None):
          d["cc-space"].append(int(match.group(1)))
          d["sacked"].append(int(match.group(2)))
          d["lost"].append(int(match.group(3)))
        match = re.search(patterns["rtt"], line)
        if (match != None):
           d["rto"].append(int(match.group(1)))
           d["srtt"].append(int(match.group(2)))
           d["mrtt-us"].append(int(match.group(3)))
           d["rttvar"].append(int(match.group(4)))
        if (stats_index == 0):
           continue
        match = re.search(patterns["rxtt"], line)
        if (match != None):
          d["rxtTimeout"].append(Point(time, d["cwnd"][stats_index - 1].y + 1e4))
          continue
        match = re.search(patterns["congestion"], line)
        if (match != None):
          d["congestion"].append(Point(time, d["cwnd"][stats_index - 1].y - 1e4))
          continue
        match = re.search(patterns["recovered"], line)
        if (match != None):
          d["recovered"].append(Point(time, d["cwnd"][stats_index - 1].y))
          continue

    plot_data(d)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Plot tcp cc logs")
    parser.add_argument('-f', action='store', dest='file', required=True,
                        help="elog file in txt format")
    parser.add_argument('-s', action='store', dest='session_index', default=0,
                        help="session index for which to plot cc logs" )
    results = parser.parse_args()
    run(results.file, int(results.session_index))