docs: update installation guide and gsg.
[vswitchperf.git] / docs / design / vswitchperf_design.rst
1 Intended Audience
2 =================
3
4 This document is intended to aid those who want to modify the vsperf code. Or to extend it - for example to add support for new traffic generators, deployment scenarios and so on.
5
6 Usage
7 =====
8
9 Example Command Lines
10 ---------------------
11
12 List all the cli options:
13
14   .. code-block:: console
15
16    $ ./vsperf -h
17
18 Run all tests that have ``tput`` in their name - ``p2p_tput``, ``pvp_tput`` etc.:
19
20   .. code-block:: console
21
22    $ ./vsperf  --tests 'tput'
23
24 As above but override default configuration with settings in 'my_settings.py'. This is useful as modifying configuration directly in the configuration files in ``conf/NN_*.py`` shows up as changes under git source control:
25
26   .. code-block:: console
27
28    $ ./vsperf  --conf-file my_settings.py --tests 'tput'
29
30 Override specific test parameters. Useful for shortening the duration of tests for development purposes:
31
32   .. code-block:: console
33
34    $ ./vsperf --test-params 'rfc2544_duration=10;rfc2544_trials=1;packet_sizes=64' --tests 'pvp_tput'
35
36 Typical Test Sequence
37 =====================
38
39 This is a typical flow of control for a test.
40
41 .. image:: ../images/vsperf.png
42
43
44 Configuration
45 =============
46
47 The conf package contains the configuration files (``*.conf``) for all system components, it also provides a ``settings`` object that exposes all of these settings.
48
49 Settings are not passed from component to component. Rather they are available globally to all components once they import the conf package.
50
51   .. code-block:: python
52
53    from conf import settings
54    ...
55    log_file = settings.getValue('LOG_FILE_DEFAULT')
56
57 Settings files (``*.conf``) are valid python code so can be set to complex types such as lists and dictionaries as well as scalar types:
58
59   .. code-block:: python
60
61    first_packet_size = settings.getValue('PACKET_SIZE_LIST')[0]
62
63 Configuration Procedure and Precedence
64 --------------------------------------
65
66 Configuration files follow a strict naming convention that allows them to be processed in a specific order. All the .conf files are named ``NN_name.conf``, where NN is a decimal digit. The files are processed in order from 00_name.conf to 99_name.conf so that if the name setting is given in both a lower and higher numbered conf file then the higher numbered file is the effective setting as it is processed after the setting in the lower numbered file.
67
68 The values in the file specified by ``--conf-file`` takes precedence over all the other configuration files and does not have to follow the naming convention.
69
70
71 Other Configuration
72 -------------------
73
74 ``conf.settings`` also loads configuration from the command line and from the environment.
75
76 VM, vSwitch, Traffic Generator Independence
77 ===========================================
78
79 VSPERF supports different vSwithes, Traffic Generators and VNFs by using standard object-oriented polymorphism:
80
81   * Support for vSwitches is implemented by a class inheriting from IVSwitch.
82   * Support for Traffic Generators is implemented by a class inheriting from ITrafficGenerator.
83   * Support for VNF is implemented by a class inheriting from IVNF.
84
85 By dealing only with the abstract interfaces the core framework can support many implementations of different vSwitches, Traffic Generators and VNFs.
86
87 IVSwitch
88 --------
89
90   .. code-block:: python
91
92     class IVSwitch:
93       start(self)
94       stop(self)
95       add_switch(switch_name)
96       del_switch(switch_name)
97       add_phy_port(switch_name)
98       add_vport(switch_name)
99       get_ports(switch_name)
100       del_port(switch_name, port_name)
101       add_flow(switch_name, flow)
102       del_flow(switch_name, flow=None)
103
104 ITrafficGenerator
105 -----------------
106
107   .. code-block:: python
108
109     class ITrafficGenerator:
110       connect()
111       disconnect()
112
113       send_burst_traffic(traffic, numpkts, time, framerate)
114
115       send_cont_traffic(traffic, time, framerate)
116       start_cont_traffic(traffic, time, framerate)
117       stop_cont_traffic(self):
118
119       send_rfc2544_throughput(traffic, trials, duration, lossrate)
120       start_rfc2544_throughput(traffic, trials, duration, lossrate)
121       wait_rfc2544_throughput(self)
122
123       send_rfc2544_back2back(traffic, trials, duration, lossrate)
124       start_rfc2544_back2back(traffic, , trials, duration, lossrate)
125       wait_rfc2544_back2back()
126
127 Note ``send_xxx()`` blocks whereas ``start_xxx()`` does not and must be followed by a subsequent call to ``wait_xxx()``.
128
129 IVnf
130 ----
131
132   .. code-block:: python
133
134     class IVnf:
135       start(memory, cpus,
136             monitor_path, shared_path_host,
137             shared_path_guest, guest_prompt)
138       stop()
139       execute(command)
140       wait(guest_prompt)
141       execute_and_wait (command)
142
143 Controllers
144 -----------
145
146 Controllers are used in conjunction with abstract interfaces as way of decoupling the control of vSwtiches, VNFs and TrafficGenerators from other components.
147
148 The controlled classes provide basic primitive operations. The Controllers sequence and co-ordinate these primitive operation in to useful actions. For instance the vswitch_controller_PVP can be used to bring any vSwitch (that implements the primitives defined in IVSwitch) into the configuration required by the Phy-to-Phy  Deployment Scenario.
149
150 In order to support a new vSwitch only a new implementation of IVSwitch needs be created for the new vSwitch to be capable of fulfilling all the Deployment Scenarios provided for by existing or future vSwitch Controllers.
151
152 Similarly if a new Deployment Scenario is required it only needs to be written once as a new vSwitch Controller and it will immediately be capable of controlling all existing and future vSwitches in to that Deployment Scenario.
153
154 Similarly the Traffic Controllers can be used to co-ordinate basic operations provided by implementers of ITrafficGenerator to provide useful tests. Though traffic generators generally already implement full test cases i.e. they both generate suitable traffic and analyse returned traffic in order to implement a test which has typically been predefined in an RFC document. However the Traffic Controller class allows for the possibility of further enhancement - such as iterating over tests for various packet sizes or creating new tests.
155
156 Traffic Controller's Role
157 -------------------------
158
159 .. image:: ../images/traffic_controller.png
160
161
162 Loader & Component Factory
163 --------------------------
164
165 The working of the Loader package (which is responsible for *finding* arbitrary classes based on configuration data) and the Component Factory which is responsible for *choosing* the correct class for a particular situation - e.g. Deployment Scenario can be seen in this diagram.
166
167 .. image:: ../images/factory_and_loader.png
168
169 Routing Tables
170 ==============
171
172 Vsperf uses a standard set of routing tables in order to allow tests to easily mix and match Deployment Scenarios (PVP, P2P topology), Tuple Matching and Frame Modification requirements.
173
174 ::
175
176                     +--------------+
177                     |              |
178                     | Table 0      |  table#0 - Match table. Flows designed to force 5 & 10 tuple matches go here.
179                     |              |
180                     +--------------+
181                           |
182                           |
183                           v
184                     +--------------+  table#1 - Routing table. Flows to route packets between ports goes here.
185                     |              |  The chosen port is communicated to subsequent tables by setting the
186                     | Table 1      |  metadata value to the egress port number. Generally this table
187                     |              |  is set-up by by the vSwitchController.
188                     +--------------+
189                           |
190                           |
191                           v
192                     +--------------+  table#2 - Frame modification table. Frame modification flow rules are
193                     |              |  isolated in this table so that they can be turned on or off
194                     | Table 2      |  without affecting the routing or tuple-matching flow rules.
195                     |              |  This allows the frame modification and tuple matching required by the
196                     +--------------+  tests in the VSWITCH PERFORMANCE FOR TELCO NFV test specification
197                           |           to be independent of the Deployment Scenario set up by the vSwitchController.
198                           |
199                           v
200                     +--------------+
201                     |              |
202                     | Table 3      |  table#3 - Egress table. Egress packets on the ports setup in Table 1.
203                     |              |
204                     +--------------+