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-10-03 17:05:20 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a9a77c2d59693ec4e49861da42976a94892f9942
a9a77c2d
1 parent
f5c9d920
Added bi-directional nature to HostToHost intent.
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
165 additions
and
2 deletions
apps/ifwd/pom.xml
apps/ifwd/src/main/java/org/onlab/onos/ifwd/IntentReactiveForwarding.java
apps/ifwd/src/main/java/org/onlab/onos/ifwd/package-info.java
apps/pom.xml
features/features.xml
apps/ifwd/pom.xml
0 → 100644
View file @
a9a77c2
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onos-apps
</artifactId>
<version>
1.0.0-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
<artifactId>
onos-app-ifwd
</artifactId>
<packaging>
bundle
</packaging>
<description>
ONOS simple reactive forwarding app that uses intent service
</description>
</project>
apps/ifwd/src/main/java/org/onlab/onos/ifwd/IntentReactiveForwarding.java
0 → 100644
View file @
a9a77c2
package
org
.
onlab
.
onos
.
ifwd
;
import
org.apache.felix.scr.annotations.Activate
;
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.ApplicationId
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.flow.DefaultTrafficSelector
;
import
org.onlab.onos.net.flow.DefaultTrafficTreatment
;
import
org.onlab.onos.net.flow.TrafficSelector
;
import
org.onlab.onos.net.flow.TrafficTreatment
;
import
org.onlab.onos.net.host.HostService
;
import
org.onlab.onos.net.intent.HostToHostIntent
;
import
org.onlab.onos.net.intent.IntentId
;
import
org.onlab.onos.net.intent.IntentService
;
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.packet.PacketService
;
import
org.onlab.onos.net.topology.TopologyService
;
import
org.onlab.packet.Ethernet
;
import
org.slf4j.Logger
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
/**
* WORK-IN-PROGRESS: Sample reactive forwarding application using intent framework.
*/
@Component
(
immediate
=
true
)
public
class
IntentReactiveForwarding
{
private
static
final
int
TIMEOUT
=
10
;
private
static
final
int
PRIORITY
=
10
;
private
final
Logger
log
=
getLogger
(
getClass
());
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
TopologyService
topologyService
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
PacketService
packetService
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
IntentService
intentService
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
HostService
hostService
;
private
ReactivePacketProcessor
processor
=
new
ReactivePacketProcessor
();
private
ApplicationId
appId
;
private
static
long
intentId
=
1
;
@Activate
public
void
activate
()
{
appId
=
ApplicationId
.
getAppId
();
packetService
.
addProcessor
(
processor
,
PacketProcessor
.
ADVISOR_MAX
+
2
);
log
.
info
(
"Started with Application ID {}"
,
appId
.
id
());
}
@Deactivate
public
void
deactivate
()
{
packetService
.
removeProcessor
(
processor
);
processor
=
null
;
log
.
info
(
"Stopped"
);
}
/**
* Packet processor responsible for forwarding packets along their paths.
*/
private
class
ReactivePacketProcessor
implements
PacketProcessor
{
@Override
public
void
process
(
PacketContext
context
)
{
// Stop processing if the packet has been handled, since we
// can't do any more to it.
if
(
context
.
isHandled
())
{
return
;
}
InboundPacket
pkt
=
context
.
inPacket
();
Ethernet
ethPkt
=
pkt
.
parsed
();
HostId
srcId
=
HostId
.
hostId
(
ethPkt
.
getSourceMAC
());
HostId
dstId
=
HostId
.
hostId
(
ethPkt
.
getDestinationMAC
());
// Do we know who this is for? If not, flood and bail.
Host
dst
=
hostService
.
getHost
(
dstId
);
if
(
dst
==
null
)
{
flood
(
context
);
return
;
}
// Otherwise forward and be done with it.
setUpConnectivity
(
context
,
srcId
,
dstId
);
}
}
// Floods the specified packet if permissible.
private
void
flood
(
PacketContext
context
)
{
if
(
topologyService
.
isBroadcastPoint
(
topologyService
.
currentTopology
(),
context
.
inPacket
().
receivedFrom
()))
{
packetOut
(
context
,
PortNumber
.
FLOOD
);
}
else
{
context
.
block
();
}
}
// Sends a packet out the specified port.
private
void
packetOut
(
PacketContext
context
,
PortNumber
portNumber
)
{
context
.
treatmentBuilder
().
setOutput
(
portNumber
);
context
.
send
();
}
// Install a rule forwarding the packet to the specified port.
private
void
setUpConnectivity
(
PacketContext
context
,
HostId
srcId
,
HostId
dstId
)
{
TrafficSelector
selector
=
DefaultTrafficSelector
.
builder
().
build
();
TrafficTreatment
treatment
=
DefaultTrafficTreatment
.
builder
().
build
();
HostToHostIntent
intent
=
new
HostToHostIntent
(
new
IntentId
(
intentId
++),
srcId
,
dstId
,
selector
,
treatment
);
intentService
.
submit
(
intent
);
}
}
apps/ifwd/src/main/java/org/onlab/onos/ifwd/package-info.java
0 → 100644
View file @
a9a77c2
/**
* Trivial application that provides simple form of reactive forwarding
* using the intent service.
*/
package
org
.
onlab
.
onos
.
fwd
;
apps/pom.xml
View file @
a9a77c2
...
...
@@ -19,6 +19,7 @@
<modules>
<module>
tvue
</module>
<module>
fwd
</module>
<module>
ifwd
</module>
<module>
foo
</module>
<module>
mobility
</module>
<module>
proxyarp
</module>
...
...
features/features.xml
View file @
a9a77c2
...
...
@@ -120,6 +120,12 @@
<bundle>
mvn:org.onlab.onos/onos-app-fwd/1.0.0-SNAPSHOT
</bundle>
</feature>
<feature
name=
"onos-app-ifwd"
version=
"1.0.0"
description=
"ONOS sample forwarding application using intents"
>
<feature>
onos-api
</feature>
<bundle>
mvn:org.onlab.onos/onos-app-ifwd/1.0.0-SNAPSHOT
</bundle>
</feature>
<feature
name=
"onos-app-mobility"
version=
"1.0.0"
description=
"ONOS sample mobility application"
>
<feature>
onos-api
</feature>
...
...
@@ -132,8 +138,6 @@
<bundle>
mvn:org.onlab.onos/onos-app-proxyarp/1.0.0-SNAPSHOT
</bundle>
</feature>
<feature
name=
"onos-app-foo"
version=
"1.0.0"
description=
"ONOS sample playground application"
>
<feature>
onos-api
</feature>
...
...
Please
register
or
login
to post a comment