~ p4alu ~
Arithmetic Logic Unit in P4
Kentaro Ebisawa | Ponto Networks, Inc.
ebiken@pontonetworks.com
Twitter: @ebiken
p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 1
• “p4alu” is an P4 program who would parse UDP packet with
payload in "p4alu header format" and apply calculation.
• This program is tested using BMv2 simple_switch P4 target.
• Source Code on GitHub
• https://github.com/ebiken/p4sandbox/tree/master/p4alu
• Generic P4 information in Japanese (日本語)
• How to Run P4 Behavior Model v2 (JAPANESE)
• https://www.slideshare.net/kentaroebisawa/how-to-run-p4-bmv2
p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 2
p4alu
p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 3
ALU
Integer
Operand
Integer
Operand
Integer
Result
opCode
op1 op2
result
p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 4
p4alu header format
Integer
Operand
Integer
Operand
Integer
Result
opCode
op1 op2
result
p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 5
P4 parser
p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 6
P4 action
p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 7
P4 table & control
p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 8
Setup netns based hosts
BMv2 running p4alu
p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 9
Compile and Run on BMv2
p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 10
Configure Tables via runtime_CLI
Forward Packet
from/to port#0 <-> port#1
Apply action based on opCode
• opCode: 1 => p4alu_add
• opCode: 2 => p4alu_sub
BMv2 Runtime CLI command format
p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 11
Packet Format (sending from host0)
• opCode: 0x01 => p4alu_add
• opCode: 0x02 => p4alu_sub
CuiShark by @slankdev | https://github.com/slankdev/cuishark
p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 12
packets after going through p4alu
op1 opCodeop2 result
CuiShark by @slankdev | https://github.com/slankdev/cuishark
p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 13
packets after going through p4alu
op1 opCodeop2 result

p4alu: Arithmetic Logic Unit in P4

  • 1.
    ~ p4alu ~ ArithmeticLogic Unit in P4 Kentaro Ebisawa | Ponto Networks, Inc. ebiken@pontonetworks.com Twitter: @ebiken p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 1
  • 2.
    • “p4alu” isan P4 program who would parse UDP packet with payload in "p4alu header format" and apply calculation. • This program is tested using BMv2 simple_switch P4 target. • Source Code on GitHub • https://github.com/ebiken/p4sandbox/tree/master/p4alu • Generic P4 information in Japanese (日本語) • How to Run P4 Behavior Model v2 (JAPANESE) • https://www.slideshare.net/kentaroebisawa/how-to-run-p4-bmv2 p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 2 p4alu
  • 3.
    p4alu ... ArithmeticLogic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 3 ALU Integer Operand Integer Operand Integer Result opCode op1 op2 result
  • 4.
    p4alu ... ArithmeticLogic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 4 p4alu header format Integer Operand Integer Operand Integer Result opCode op1 op2 result
  • 5.
    p4alu ... ArithmeticLogic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 5 P4 parser
  • 6.
    p4alu ... ArithmeticLogic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 6 P4 action
  • 7.
    p4alu ... ArithmeticLogic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 7 P4 table & control
  • 8.
    p4alu ... ArithmeticLogic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 8 Setup netns based hosts BMv2 running p4alu
  • 9.
    p4alu ... ArithmeticLogic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 9 Compile and Run on BMv2
  • 10.
    p4alu ... ArithmeticLogic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 10 Configure Tables via runtime_CLI Forward Packet from/to port#0 <-> port#1 Apply action based on opCode • opCode: 1 => p4alu_add • opCode: 2 => p4alu_sub BMv2 Runtime CLI command format
  • 11.
    p4alu ... ArithmeticLogic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 11 Packet Format (sending from host0) • opCode: 0x01 => p4alu_add • opCode: 0x02 => p4alu_sub
  • 12.
    CuiShark by @slankdev| https://github.com/slankdev/cuishark p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 12 packets after going through p4alu op1 opCodeop2 result
  • 13.
    CuiShark by @slankdev| https://github.com/slankdev/cuishark p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 13 packets after going through p4alu op1 opCodeop2 result