Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
tom
2014-09-17 13:52:55 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
642b226499d154e9ad7cad6cae314c0b445dfbc7
642b2264
1 parent
9c94c5b4
Fixed the react fwd app; glitch pause still remains though.
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
20 deletions
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactiveForwarding.java
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactiveForwarding.java
View file @
642b226
package
org
.
onlab
.
onos
.
fwd
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.util.Set
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
...
...
@@ -31,6 +27,10 @@ import org.onlab.onos.net.topology.TopologyService;
import
org.onlab.packet.Ethernet
;
import
org.slf4j.Logger
;
import
java.util.Set
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
/**
* Sample reactive forwarding application.
*/
...
...
@@ -81,7 +81,8 @@ public class ReactiveForwarding {
}
InboundPacket
pkt
=
context
.
inPacket
();
HostId
id
=
HostId
.
hostId
(
pkt
.
parsed
().
getDestinationMAC
());
Ethernet
ethPkt
=
pkt
.
parsed
();
HostId
id
=
HostId
.
hostId
(
ethPkt
.
getDestinationMAC
());
// Do we know who this is for? If not, flood and bail.
Host
dst
=
hostService
.
getHost
(
id
);
...
...
@@ -100,7 +101,7 @@ public class ReactiveForwarding {
// Otherwise, get a set of paths that lead from here to the
// destination edge switch.
Set
<
Path
>
paths
=
topologyService
.
getPaths
(
topologyService
.
currentTopology
(),
context
.
inPacket
()
.
receivedFrom
().
deviceId
(),
pkt
.
receivedFrom
().
deviceId
(),
dst
.
location
().
deviceId
());
if
(
paths
.
isEmpty
())
{
// If there are no paths, flood and bail.
...
...
@@ -112,7 +113,9 @@ public class ReactiveForwarding {
// came from; if no such path, flood and bail.
Path
path
=
pickForwardPath
(
paths
,
pkt
.
receivedFrom
().
port
());
if
(
path
==
null
)
{
log
.
warn
(
"Doh... don't know where to go..."
);
log
.
warn
(
"Doh... don't know where to go... {} -> {} received on {}"
,
ethPkt
.
getSourceMAC
(),
ethPkt
.
getDestinationMAC
(),
pkt
.
receivedFrom
().
port
());
flood
(
context
);
return
;
}
...
...
@@ -133,28 +136,28 @@ public class ReactiveForwarding {
return
null
;
}
// Floods the specified packet.
// Floods the specified packet
if permissible
.
private
void
flood
(
PacketContext
context
)
{
if
(
topologyService
.
isBroadcastPoint
(
topologyService
.
currentTopology
(),
context
.
inPacket
().
receivedFrom
()))
{
packetOut
Flood
(
context
);
packetOut
(
context
,
PortNumber
.
FLOOD
);
}
else
{
context
.
block
();
}
}
//
Floods a packet out
private
void
packetOut
Flood
(
PacketContext
context
)
{
context
.
treatmentBuilder
().
add
(
Instructions
.
createOutput
(
PortNumber
.
FLOOD
));
//
Sends a packet out the specified port.
private
void
packetOut
(
PacketContext
context
,
PortNumber
portNumber
)
{
context
.
treatmentBuilder
().
add
(
Instructions
.
createOutput
(
portNumber
));
context
.
send
();
}
// Install a rule forwarding the packet to the specified port.
private
void
installRule
(
PacketContext
context
,
PortNumber
portNumber
)
{
// we don't yet support bufferids in the flowservice so packet out and
// then install a flowmod.
packetOutFlood
(
context
);
// We don't yet support bufferids in the flowservice so packet out first.
packetOut
(
context
,
portNumber
);
// Install the flow rule to handle this type of message from now on.
Ethernet
inPkt
=
context
.
inPacket
().
parsed
();
TrafficSelector
.
Builder
builder
=
new
DefaultTrafficSelector
.
Builder
();
builder
.
add
(
Criteria
.
matchEthType
(
inPkt
.
getEtherType
()))
...
...
@@ -169,11 +172,6 @@ public class ReactiveForwarding {
builder
.
build
(),
treat
.
build
());
flowRuleService
.
applyFlowRules
(
f
);
// we don't yet support bufferids in the flowservice so packet out and
// then install a flowmod.
context
.
treatmentBuilder
().
add
(
Instructions
.
createOutput
(
portNumber
));
context
.
send
();
}
}
...
...
Please
register
or
login
to post a comment