Browse Source

Begin to introduce commented out code, use metadata

master
Nico Schottelius 3 years ago
parent
commit
8b8f70e6a0
  1. 6
      bin/checksum_from_scapy.py
  2. 94
      doc/plan.org
  3. 959
      netpfga/minip4/src/minip4_solution-nat64.p4
  4. 2
      netpfga/minip4/src/minip4_solution.p4
  5. 1
      netpfga/minip4/src/settings.p4
  6. 1
      p4src/settings.p4

6
bin/checksum_from_scapy.py

@ -23,6 +23,8 @@ else:
# create array with unsigned shorts,
# sum it up -> results in 16 bit uint (?)
s = sum(array.array("H", pkt))
print("sum={}".format(s))
# This step is understood
# (s & 0xffff) -> mask for 16 bit, truncate rest
# (s >> 16) right shift by 16 bits
@ -40,7 +42,6 @@ else:
# over bits from the previous calculation
s += s >> 16
# according to https://stackoverflow.com/questions/8305199/the-tilde-operator-in-python
# ~ is the bitwise complement operator in python
# which essentially calculates -x - 1
@ -65,3 +66,6 @@ if __name__ == '__main__':
pkt_bytes = pkt.encode('utf-8')
print(pkt_bytes)
print(checksum(pkt_bytes))
ipv4 = "AAAA"
ipv6 = "BBAA"

94
doc/plan.org

@ -358,8 +358,30 @@
| | - 15m q&a | |
| | | |
| | | |
| 2019-06-24 | | |
| | Laurent meeting | |
| | | |
| | Checksums | |
| | - 16 bit sum of fields, later one/two complement | |
| | - various implementations | |
| | - is a sum -> commutative law | |
| | - overflow (delta > payload) handling unclear | |
| | | |
| | Netpfga | |
| | - Old one had several failure messages (one in DDR area) | |
| | - New one: tables can be written | |
| | - Need 3 ports: v4, v6, management | |
| | | |
| | Next steps: | |
| | - Test checksums delta on software switch | |
| | - Begin to port code to netpfga one-by-one | |
| | | |
| | Follow up notes: | |
| | - Checkout Hendrik thesis / right / left shift | |
| | - Fix computer in lab | |
| | | |
| 2018-06-27 | | |
| | | |
| 2019-06-27 | | |
| | Target Hardware: code running | |
| | | |
| 2019-07-11 | | |
@ -3000,6 +3022,76 @@ b'AAAA'
[14:18] line:bin% python3 checksum_from_scapy.py BBAA
b'BBAA'
31868
[14:18] line:bin% python3 checksum_from_scapy.py AA
b'AA'
48830
[14:20] line:bin% python3 checksum_from_scapy.py BB
b'BB'
48573
>>> bin(48830)
'0b1011111010111110'
>>> bin(48573)
'0b1011110110111101'
>>>
>>> array.array("H", "AAAA".encode("utf-8"))
array('H', [16705, 16705])
>>> array.array("H", "AA".encode("utf-8"))
array('H', [16705])
-> bit concat on 16:
AA:
>>> 0b100000101000001
16705
Order in 16 bit tuples does not matter:
[14:24] line:bin% python3 checksum_from_scapy.py AABB
b'AABB'
sum=33667
31868
[14:28] line:bin% python3 checksum_from_scapy.py BBAA
b'BBAA'
sum=33667
31868
[14:28] line:bin% python3 checksum_from_scapy.py BBCCAA
b'BBCCAA'
sum=50886
14649
[14:28] line:bin% python3 checksum_from_scapy.py BBAACC
b'BBAACC'
sum=50886
14649
Sum on shorts does not stay in short area:
>>> sum(array.array("H", [48830, 48573]))
97403
>>> sum(array.array("H", "AAAA".encode("utf-8")))
33410
>>> sum(array.array("H", "AABB".encode("utf-8")))
33667
>>> sum(array.array("H", "AABBCC".encode("utf-8")))
50886
>>> sum(array.array("H", "AABBCCDD".encode("utf-8")))
68362
Adding with overflow control works:
>>> s = 97403
>>> s = (s >> 16) + (s & 0xffff)
>>> s
31868
>>> s += s >> 16
>>> s
31868
[14:29] line:bin% python3 checksum_from_scapy.py AABB
b'AABB'
sum=33667
31868
#+END_CENTER
*** TODO Get ANY p4 program to successfully run on netpfga

959
netpfga/minip4/src/minip4_solution-nat64.p4

File diff suppressed because it is too large Load Diff

2
netpfga/minip4/src/minip4_solution.p4

@ -1 +1 @@
minip4_solution-v6zero.p4
minip4_solution-nat64.p4

1
netpfga/minip4/src/settings.p4

@ -0,0 +1 @@
../../../p4src/settings.p4

1
p4src/settings.p4

@ -10,5 +10,6 @@
#define ICMP6_TABLE_SIZE 64 /* icmp6 handlers */
#define ICMP_TABLE_SIZE 64 /* icmp6 handlers */
#define NAT64_TABLE_SIZE 64 /* nat64 and nat46 entries */
#define TEST_TABLE_SIZE 64 /* nat64 and nat46 entries */
#endif

Loading…
Cancel
Save