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
alshabib
2014-09-15 17:47:31 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8aef1ad7ddd1cbe9c84c71123ec17b04faaca1e1
8aef1ad7
1 parent
030111ed
added enhanced reactive forwarding
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
15 deletions
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactiveForwarding.java
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactivePacketProcessor.java
apps/tvue/pom.xml
providers/of/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
providers/of/packet/src/main/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProvider.java
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactiveForwarding.java
View file @
8aef1ad
...
...
@@ -5,6 +5,7 @@ import org.apache.felix.scr.annotations.Component;
import
org.apache.felix.scr.annotations.Deactivate
;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.onlab.onos.net.host.HostService
;
import
org.onlab.onos.net.packet.PacketProcessor
;
import
org.onlab.onos.net.packet.PacketService
;
import
org.onlab.onos.net.topology.TopologyService
;
...
...
@@ -18,11 +19,14 @@ public class ReactiveForwarding {
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
PacketService
packetService
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
HostService
hostService
;
private
ReactivePacketProcessor
processor
;
@Activate
public
void
activate
()
{
processor
=
new
ReactivePacketProcessor
(
topologyService
);
processor
=
new
ReactivePacketProcessor
(
topologyService
,
hostService
);
packetService
.
addProcessor
(
processor
,
PacketProcessor
.
ADVISOR_MAX
+
1
);
}
...
...
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactivePacketProcessor.java
View file @
8aef1ad
...
...
@@ -2,36 +2,73 @@ package org.onlab.onos.fwd;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.util.Set
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.onos.net.Path
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.flow.Instructions
;
import
org.onlab.onos.net.host.HostService
;
import
org.onlab.onos.net.packet.InboundPacket
;
import
org.onlab.onos.net.packet.PacketContext
;
import
org.onlab.onos.net.packet.PacketProcessor
;
import
org.onlab.onos.net.topology.TopologyService
;
import
org.onlab.packet.VLANID
;
import
org.slf4j.Logger
;
public
class
ReactivePacketProcessor
implements
PacketProcessor
{
private
final
Logger
log
=
getLogger
(
getClass
());
private
final
TopologyService
topologyService
;
private
final
HostService
hostService
;
public
ReactivePacketProcessor
(
TopologyService
topologyService
)
{
public
ReactivePacketProcessor
(
TopologyService
topologyService
,
HostService
hostService
)
{
this
.
topologyService
=
topologyService
;
this
.
hostService
=
hostService
;
}
@Override
public
void
process
(
PacketContext
context
)
{
InboundPacket
pkt
=
context
.
inPacket
();
HostId
id
=
HostId
.
hostId
(
pkt
.
parsed
().
getDestinationMAC
(),
VLANID
.
vlanId
((
short
)
-
1
));
Host
dst
=
hostService
.
getHost
(
id
);
if
(
dst
==
null
)
{
flood
(
context
);
return
;
}
Set
<
Path
>
p
=
null
;
if
(
pkt
.
receivedFrom
().
deviceId
().
equals
(
dst
.
location
().
deviceId
()))
{
context
.
treatmentBuilder
().
add
(
Instructions
.
createOutput
(
dst
.
location
().
port
()));
context
.
send
();
return
;
}
else
{
p
=
topologyService
.
getPaths
(
topologyService
.
currentTopology
(),
context
.
inPacket
().
receivedFrom
().
deviceId
(),
dst
.
location
().
deviceId
());
}
if
(
p
.
isEmpty
())
{
flood
(
context
);
}
else
{
Path
p1
=
p
.
iterator
().
next
();
context
.
treatmentBuilder
().
add
(
Instructions
.
createOutput
(
p1
.
src
().
port
()));
context
.
send
();
}
}
private
void
flood
(
PacketContext
context
)
{
boolean
canBcast
=
topologyService
.
isBroadcastPoint
(
topologyService
.
currentTopology
(),
context
.
inPacket
().
receivedFrom
());
if
(
canBcast
)
{
context
.
treatmentBuilder
().
add
(
Instructions
.
createOutput
(
PortNumber
.
FLOOD
));
context
.
send
();
}
else
{
context
.
block
();
}
}
}
...
...
apps/tvue/pom.xml
View file @
8aef1ad
...
...
@@ -84,6 +84,7 @@
com.sun.jersey.server.impl.container.servlet,
com.fasterxml.jackson.databind,
com.fasterxml.jackson.databind.node,
org.onlab.packet.*,
org.onlab.rest.*,
org.onlab.onos.*
</Import-Package>
...
...
providers/of/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
View file @
8aef1ad
package
org
.
onlab
.
onos
.
provider
.
of
.
host
.
impl
;
import
static
com
.
google
.
common
.
collect
.
Sets
.
newHashSet
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
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
;
...
...
@@ -28,13 +35,6 @@ import org.onlab.packet.IPAddress;
import
org.onlab.packet.VLANID
;
import
org.slf4j.Logger
;
import
java.util.Set
;
import
static
com
.
google
.
common
.
collect
.
Sets
.
newHashSet
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
/**
* Provider which uses an OpenFlow controller to detect network
* end-station hosts.
...
...
@@ -96,7 +96,7 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
if
(
eth
.
getEtherType
()
==
Ethernet
.
TYPE_ARP
)
{
VLANID
vlan
=
VLANID
.
vlanId
(
eth
.
getVlanID
());
ConnectPoint
heardOn
=
new
ConnectPoint
(
deviceId
(
Dpid
.
uri
(
pktCtx
.
dpid
())),
portNumber
(
pktCtx
.
inPort
()));
portNumber
(
pktCtx
.
inPort
()));
// If this is not an edge port, bail out.
Topology
topology
=
topologyService
.
currentTopology
();
...
...
@@ -105,8 +105,8 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
}
HostLocation
hloc
=
new
HostLocation
(
deviceId
(
Dpid
.
uri
(
pktCtx
.
dpid
())),
portNumber
(
pktCtx
.
inPort
()),
System
.
currentTimeMillis
());
portNumber
(
pktCtx
.
inPort
()),
System
.
currentTimeMillis
());
HostId
hid
=
HostId
.
hostId
(
eth
.
getSourceMAC
(),
vlan
);
ARP
arp
=
(
ARP
)
eth
.
getPayload
();
...
...
providers/of/packet/src/main/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProvider.java
View file @
8aef1ad
...
...
@@ -54,7 +54,7 @@ public class OpenFlowPacketProvider extends AbstractProvider implements PacketPr
@Activate
public
void
activate
()
{
providerService
=
providerRegistry
.
register
(
this
);
controller
.
addPacketListener
(
1
,
listener
);
controller
.
addPacketListener
(
20
,
listener
);
log
.
info
(
"Started"
);
}
...
...
Please
register
or
login
to post a comment