ovs-vsctl error while Streaming Video in Mininet - python

I am recently studying Mininet.And I watched a video about "How to Streaming Video in Mininet"
this is its python code
def myNetwork():
"Create a network."
net = Mininet( topo=None, build=False )
info('*** Adding Controller\n')
net.addController(name='c0')
print( "*** Add Access Points\n")
s1=net.addSwitch('s1')
# Intf('eth0',node=s1) # Some Problem
info('*** Add hosts\n')
h1 = net.addHost('h1',ip='10.0.0.1')
h2 = net.addHost('h2',ip='10.0.0.2')
info('*** Add links\n')
net.addLink(h1,s1,cls=TCLink,bw=10,delay='1ms',loss=0)
net.addLink(h2,s1,cls=TCLink,bw=10,delay='1ms',loss=50)
print ("*** Starting network")
net.start()
os.popen('ovs-vsctl add-port s1 eth0')
h1.cmdPrint('dhclient '+h1.defaultIntf().name)
h2.cmdPrint('dhclient '+h2.defaultIntf().name)
CLI(net)
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
myNetwork()
after running this code , the bug ocuurs as below:
*** h1 : ('dhclient h1-eth0',)
ovs-vsctl: Error detected while setting up 'eth0'. See ovs-vswitchd log for details
How can I fix this
Why the error occurs and how can I fix this error to make it works

Related

Linux NoHup fails for Streaming API IG Markets where file is python

This is quite a specific question regarding nohup in linux, which runs a python file.
Back-story, I am trying to save down streaming data (from IG markets broadcast signal). And, as I am trying to run it via a remote-server (so I don't have to keep my own local desktop up 24/7),
somehow, the nohup will not engage when it 'listen's to a broadcast signal.
Below, is the example python code
#!/usr/bin/env python
#-*- coding:utf-8 -*-
"""
IG Markets Stream API sample with Python
"""
user_ = 'xxx'
password_ = 'xxx'
api_key_ = 'xxx' # this is the 1st api key
account_ = 'xxx'
acc_type_ = 'xxx'
fileLoc = 'marketdata_IG_spx_5min.csv'
list_ = ["CHART:IX.D.SPTRD.DAILY.IP:5MINUTE"]
fields_ = ["UTM", "LTV", "TTV", "BID_OPEN", "BID_HIGH", \
"BID_LOW", "BID_CLOSE",]
import time
import sys
import traceback
import logging
import warnings
warnings.filterwarnings('ignore')
from trading_ig import (IGService, IGStreamService)
from trading_ig.lightstreamer import Subscription
cols_ = ['timestamp', 'data']
# A simple function acting as a Subscription listener
def on_prices_update(item_update):
# print("price: %s " % item_update)
print("xxxxxxxx
))
# A simple function acting as a Subscription listener
def on_charts_update(item_update):
# print("price: %s " % item_update)
print(xxxxxx"\
.format(
stock_name=item_update["name"], **item_update["values"]
))
res_ = [xxxxx"\
.format(
stock_name=item_update["name"], **item_update["values"]
).split(' '))]
# display(pd.DataFrame(res_))
try:
data_ = pd.read_csv(fileLoc)[cols_]
data_ = data_.append(pd.DataFrame(res_, columns = cols_))
data_.to_csv(fileLoc)
print('there is data and we are reading it')
# display(data_)
except:
pd.DataFrame(res_, columns = cols_).to_csv(fileLoc)
print('there is no data and we are saving first time')
time.sleep(60) # sleep for 1 min
def main():
logging.basicConfig(level=logging.INFO)
# logging.basicConfig(level=logging.DEBUG)
ig_service = IGService(
user_, password_, api_key_, acc_type_
)
ig_stream_service = IGStreamService(ig_service)
ig_session = ig_stream_service.create_session()
accountId = account_
################ my code to set sleep function to sleep/read at only certain time intervals
s_time = time.time()
############################
# Making a new Subscription in MERGE mode
subscription_prices = Subscription(
mode="MERGE",
# make sure to put L1 in front of the instrument name
items= list_,
fields= fields_
)
# adapter="QUOTE_ADAPTER")
# Adding the "on_price_update" function to Subscription
subscription_prices.addlistener(on_charts_update)
# Registering the Subscription
sub_key_prices = ig_stream_service.ls_client.subscribe(subscription_prices)
print('this is the line here')
input("{0:-^80}\n".format("HIT CR TO UNSUBSCRIBE AND DISCONNECT FROM \
LIGHTSTREAMER"))
# Disconnecting
ig_stream_service.disconnect()
if __name__ == '__main__':
main()
#######
Then, I try to run it on linux using this command : nohup python marketdata.py
where marketdata.py is basically the python code above.
Somehow, the nohup will not engage....... Any experts/guru who might see what I am missing in my code?

