179 | | 1. '''Use the interfaces that are connected to `host2` and `host3`. ''' |
180 | | * Software Switch (OVS): If you have not noted them down you can use the manifest and the MAC address of the interfaces (ovs:if1 and ovs:if2) to figure this out. But you should have noted down the interfaces in Section 2 when you were configuring the software switch. Run tcpdump on these interfaces; one in each of the two ovs terminals you opened. This will allow you to see all traffic going out the interfaces. |
| 179 | 1. ''' Insert the flow to Duplicate Traffic ''' |
| 180 | * We are going to duplicate IPv4 traffic from Host 1 destined to Host 2 on Host 3. Open a new ''Controller'' terminal and type the following flow: |
| 181 | {{{ |
| 182 | curl -X POST -d '{"switch":"<DPID OF OPEN vSWITCH>","name":"flow-1","priority":"32768","in_port":"<PORT OF 10.0.0.1>","active":"true", "eth_type":"0x0800", "eth_src":"<MAC OF 10.0.0.1>", "eth_dst":"<MAC OF 10.0.0.2>", "ipv4_src":"10.0.0.1", "ipv4_dst":"10.0.0.2", "actions":"set_field=eth_dst-><MAC OF 10.0.0.2>,set_field=ipv4_dst->10.0.0.2,output=<PORT OF 10.0.0.2>,set_field=eth_dst-><MAC OF 10.0.0.3>,output=<PORT OF 10.0.0.3>"}' http://localhost:8080/wm/staticflowpusher/json |
| 183 | }}} |
183 | | To see that duplication is happening, on the ovs host, run: |
184 | | {{{ |
185 | | sudo tcpdump -i <data_interface_name> [data_interface to host2] |
186 | | sudo tcpdump -i <data_interface_name> [data_interface to host3] |
187 | | }}} |
188 | | |
189 | | You should see traffic from host1 to host2 showing up in the tcpdump window for host3. As a comparison, you will notice that no traffic shows up in that window when the controller is running the learning switch. |
190 | | 2. '''In the controller host directory `/tmp/pox/ext` you should see two files:''' |
191 | | |
192 | | i. '''myDuplicateTraffic.py''' : This is the file that has instructions about how to complete the missing information. Go ahead and try to implement your first controller. |
193 | | ii. '''!DuplicateTraffic.py''' : This has the actual solution. You can just run this if you don't want to bother with writing a controller. |
194 | | |
195 | | 3. Run your newly written controller on the <data_interface_name> that corresponds to ''OVS:if2'' (which is connected to `host3`): |
196 | | {{{ |
197 | | cd /tmp/pox |
198 | | ./pox.py --verbose DuplicateTraffic --duplicate_port=? |
199 | | }}} |
200 | | |
201 | | For example, if ''OVS:if2'' corresponds to "eth1", enter |
202 | | |
203 | | {{{ |
204 | | ./pox.py --verbose myDuplicateTraffic --duplicate_port=eth1 |
205 | | }}} |
206 | | |
207 | | 4. To test it go to the terminal of host1 and try to ping host2: |
208 | | {{{ |
209 | | ping 10.10.1.2 |
210 | | }}} |
211 | | If your controller is working, your packets will register in both terminals running tcpdump. |
212 | | |
213 | | 5. Stop the POX controller: |
214 | | {{{ |
215 | | DEBUG:DuplicateTraffic:Got a packet : [02:f1:ae:bb:e3:a8>02:c7:e8:a7:40:65 IP] |
216 | | DEBUG:SimpleL2Learning:installing flow for 02:f1:ae:bb:e3:a8.2 -> 02:c7:e8:a7:40:65.[1, 2] |
217 | | |
218 | | INFO:core:Going down... |
219 | | INFO:openflow.of_01:[3a-51-a1-ab-c3-43 1] disconnected |
220 | | INFO:core:Down. |
221 | | }}} |
| 186 | To see that duplication is happening, on Host 2 and Host 3 , run: |
| 187 | {{{ |
| 188 | sudo tcpdump -i eth1 |
| 189 | }}} |
| 190 | |
| 191 | You should see traffic from host1 to host2 showing up in the tcpdump window for host3 as shown below: |
| 192 | {{{ |
| 193 | pjayant@host3:~$ sudo tcpdump -i eth1 |
| 194 | tcpdump: verbose output suppressed, use -v or -vv for full protocol decode |
| 195 | listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes |
| 196 | 02:48:38.270572 IP Host1-link-1 > Host2-link-2: ICMP echo request, id 8877, seq 1, length 64 |
| 197 | 02:48:38.270639 IP Host3-link-3 > Host1-link-1: ICMP redirect Host2-link-2 to host Host2-link-2, length 92 |
| 198 | 02:48:38.270654 IP Host1-link-1 > Host2-link-2: ICMP echo request, id 8877, seq 1, length 64 |
| 199 | 02:48:39.271350 IP Host1-link-1 > Host2-link-2: ICMP echo request, id 8877, seq 2, length 64 |
| 200 | 02:48:39.271390 IP Host3-link-3 > Host1-link-1: ICMP redirect Host2-link-2 to host Host2-link-2, length 92 |
| 201 | 02:48:39.271403 IP Host1-link-1 > Host2-link-2: ICMP echo request, id 8877, seq 2, length 64 |
| 202 | 02:48:40.272525 IP Host1-link-1 > Host2-link-2: ICMP echo request, id 8877, seq 3, length 64 |
| 203 | 02:48:40.272570 IP Host3-link-3 > Host1-link-1: ICMP redirect Host2-link-2 to host Host2-link-2, length 92 |
| 204 | 02:48:40.272582 IP Host1-link-1 > Host2-link-2: ICMP echo request, id 8877, seq 3, length 64 |
| 205 | }}} |