<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi,</p>
    <p>A follow up question:</p>
    <p>I am trying to store two state variables per switch in a header
      stack and doing the following. Seems it does not work. I am trying
      this on bmv2. No compilation errors. Is this the correct way to do
      what I am trying to do? <br>
    </p>
    <p>header_type state_var_t{</p>
    <p>    fields {</p>
    <p>         field_1: 8;</p>
    <p>         field_2: 8;</p>
    <p>   }<br>
    </p>
    <p>}<br>
    </p>
    header state_var_t state[8]; // 8-node topology<br>
    <br>
    parser start {<br>
        extract(state[2]); //for example<br>
        set_metadata(my_meta.field_1, state[2].field_1);<br>
        set_metadata(my_meta.field_2, state[2].field_2);<br>
         return ingress;<br>
    }<br>
    <br>
    Any help would be great.<br>
    <br>
    Thanks.<br>
    Roshan.<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 2017-11-21 22:55, Andy Fingerhut
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAKvLtDbLZFoocQbZ-9pbWLp6NNuReD1oSmkYeC_wuEYqbYZ5Qg@mail.gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <div dir="ltr">
        <div>
          <div>
            <div>P4_14 and P4_16 languages have the notion of a header
              stack, which is close to the idea of an array in other
              languages.<br>
              <br>
            </div>
            As long as you can pick a maximum value for 'n' in your
            example that you can live with, and compile with that
            maximum allowed value into your program, the P4 language can
            implement that.<br>
            <br>
          </div>
          There are several examples of using P4 for Inband Network
          Telemetry (INT) that have a similar header, with not only a
          switch id recorded in the header at each switch, but also
          statistics like the current queue depth of the queue that the
          packet went through, or a timestamp when the packet arrived at
          or left that device.  You should be able to find some examples
          of this in the repository <a
            href="https://github.com/p4lang/tutorials"
            moz-do-not-send="true">https://github.com/p4lang/tutorials</a>,
          but I don't have a recommendation of which particular program
          to look at first in there, although pick the most recent ones
          if you are interested in P4_16 source code, or somewhat older
          ones if you are interested in P4_14.<br>
          <br>
        </div>
        Andy<br>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Tue, Nov 21, 2017 at 7:03 AM, Roshan
          <span dir="ltr"><<a href="mailto:sedar@oasis.uclouvain.be"
              target="_blank" moz-do-not-send="true">sedar@oasis.uclouvain.be</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
            <br>
            I am trying the following to keep a variable in packet
            header per switch. I just want to know which way is the best
            way to do this. This could grow the header largely as it
            appears.<br>
            <br>
            <br>
            header_type {<br>
            <br>
                  fields {<br>
            <br>
                        switch_1: 8;<br>
            <br>
                         switch_2: 8;<br>
            <br>
                        ............<br>
            <br>
                         switch_n: 8;<br>
            <br>
                }<br>
            <br>
            }<br>
            <br>
            <br>
            Thanks!<br>
            <br>
            <br>
            Regards,<br>
            <br>
            Roshan.<br>
            <br>
            <br>
            ______________________________<wbr>_________________<br>
            P4-dev mailing list<br>
            <a href="mailto:P4-dev@lists.p4.org" target="_blank"
              moz-do-not-send="true">P4-dev@lists.p4.org</a><br>
            <a
              href="http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org"
              rel="noreferrer" target="_blank" moz-do-not-send="true">http://lists.p4.org/mailman/li<wbr>stinfo/p4-dev_lists.p4.org</a></blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
P4-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:P4-dev@lists.p4.org">P4-dev@lists.p4.org</a>
<a class="moz-txt-link-freetext" href="http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org">http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org</a></pre>
    </blockquote>
    <br>
  </body>
</html>