Switch can't connect to controller in my code in Mininet

I am having trouble connecting the switch to the controller in mininet. I use python script.
My script is the following.
The file name is test.py.
#!/usr/bin/python
from mininet.cli import CLI
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.util import dumpNodeConnections
from mininet.node import Controller, OVSSwitch, RemoteController, OVSBridge
from mininet.log import setLogLevel
class test_Topo(Topo):
def build(self):
s1 = self.addSwitch( 's1')
s2 = self.addSwitch( 's2')
h1 = self.addHost( 'h1' )
h2 = self.addHost( 'h2' )
n1 = self.addHost( 'n1' )
self.addLink( s1, s2 )
self.addLink( s1, h1 )
self.addLink( s1, h2 )
self.addLink( s2, n1 )
def test():
topo = test_Topo()
net = Mininet(topo, build=False, waitConnected=True, switch=OVSSwitch, controller=Controller)
c0 = net.addController( 'c0', port=6633 )
c1 = net.addController('c1', port=6634)
net.build()
s1 = net.get('s1')
s2 = net.get('s2')
c0.start()
c1.start()
s1.start([c0])
s2.start([c1])
net.start()
net.pingAll()
CLI( net )
net.stop()
if __name__ == '__main__':
setLogLevel('info')
test()
I want to have each switch connected to a different controller. 
I ran the script with the following command.
sudo python3 test.py
The result is the following.
*** Creating network
*** Adding hosts:
h1 h2 n1
*** Adding switches:
s1 s2
*** Adding links:
(s1, h1) (s1, h2) (s1, s2) (s2, n1)
*** Configuring hosts
h1 h2 n1
*** Starting controller
c0 c1
*** Starting 2 switches
s1 s2 ...
*** Waiting for switches to connect
The connection does not end permanently after the message
*** Waiting for switches to connect
is displayed.
I referred to this code.
https://github.com/mininet/mininet/blob/master/examples/controllers.py
https://github.com/mininet/mininet/blob/master/examples/controllers2.py
I can't understand why switch can't connect the controller in my code.
I apologize for my poor English.

Flask Deploy on Gunicorn and Nginx Threadsafe error

