[P4-dev] concat fields

Yuliang Li yuliangl at usc.edu
Thu Mar 31 23:14:52 EDT 2016


Hi Salvatore,

Thank you for you detailed help! But I think my problem is a bit different.
I do not need to calculate hash on the 5-tuple. Instead, I only need
something to concatenate the 5-tuple into one. What I have now are
ipv4.srcAddr (32bits), ipv4.dstAddr (32bits), tcp.srcPort (16bits),
tcp.dstPort (16bits), ipv4.protocol(8bits). And I want to have a metadata
that is a concatenation of these 5 fields, which is 104bits
(32+32+16+16+8). Do you know how to do it?

Thanks,
Yuliang

On Thu, Mar 31, 2016 at 6:40 PM, Salvatore Signorello <
salvatore.signorello at uni.lu> wrote:

> Hi Yuliang,
>
> you can use field list calculation (see sec. 4 "Checksums and Hash-value
> generators" of the language specification). For instance, you define a
> field list which is a structure containing all the header fields you want
> to concat, like follows:
>
> field_list tuple_fl {
>   headerX.a;
>   headerX.b;
>   headerX.c;
>   headerY.a;
>   headerY.b;
> }
>
> then you define a field list calculation which maps the result of a
> function computed over a field list to an integer value, like follows:
>
> field_list_calculation tuple_xor {
>     input {
>         tuple_fl;
>     }
>     algorithm : xor16; // a list of the supported algorithms is provided
> within the aforementioned sec. of the specification
>     output_width : 16;
> }
>
>
> Then, you need to copy the tuple_xor value first in a metadata and later
> in a register by calling an action that could be defined like follows:
>
> action set_xor_value(base, count) {
>     modify_field_with_hash_based_offset(your_metadata.tuple_xor, base,
> tuple_xor, ecmp_count);
>     register_write(register_name, index, your_metadata.tuple_xor)
> }
>
> While back, the operation above could not be performed in one step,
> because the "modify_field_with_hash_based_offset" didn't accept a register
> as 1st argument. Today, I'm not sure that this is still the case.
>
> Of course, finally, you also need a table that triggers the action above.
>
> There should be the flowlet switching example that performs a similar
> operation at
>
> https://github.com/p4lang/tutorials/tree/master/SIGCOMM_2015/flowlet_switching
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_p4lang_tutorials_tree_master_SIGCOMM-5F2015_flowlet-5Fswitching&d=CwMD-g&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=-sjq3J2b6bOdupF1bsRuzQ&m=ts0opezTBCtHAf1xuCqwG-VjLs2x3v-lYVJKssygUK4&s=LpAPBumB-CdXnZLTj5b8CcykPe38Y-0wvXVG5DwQlbU&e=>
>
> Hope that this helps,
> Salvatore
>
>
> On 04/01/2016 02:58 AM, Yuliang Li wrote:
>
> Hi,
>
> I need to xor the 5-tuple of each packet into a register. So I need
> something like concat(srcip, dstip, srcport, dstport, protocol), and xor it
> to my register. Does anyone know how to do it in p4 data plane?
>
> Thanks,
> Yuliang
>
>
> _______________________________________________
> P4-dev mailing listP4-dev at lists.p4.orghttp://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.p4.org_mailman_listinfo_p4-2Ddev-5Flists.p4.org&d=CwMD-g&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=-sjq3J2b6bOdupF1bsRuzQ&m=ts0opezTBCtHAf1xuCqwG-VjLs2x3v-lYVJKssygUK4&s=3xsoZ9rodNaRj0p6jLMCrX4sPLyzSpsq-lW5vSUR08k&e=>
>
>
> --
> Salvatore Signorello
> PhD student of the SEDAN research group at SnT
>
> Interdisciplinary Centre for Security, Reliability and Trust
> University of Luxembourghttp://wwwen.uni.lu/snt/people/salvatore_signorello <https://urldefense.proofpoint.com/v2/url?u=http-3A__wwwen.uni.lu_snt_people_salvatore-5Fsignorello&d=CwMD-g&c=clK7kQUTWtAVEOVIgvi0NU5BOUHhpN0H8p7CSfnc_gI&r=-sjq3J2b6bOdupF1bsRuzQ&m=ts0opezTBCtHAf1xuCqwG-VjLs2x3v-lYVJKssygUK4&s=vNfG0SW0_svxzN50IYWDky3b0L7GwLPBarxrshLWGsM&e=>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20160331/101113a9/attachment-0002.html>


More information about the P4-dev mailing list