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-15 15:29:24 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
025e09f0b64dd8f46e622147327572a6eec56435
025e09f0
1 parent
5786ac65
Added display of hosts in the topology viewer and fixed a glitch in the host provider.
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
26 deletions
apps/tvue/src/main/java/org/onlab/onos/tvue/TopologyResource.java
core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopologyProvider.java
providers/of/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
apps/tvue/src/main/java/org/onlab/onos/tvue/TopologyResource.java
View file @
025e09f
...
...
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.ElementId
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.Path
;
import
org.onlab.onos.net.device.DeviceService
;
...
...
@@ -26,6 +27,7 @@ import java.util.Map;
import
java.util.Set
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
/**
* Topology viewer resource.
...
...
@@ -67,13 +69,10 @@ public class TopologyResource extends BaseResource {
// Merge the exterior and interior vertexes and inject host links as
// the exterior edges.
// Iterator<Host> hosts = hostService.getHosts();
// while (hosts.hasNext()) {
// Host host = hosts.next();
// vertexesNode.add(json(mapper, host.id().ip().toString(), 3, true));
// edgesNode.add(json(mapper, 1, host.ip().toString(),
// host.location().elementId().uri()));
// }
for
(
Host
host
:
hostService
.
getHosts
())
{
vertexesNode
.
add
(
json
(
mapper
,
host
.
id
(),
3
,
true
));
edgesNode
.
add
(
json
(
mapper
,
1
,
host
.
location
(),
new
ConnectPoint
(
host
.
id
(),
portNumber
(-
1
))));
}
// Now put the vertexes and edges into a root node and ship them off
ObjectNode
rootNode
=
mapper
.
createObjectNode
();
...
...
core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopologyProvider.java
View file @
025e09f
...
...
@@ -46,7 +46,8 @@ public class DefaultTopologyProvider extends AbstractProvider
private
static
final
int
MAX_BATCH_MS
=
200
;
private
static
final
int
MAX_THREADS
=
8
;
// FIXME: Replace with a system-wide timer instance
// FIXME: Replace with a system-wide timer instance;
// TODO: Convert to use HashedWheelTimer or produce a variant of that; then decide which we want to adopt
private
static
final
Timer
TIMER
=
new
Timer
();
private
final
Logger
log
=
getLogger
(
getClass
());
...
...
providers/of/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
View file @
025e09f
package
org
.
onlab
.
onos
.
provider
.
of
.
host
.
impl
;
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
;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.onlab.onos.net.
DeviceId
;
import
org.onlab.onos.net.
ConnectPoint
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.onos.net.HostLocation
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.host.DefaultHostDescription
;
import
org.onlab.onos.net.host.HostDescription
;
import
org.onlab.onos.net.host.HostProvider
;
...
...
@@ -19,6 +16,8 @@ import org.onlab.onos.net.host.HostProviderRegistry;
import
org.onlab.onos.net.host.HostProviderService
;
import
org.onlab.onos.net.provider.AbstractProvider
;
import
org.onlab.onos.net.provider.ProviderId
;
import
org.onlab.onos.net.topology.Topology
;
import
org.onlab.onos.net.topology.TopologyService
;
import
org.onlab.onos.of.controller.Dpid
;
import
org.onlab.onos.of.controller.OpenFlowController
;
import
org.onlab.onos.of.controller.OpenFlowPacketContext
;
...
...
@@ -29,8 +28,11 @@ import org.onlab.packet.IPAddress;
import
org.onlab.packet.VLANID
;
import
org.slf4j.Logger
;
import
com.google.common.collect.Sets
;
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
;
/**
...
...
@@ -48,6 +50,9 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
OpenFlowController
controller
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
protected
TopologyService
topologyService
;
private
HostProviderService
providerService
;
private
final
InternalHostProvider
listener
=
new
InternalHostProvider
();
...
...
@@ -87,25 +92,32 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
public
void
handlePacket
(
OpenFlowPacketContext
pktCtx
)
{
Ethernet
eth
=
pktCtx
.
parsed
();
//
p
otentially a new or moved host
//
P
otentially a new or moved host
if
(
eth
.
getEtherType
()
==
Ethernet
.
TYPE_ARP
)
{
VLANID
vlan
=
VLANID
.
vlanId
(
eth
.
getVlanID
());
HostId
hid
=
HostId
.
hostId
(
eth
.
getSourceMAC
(),
vlan
);
HostLocation
hloc
=
new
HostLocation
(
DeviceId
.
deviceId
(
Dpid
.
uri
(
pktCtx
.
dpid
())),
PortNumber
.
portNumber
(
pktCtx
.
inPort
()),
System
.
currentTimeMillis
());
ConnectPoint
heardOn
=
new
ConnectPoint
(
deviceId
(
Dpid
.
uri
(
pktCtx
.
dpid
())),
portNumber
(
pktCtx
.
inPort
()));
// If this is not an edge port, bail out.
Topology
topology
=
topologyService
.
currentTopology
();
if
(
topologyService
.
isInfrastructure
(
topology
,
heardOn
))
{
return
;
}
HostLocation
hloc
=
new
HostLocation
(
deviceId
(
Dpid
.
uri
(
pktCtx
.
dpid
())),
portNumber
(
pktCtx
.
inPort
()),
System
.
currentTimeMillis
());
HostId
hid
=
HostId
.
hostId
(
eth
.
getSourceMAC
(),
vlan
);
ARP
arp
=
(
ARP
)
eth
.
getPayload
();
Set
<
IPAddress
>
ips
=
Sets
.
newHashSet
(
IPAddress
.
valueOf
(
arp
.
getSenderProtocolAddress
()));
HostDescription
hdescr
=
new
DefaultHostDescription
(
eth
.
getSourceMAC
(),
vlan
,
hloc
,
ips
);
Set
<
IPAddress
>
ips
=
newHashSet
(
IPAddress
.
valueOf
(
arp
.
getSenderProtocolAddress
()));
HostDescription
hdescr
=
new
DefaultHostDescription
(
eth
.
getSourceMAC
(),
vlan
,
hloc
,
ips
);
providerService
.
hostDetected
(
hid
,
hdescr
);
}
// TODO: Use DHCP packets as well later...
}
}
...
...
Please
register
or
login
to post a comment