public class MockSwitchBank extends Object
The mock switch bank is configured via a text-based definition file. This file contains a number of sections:
Notes:
The [packets]
functionality has not yet been implemented.
The [scenario]
functionality is incomplete; a base set of
action keywords will parse correctly, but the scenario engine has not yet
been implemented. As a provisional workaround, when the bank is activated,
the mock switches are activated one after the other with a short (50ms)
delay between each activation.
An example definition file is shown below. Note that blank lines and lines beginning with "#" are considered comments and thus ignored by the parser.
## Switch bank definition file [switches] SW10 = simple10sw4port.def SW13 = simple13sw32port.defThe records in the [switches] section take the form
LNAME = filename.def
where LNAME is the logical name
that will be used to refer to the switch in the scenario, and
filename.def is the name of the definition file describing
the mock switch. The file is assumed to be in the same directory as
the bank definition file.
This example will be expanded once the [packets] and [scenario] functionality have been fully implemented.
MockOpenflowSwitch
Constructor and Description |
---|
MockSwitchBank(String path,
boolean showOutput)
Constructs the switch bank from a bank definition object.
|
Modifier and Type | Method and Description |
---|---|
void |
activate()
Activates the switch bank, by starting the scenario script.
|
void |
activate(DataPathId dpid)
Activates the mock switch with the specified datapath ID.
|
void |
deactivate(DataPathId dpid)
Deactivates the mock switch with the specified datapath ID.
|
void |
endScenario()
Ends the scenario by checking each mock switch for failed assertions.
|
int |
expectedToCompleteHandshake()
Returns the number of mock switches that are expected to complete the
handshake process.
|
DataPathId[] |
getDpids()
Returns the datapath IDs of the configured switches in an array.
|
void |
resume()
Resumes the scenario processing after a scripted SUSPEND.
|
void |
setInternalMsgLatch(DataPathId dpid,
CountDownLatch latch)
Install a count down latch on the specified mock switch's message
handler.
|
void |
shutdown()
Immediately shuts down all activated switches.
|
int |
size()
Returns the number of configured mock switches.
|
public MockSwitchBank(String path, boolean showOutput)
path
- the bank definition file pathshowOutput
- if true, output to STDOUT is permissiblepublic void activate()
public void resume()
public void shutdown()
public int size()
public int expectedToCompleteHandshake()
Implementors should override this to account for switches with unsupported protocol versions.
public DataPathId[] getDpids()
public void activate(DataPathId dpid)
dpid
- the switch's datapath IDNullPointerException
- if dpid is nullIllegalArgumentException
- if there is no datapath with
the specified IDIllegalStateException
- if the switch is already activepublic void deactivate(DataPathId dpid)
dpid
- the switch's datapath IDNullPointerException
- if dpid is nullIllegalArgumentException
- if there is no datapath with
the specified IDIllegalStateException
- if the switch is already inactivepublic void setInternalMsgLatch(DataPathId dpid, CountDownLatch latch)
dpid
- the id of the switchlatch
- the latch to installpublic void endScenario()
Copyright © 2015. All Rights Reserved.