Pier | ee1f59c | 2016-11-18 19:38:56 -0800 | [diff] [blame] | 1 | from oftest.testutils import * |
| 2 | from oftest import config |
| 3 | import oftest.base_tests as base_tests |
| 4 | import time |
| 5 | |
| 6 | class QinQPacketGenerator( base_tests.DataPlaneOnly ): |
| 7 | """ |
| 8 | Generator for QinQ packets. |
| 9 | """ |
| 10 | def runTest( self ): |
| 11 | # Get the ports and the interfaces |
| 12 | ports = config[ "interfaces" ] |
| 13 | in_port = ports[0][0] |
| 14 | in_interface = ports[0][1].strip() |
| 15 | out_port = ports[1][0] |
| 16 | out_interface = ports[1][1].strip() |
| 17 | outer_vlan = 20 |
| 18 | innner_vlan = 10 |
| 19 | # Generating the packets |
| 20 | parsed_pkt = simple_tcp_packet_two_vlan( |
| 21 | pktlen=108, |
| 22 | out_dl_vlan_enable=True, |
| 23 | out_vlan_vid=outer_vlan, |
| 24 | in_dl_vlan_enable=True, |
| 25 | in_vlan_vid=innner_vlan |
| 26 | ) |
| 27 | qinq_pkt = str( parsed_pkt ) |
| 28 | # Sending the packet |
| 29 | print "\nSending packet on", out_interface |
| 30 | while True : |
| 31 | self.dataplane.send( in_port, qinq_pkt ) |
| 32 | time.sleep(1) |
| 33 | |
| 34 | class VlanPacketGenerator( base_tests.DataPlaneOnly ): |
| 35 | """ |
| 36 | Generator for vlan packets. |
| 37 | """ |
| 38 | def runTest( self ): |
| 39 | # Get the ports and the interfaces |
| 40 | ports = config[ "interfaces" ] |
| 41 | in_port = ports[0][0] |
| 42 | in_interface = ports[0][1].strip() |
| 43 | out_port = ports[1][0] |
| 44 | out_interface = ports[1][1].strip() |
| 45 | outer_vlan = 20 |
| 46 | # Generating the packets |
| 47 | parsed_pkt = simple_tcp_packet( |
| 48 | pktlen=108, |
| 49 | dl_vlan_enable=True, |
| 50 | vlan_vid=outer_vlan |
| 51 | ) |
| 52 | vlan_pkt = str( parsed_pkt ) |
| 53 | # Sending the packet |
| 54 | print "\nSending packet on", out_interface |
| 55 | while True : |
| 56 | self.dataplane.send( in_port, vlan_pkt ) |
| 57 | time.sleep(1) |
| 58 | |
| 59 | class UntaggedPacketGenerator( base_tests.DataPlaneOnly ): |
| 60 | """ |
| 61 | Generator for untagged packets. |
| 62 | """ |
| 63 | def runTest( self ): |
| 64 | # Get the ports and the interfaces |
| 65 | ports = config[ "interfaces" ] |
| 66 | in_port = ports[0][0] |
| 67 | in_interface = ports[0][1].strip() |
| 68 | out_port = ports[1][0] |
| 69 | out_interface = ports[1][1].strip() |
| 70 | # Generating the packets |
| 71 | parsed_pkt = simple_tcp_packet( |
| 72 | pktlen=108, |
| 73 | ) |
| 74 | untagged_pkt = str( parsed_pkt ) |
| 75 | # Sending the packet |
| 76 | print "\nSending packet on", out_interface |
| 77 | while True : |
| 78 | self.dataplane.send( in_port, untagged_pkt ) |
| 79 | time.sleep(1) |