• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1% LACP unit tests
2#
3# Type the following command to launch start the tests:
4# $ test/run_tests -P "load_contrib('lacp')" -t test/contrib/lacp.uts
5
6+ LACP
7
8= Build & dissect LACP
9
10# 1    0.000000    CiscoInc_12:0f:0d    Slow-Protocols    LACP    124    Link Aggregation Control ProtocolVersion 1.  Actor Port = 22 Partner Port = 25
11params = dict(
12    actor_system_priority=32768,
13    actor_system='00:13:c4:12:0f:00',
14    actor_key=13,
15    actor_port_priority=32768,
16    actor_port_number=22,
17    actor_state=0x85,
18    partner_system_priority=32768,
19    partner_system='00:0e:83:16:f5:00',
20    partner_key=13,
21    partner_port_priority=32768,
22    partner_port_number=25,
23    partner_state=0x36,
24    collector_max_delay=32768,
25)
26pkt = Ether(src="00:13:c4:12:0f:0d") / SlowProtocol() / LACP(**params)
27s = raw(pkt)
28raw_pkt = b'\x01\x80\xc2\x00\x00\x02\x00\x13\xc4\x12\x0f\x0d\x88\x09\x01\x01\x01\x14\x80' \
29	  b'\x00\x00\x13\xc4\x12\x0f\x00\x00\x0d\x80\x00\x00\x16\x85\x00\x00\x00\x02\x14' \
30	  b'\x80\x00\x00\x0e\x83\x16\xf5\x00\x00\x0d\x80\x00\x00\x19\x36\x00\x00\x00\x03' \
31	  b'\x10\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \
32	  b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \
33	  b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \
34	  b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
35assert s == raw_pkt
36
37p = Ether(s)
38assert SlowProtocol in p and LACP in p
39assert raw(p) == raw_pkt
40
41= Marker sanity
42
43pkt = Ether(src="00:13:c4:12:0f:0d") / SlowProtocol() / MarkerProtocol()
44pkt.show()
45s = raw(pkt)
46p = Ether(s)
47assert SlowProtocol in p and MarkerProtocol in p
48assert raw(p) == s
49