i deploy a Flask scrip as below on a Centos7 vps.
from flask import Flask, request
import time
# http server
app = Flask(__name__)
server_dict = dict()
server_status_dict = dict()
#app.route('/<ip>')
def report(ip):
server_dict[ip] = time.time()
return "ok" + ":"+ip + ":"+str(time.time())
#app.route('/check')
def check():
for server in server_dict:
difference = time.time()-server_dict[server]
if difference < 120:
server_status_dict[server]= "ok" + ":"+str(difference)
elif difference > 172800:
del server_status_dict[server]
else:
server_status_dict[server]= "fail" + ":"+str(difference)
message =''
for item in server_status_dict:
message = message+ f'{item}:{server_status_dict[item]}<br>'
return message
# main function
if __name__ == '__main__':
# start server
app.run(host='0.0.0.0', port=1111)
I run it in 2 way.
1. direct run the python scrip by type "python3.7 test.py"
2. deploy with Gunicorn and Nginx.
And i make a script to test this Flask api as below
import requests
for i in range(100):
requests.get(f'http://example.org/{i}')
print("done 1")
for i in range(100):
requests.get(f'http://server_IP:1111/{i}')
print("done 2")
with 1st option. The scrip run ok. When i go to "http://server_IP:1111/check". It give 100 entry
0:fail:759.2570543289185
1:fail:758.8786942958832
2:fail:758.5069346427917
3:fail:758.1351449489594
4:fail:757.7596881389618
5:fail:757.3863341808319
6:fail:757.010666847229
7:fail:756.6381704807281
8:fail:756.2622804641724
9:fail:755.8862257003784
10:fail:755.5146560668945
11:fail:755.1291973590851
12:fail:754.7365326881409
13:fail:754.356516122818
14:fail:753.981279373169
15:fail:753.6054089069366
16:fail:753.2138450145721
17:fail:752.818380355835
18:fail:752.4382960796356
19:fail:752.0667576789856
20:fail:751.7003827095032
21:fail:751.3132452964783
22:fail:750.9238367080688
23:fail:750.5513446331024
24:fail:750.1771302223206
25:fail:749.7979047298431
26:fail:749.4190459251404
27:fail:749.0481917858124
28:fail:748.6672575473785
29:fail:748.2830848693848
30:fail:747.909416437149
31:fail:747.5357480049133
32:fail:747.1593079566956
33:fail:746.7837409973145
34:fail:746.3994252681732
35:fail:746.0265593528748
36:fail:745.6520500183105
37:fail:745.2793860435486
38:fail:744.904794216156
39:fail:744.5288579463959
40:fail:744.1554877758026
41:fail:743.7802364826202
42:fail:743.4038217067719
43:fail:743.0015366077423
44:fail:742.616055727005
45:fail:742.2241225242615
46:fail:741.8492274284363
47:fail:741.4703538417816
48:fail:741.0822536945343
49:fail:740.7089433670044
50:fail:740.3415608406067
51:fail:739.9651212692261
52:fail:739.5690467357635
53:fail:739.1705968379974
54:fail:738.7934353351593
55:fail:738.4151468276978
56:fail:738.0353343486786
57:fail:737.6413230895996
58:fail:737.2650125026703
59:fail:736.8714530467987
60:fail:736.4966006278992
61:fail:736.1160485744476
62:fail:735.7190825939178
63:fail:735.3462533950806
64:fail:734.9714226722717
65:fail:734.5957586765289
66:fail:734.2199065685272
67:fail:733.8420522212982
68:fail:733.4598708152771
69:fail:733.0775439739227
70:fail:732.6989419460297
71:fail:732.3187139034271
72:fail:731.9392898082733
73:fail:731.5633845329285
74:fail:731.1846008300781
75:fail:730.8096714019775
76:fail:730.4323663711548
77:fail:730.0437717437744
78:fail:729.6707744598389
79:fail:729.2912459373474
80:fail:728.8956272602081
81:fail:728.5194237232208
82:fail:728.1444211006165
83:fail:727.7692551612854
84:fail:727.3844618797302
85:fail:727.0075929164886
86:fail:726.612667798996
87:fail:726.2140853404999
88:fail:725.8366258144379
89:fail:725.4668595790863
90:fail:725.080512046814
91:fail:724.7128283977509
92:fail:724.3402450084686
93:fail:723.9593863487244
94:fail:723.5851843357086
95:fail:723.2059574127197
96:fail:722.802404165268
97:fail:722.40824842453
98:fail:722.0141706466675
99:fail:721.6389377117157
But with 2nd option. the error happen. when i go to "http://example.org/check" it give difference result each time.
some time is below:
0:fail:780.1568698883057
4:fail:778.6187407970428
6:fail:777.8681375980377
9:fail:776.739280462265
13:fail:775.2384984493256
15:fail:774.4248764514923
19:fail:772.897510766983
22:fail:771.7576985359192
25:fail:770.6321122646332
28:fail:769.4517879486084
31:fail:768.3453030586243
34:fail:767.2020778656006
37:fail:766.0453197956085
40:fail:764.8815402984619
43:fail:763.7402126789093
another time is below:
2:fail:933.5209627151489
5:fail:932.381462097168
8:fail:931.2705476284027
11:fail:930.1319863796234
14:fail:928.9525971412659
17:fail:927.8257281780243
20:fail:926.6680727005005
23:fail:925.52357172966
26:fail:924.3903162479401
29:fail:923.2299783229828
32:fail:922.1214139461517
35:fail:920.9716517925262
38:fail:919.8139469623566
41:fail:918.6542329788208
44:fail:917.4981758594513
49:fail:915.6011772155762
i'm thinking it is threadsafe issue. Could someone advise me.
Thanks

