blob: 74d2ccc1fe0fa602126a50e6e5744d16be39326f [file] [log] [blame]
Sreeju Sreedhare3fefd92019-04-02 15:57:15 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
17from oftest.testutils import *
18from oftest import config
19import oftest.base_tests as base_tests
20import time
21
22class QinQPacketGenerator( base_tests.DataPlaneOnly ):
23 """
24 Generator for QinQ packets.
25 """
26 def runTest( self ):
27 # Get the ports and the interfaces
28 ports = config[ "interfaces" ]
29 in_port = ports[0][0]
30 in_interface = ports[0][1].strip()
31 out_port = ports[1][0]
32 out_interface = ports[1][1].strip()
33 outer_vlan = 20
34 innner_vlan = 10
35 # Generating the packets
36 parsed_pkt = simple_tcp_packet_two_vlan(
37 pktlen=108,
38 out_dl_vlan_enable=True,
39 out_vlan_vid=outer_vlan,
40 in_dl_vlan_enable=True,
41 in_vlan_vid=innner_vlan
42 )
43 qinq_pkt = str( parsed_pkt )
44 # Sending the packet
45 print "\nSending packet on", out_interface
46 while True :
47 self.dataplane.send( in_port, qinq_pkt )
48 time.sleep(1)
49
50class VlanPacketGenerator( base_tests.DataPlaneOnly ):
51 """
52 Generator for vlan packets.
53 """
54 def runTest( self ):
55 # Get the ports and the interfaces
56 ports = config[ "interfaces" ]
57 in_port = ports[0][0]
58 in_interface = ports[0][1].strip()
59 out_port = ports[1][0]
60 out_interface = ports[1][1].strip()
61 outer_vlan = 20
62 # Generating the packets
63 parsed_pkt = simple_tcp_packet(
64 pktlen=108,
65 dl_vlan_enable=True,
66 vlan_vid=outer_vlan
67 )
68 vlan_pkt = str( parsed_pkt )
69 # Sending the packet
70 print "\nSending packet on", out_interface
71 while True :
72 self.dataplane.send( in_port, vlan_pkt )
73 time.sleep(1)
74
75class UntaggedPacketGenerator( base_tests.DataPlaneOnly ):
76 """
77 Generator for untagged packets.
78 """
79 def runTest( self ):
80 # Get the ports and the interfaces
81 ports = config[ "interfaces" ]
82 in_port = ports[0][0]
83 in_interface = ports[0][1].strip()
84 out_port = ports[1][0]
85 out_interface = ports[1][1].strip()
86 # Generating the packets
87 parsed_pkt = simple_tcp_packet(
88 pktlen=108,
89 )
90 untagged_pkt = str( parsed_pkt )
91 # Sending the packet
92 print "\nSending packet on", out_interface
93 while True :
94 self.dataplane.send( in_port, untagged_pkt )
95 time.sleep(1)