How to Send New Messages from Azure IoT Edge Module Python

It seems there is not very much support for what I am trying to do, but it is supposed to be possible since it is demonstrated in temperature sensor and sensor filter tutorial. However, there are no examples for the actual message creation from an edge module in python. That tutorial only shows forwarding messages. There are examples of sending from a device, but devices use a different class than edge modules. From the filter example and from a couple of device examples I have pieced together the following:
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for
# full license information.
import random
import time
import sys
import iothub_client
from iothub_client import IoTHubModuleClient, IoTHubClientError, IoTHubTransportProvider
from iothub_client import IoTHubMessage, IoTHubMessageDispositionResult, IoTHubError
# messageTimeout - the maximum time in milliseconds until a message times out.
# The timeout period starts at IoTHubModuleClient.send_event_async.
# By default, messages do not expire.
MESSAGE_TIMEOUT = 10000
# global counters
RECEIVE_CALLBACKS = 0
SEND_CALLBACKS = 0
# Choose HTTP, AMQP or MQTT as transport protocol. Currently only MQTT is supported.
PROTOCOL = IoTHubTransportProvider.MQTT
# Callback received when the message that we're forwarding is processed.
def send_confirmation_callback(message, result, user_context):
global SEND_CALLBACKS
print ( "Confirmation[%d] received for message with result = %s" % (user_context, result) )
map_properties = message.properties()
key_value_pair = map_properties.get_internals()
print ( " Properties: %s" % key_value_pair )
SEND_CALLBACKS += 1
print ( " Total calls confirmed: %d" % SEND_CALLBACKS )
# receive_message_callback is invoked when an incoming message arrives on the specified
# input queue (in the case of this sample, "input1"). Because this is a filter module,
# we will forward this message onto the "output1" queue.
def receive_message_callback(message, hubManager):
global RECEIVE_CALLBACKS
message_buffer = message.get_bytearray()
size = len(message_buffer)
print ( " Data: <<<%s>>> & Size=%d" % (message_buffer[:size].decode('utf-8'), size) )
map_properties = message.properties()
key_value_pair = map_properties.get_internals()
print ( " Properties: %s" % key_value_pair )
RECEIVE_CALLBACKS += 1
print ( " Total calls received: %d" % RECEIVE_CALLBACKS )
hubManager.forward_event_to_output("output1", message, 0)
return IoTHubMessageDispositionResult.ACCEPTED
def construct_message(message_body, topic):
try:
msg_txt_formatted = message_body
message = IoTHubMessage(msg_txt_formatted)
# Add a custom application property to the message.
# An IoT hub can filter on these properties without access to the message body.
prop_map = message.properties()
prop_map.add("topic", topic)
# TODO Use logging
# Send the message.
print( "Sending message: %s" % message.get_string() )
except IoTHubError as iothub_error:
print ( "Unexpected error %s from IoTHub" % iothub_error )
return
return message
class HubManager(object):
def __init__(
self,
protocol=IoTHubTransportProvider.MQTT):
self.client_protocol = protocol
self.client = IoTHubModuleClient()
self.client.create_from_environment(protocol)
# set the time until a message times out
self.client.set_option("messageTimeout", MESSAGE_TIMEOUT)
# sets the callback when a message arrives on "input1" queue. Messages sent to
# other inputs or to the default will be silently discarded.
self.client.set_message_callback("input1", receive_message_callback, self)
# Forwards the message received onto the next stage in the process.
def forward_event_to_output(self, outputQueueName, event, send_context):
self.client.send_event_async(
outputQueueName, event, send_confirmation_callback, send_context)
def send_message(self, message):
# No callback
# TODO what is the third arg?
self.client.send_event_async(
"output1", message, send_confirmation_callback, 0)
self.client.send_message()
def mypublish(self, topic, msg):
message = construct_message(msg, topic)
self.send_message(message)
print('publishing %s', msg)
def main(protocol):
try:
print ( "\nPython %s\n" % sys.version )
print ( "IoT Hub Client for Python" )
hub_manager = HubManager(protocol)
print ( "Starting the IoT Hub Python sample using protocol %s..." % hub_manager.client_protocol )
print ( "The sample is now waiting for messages and will indefinitely. Press Ctrl-C to exit. ")
while True:
hub_manager.mypublish('testtopic', 'hello world this is a module')
time.sleep(1)
except IoTHubError as iothub_error:
print ( "Unexpected error %s from IoTHub" % iothub_error )
return
except KeyboardInterrupt:
print ( "IoTHubModuleClient sample stopped" )
if __name__ == '__main__':
main(PROTOCOL)
When I build and deploy this it executes on the edge device without errors and in the log, the callback reports that the messages are sent ok. However, no messages come through when I attempt to monitor D2C messages.
I used this to create and send a message from a JSON dict.
new_message = json.dumps(json_obj)
new_message = IoTHubMessage(new_message)
hubManager.forward_event_to_output("output1", new_message, 0)
You can send anything you need, even strings or whatever.
To narrow down the issue, you can install the azureiotedge-simulated-temperature-sensor module published by Microsoft to see whether the issue relative to the Edge environment issue or coding.
I also wrote a sample Python code module based on the Python Module templates which works well for me, you can refer the code below:
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for
# full license information.
import random
import time
import sys
import iothub_client
from iothub_client import IoTHubModuleClient, IoTHubClientError, IoTHubTransportProvider
from iothub_client import IoTHubMessage, IoTHubMessageDispositionResult, IoTHubError
# messageTimeout - the maximum time in milliseconds until a message times out.
# The timeout period starts at IoTHubModuleClient.send_event_async.
# By default, messages do not expire.
MESSAGE_TIMEOUT = 10000
# global counters
RECEIVE_CALLBACKS = 0
SEND_CALLBACKS = 0
# Choose HTTP, AMQP or MQTT as transport protocol. Currently only MQTT is supported.
PROTOCOL = IoTHubTransportProvider.MQTT
# Callback received when the message that we're forwarding is processed.
def send_confirmation_callback(message, result, user_context):
global SEND_CALLBACKS
print ( "Confirmation[%d] received for message with result = %s" % (user_context, result) )
map_properties = message.properties()
key_value_pair = map_properties.get_internals()
print ( " Properties: %s" % key_value_pair )
SEND_CALLBACKS += 1
print ( " Total calls confirmed: %d" % SEND_CALLBACKS )
# receive_message_callback is invoked when an incoming message arrives on the specified
# input queue (in the case of this sample, "input1"). Because this is a filter module,
# we will forward this message onto the "output1" queue.
def receive_message_callback(message, hubManager):
global RECEIVE_CALLBACKS
message_buffer = message.get_bytearray()
size = len(message_buffer)
print ( " Data: <<<%s>>> & Size=%d" % (message_buffer[:size].decode('utf-8'), size) )
map_properties = message.properties()
key_value_pair = map_properties.get_internals()
print ( " Properties: %s" % key_value_pair )
RECEIVE_CALLBACKS += 1
print ( " Total calls received: %d" % RECEIVE_CALLBACKS )
hubManager.forward_event_to_output("output1", message, 0)
return IoTHubMessageDispositionResult.ACCEPTED
class HubManager(object):
def __init__(
self,
protocol=IoTHubTransportProvider.MQTT):
self.client_protocol = protocol
self.client = IoTHubModuleClient()
self.client.create_from_environment(protocol)
# set the time until a message times out
self.client.set_option("messageTimeout", MESSAGE_TIMEOUT)
# sets the callback when a message arrives on "input1" queue. Messages sent to
# other inputs or to the default will be silently discarded.
self.client.set_message_callback("input1", receive_message_callback, self)
# Forwards the message received onto the next stage in the process.
def forward_event_to_output(self, outputQueueName, event, send_context):
self.client.send_event_async(
outputQueueName, event, send_confirmation_callback, send_context)
def SendSimulationData(self, msg):
print"sending message..."
message=IoTHubMessage(msg)
self.client.send_event_async(
"output1", message, send_confirmation_callback, 0)
print"finished sending message..."
def main(protocol):
try:
print ( "\nPython %s\n" % sys.version )
print ( "IoT Hub Client for Python" )
hub_manager = HubManager(protocol)
print ( "Starting the IoT Hub Python sample using protocol %s..." % hub_manager.client_protocol )
print ( "The sample is now waiting for messages and will indefinitely. Press Ctrl-C to exit. ")
while True:
hub_manager.SendSimulationData("test msg")
time.sleep(1)
except IoTHubError as iothub_error:
print ( "Unexpected error %s from IoTHub" % iothub_error )
return
except KeyboardInterrupt:
print ( "IoTHubModuleClient sample stopped" )
if __name__ == '__main__':
main(PROTOCOL)
If it can help someone, I think you miss await send_message.
Seems the same problem I answered here

Trying to perform mobility with an Opendaylight controller

I am using mininet to simulate a linear topology, 3 switches connected to each other and one host connected to each switch. Looks like this.
I used the mobility script provided on github to perform mobility within mininet. The script uses the default controller of Mininet.
Now I would like to use a remote Opendaylight controller to perform the mobility, or more specifically to move h1 from s1 to s2 and then back to s2.
My code is a modified version of the original mobility script. Changes are in the mobilityTest() method and the CLI was added for debugging.
#!/usr/bin/python
"""
Simple example of Mobility with Mininet
(aka enough rope to hang yourself.)
We move a host from s1 to s2, s2 to s3, and then back to s1.
Gotchas:
The reference controller doesn't support mobility, so we need to
manually flush the switch flow tables!
Good luck!
to-do:
- think about wifi/hub behavior
- think about clearing last hop - why doesn't that work?
"""
from mininet.node import RemoteController
from mininet.net import Mininet
from mininet.node import OVSSwitch
from mininet.topo import LinearTopo
from mininet.log import info, output, warn, setLogLevel
from mininet.examples.clustercli import CLI
from random import randint
import time
class MobilitySwitch( OVSSwitch ):
"Switch that can reattach and rename interfaces"
def delIntf( self, intf ):
"Remove (and detach) an interface"
port = self.ports[ intf ]
del self.ports[ intf ]
del self.intfs[ port ]
del self.nameToIntf[ intf.name ]
def addIntf( self, intf, rename=False, **kwargs ):
"Add (and reparent) an interface"
OVSSwitch.addIntf( self, intf, **kwargs )
intf.node = self
if rename:
self.renameIntf( intf )
def attach( self, intf ):
"Attach an interface and set its port"
port = self.ports[ intf ]
if port:
if self.isOldOVS():
self.cmd( 'ovs-vsctl add-port', self, intf )
else:
self.cmd( 'ovs-vsctl add-port', self, intf,
'-- set Interface', intf,
'ofport_request=%s' % port )
self.validatePort( intf )
def validatePort( self, intf ):
"Validate intf's OF port number"
ofport = int( self.cmd( 'ovs-vsctl get Interface', intf,
'ofport' ) )
if ofport != self.ports[ intf ]:
warn( 'WARNING: ofport for', intf, 'is actually', ofport,
'\n' )
def renameIntf( self, intf, newname='' ):
"Rename an interface (to its canonical name)"
intf.ifconfig( 'down' )
if not newname:
newname = '%s-eth%d' % ( self.name, self.ports[ intf ] )
intf.cmd( 'ip link set', intf, 'name', newname )
del self.nameToIntf[ intf.name ]
intf.name = newname
self.nameToIntf[ intf.name ] = intf
intf.ifconfig( 'up' )
def moveIntf( self, intf, switch, port=None, rename=True ):
"Move one of our interfaces to another switch"
self.detach( intf )
self.delIntf( intf )
switch.addIntf( intf, port=port, rename=rename )
switch.attach( intf )
def printConnections( switches ):
"Compactly print connected nodes to each switch"
for sw in switches:
output( '%s: ' % sw )
for intf in sw.intfList():
link = intf.link
if link:
intf1, intf2 = link.intf1, link.intf2
remote = intf1 if intf1.node != sw else intf2
output( '%s(%s) ' % ( remote.node, sw.ports[ intf ] ) )
output( '\n' )
def moveHost( host, oldSwitch, newSwitch, newPort=None ):
"Move a host from old switch to new switch"
hintf, sintf = host.connectionsTo( oldSwitch )[ 0 ]
oldSwitch.moveIntf( sintf, newSwitch, port=newPort )
return hintf, sintf
def mobilityTest():
"A simple test of mobility"
info( '* Simple mobility test\n' )http://localhost:8181/restconf/operational/opendaylight-inventory:nodes/
net = Mininet( topo=LinearTopo( 3 ), controller=lambda a: RemoteController( a, ip='127.0.0.1', port=6653), switch=MobilitySwitch )
info( '* Starting network:\n' )
net.start()
printConnections( net.switches )
info( '* Testing network\n' )
time.sleep( 3 )
net.pingAll()
info( '* Identifying switch interface for h1\n' )
h1, old = net.get( 'h1', 's1' )
CLI( net )
for s in 2, 3, 1:
new = net[ 's%d' % s ]
port = randint( 10, 20 )
info( '* Moving', h1, 'from', old, 'to', new, 'port', port, '\n' )
hintf, sintf = moveHost( h1, old, new, newPort=port )
info( '*', hintf, 'is now connected to', sintf, '\n' )
info( '* Clearing out old flows\n' )
for sw in net.switches:
sw.dpctl( 'del-flows' )
info( '* Add flow rule\n' )
CLI( net )
info( '* New network:\n' )
printConnections( net.switches )
info( '* Testing connectivity:\n' )
net.pingAll()
old = new
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
mobilityTest()
When running the script the linear topology is set up successfully, which I can see in the delux GUI of the ODL controller. I can also ping between all hosts.
The problem occurs when mobility is performed and h1 is connected to s2.
Pinging does not work anymore.
Populating the flow-tables with a flow-rule to the controller did not solve the problem.
mininet> dpctl add-flow "table=0, priority=100,dl_type=0x88cc actions=CONTROLLER:65535"
*** s1 ------------------------------------------------------------------------
*** s2 ------------------------------------------------------------------------
*** s3 ------------------------------------------------------------------------
mininet> dpctl dump-flows
*** s1 ------------------------------------------------------------------------
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=7.914s, table=0, n_packets=0, n_bytes=0, idle_age=7, priority=100,dl_type=0x88cc actions=CONTROLLER:65535
*** s2 ------------------------------------------------------------------------
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=7.916s, table=0, n_packets=1, n_bytes=85, idle_age=2, priority=100,dl_type=0x88cc actions=CONTROLLER:65535
*** s3 ------------------------------------------------------------------------
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=7.917s, table=0, n_packets=1, n_bytes=85, idle_age=2, priority=100,dl_type=0x88cc actions=CONTROLLER:65535
mininet> pingall
*** Ping: testing ping reachability
h1 -> X X
h2 -> X X
h3 -> X X
*** Results: 100% dropped (0/6 received)
Then I monitored with tcpdump all interfaces when I try to ping from h1 to h2, which are now both connected to s2. h1 sends out an ARP request, which is received by the s2 switch, but this switch s2 is not forwarding the ARP request to the other switches and hosts.
I would like to know why my ping does not work anymore after performing mobility.
Any help is highly appreciated.
Thanks

Categories