protocol independent host tracker
Change-Id: I192a17ee6eee347f6a7d8e251cecc49cbe36f8dc
Showing
7 changed files
with
166 additions
and
1 deletions
... | @@ -105,8 +105,8 @@ | ... | @@ -105,8 +105,8 @@ |
105 | <bundle>mvn:org.onlab.onos/onos-of-ctl/1.0.0-SNAPSHOT</bundle> | 105 | <bundle>mvn:org.onlab.onos/onos-of-ctl/1.0.0-SNAPSHOT</bundle> |
106 | 106 | ||
107 | <bundle>mvn:org.onlab.onos/onos-lldp-provider/1.0.0-SNAPSHOT</bundle> | 107 | <bundle>mvn:org.onlab.onos/onos-lldp-provider/1.0.0-SNAPSHOT</bundle> |
108 | + <bundle>mvn:org.onlab.onos/onos-host-provider/1.0.0-SNAPSHOT</bundle> | ||
108 | <bundle>mvn:org.onlab.onos/onos-of-provider-device/1.0.0-SNAPSHOT</bundle> | 109 | <bundle>mvn:org.onlab.onos/onos-of-provider-device/1.0.0-SNAPSHOT</bundle> |
109 | - <bundle>mvn:org.onlab.onos/onos-of-provider-host/1.0.0-SNAPSHOT</bundle> | ||
110 | <bundle>mvn:org.onlab.onos/onos-of-provider-packet/1.0.0-SNAPSHOT</bundle> | 110 | <bundle>mvn:org.onlab.onos/onos-of-provider-packet/1.0.0-SNAPSHOT</bundle> |
111 | <bundle>mvn:org.onlab.onos/onos-of-provider-flow/1.0.0-SNAPSHOT</bundle> | 111 | <bundle>mvn:org.onlab.onos/onos-of-provider-flow/1.0.0-SNAPSHOT</bundle> |
112 | 112 | ... | ... |
providers/host/bin/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
5 | + <modelVersion>4.0.0</modelVersion> | ||
6 | + | ||
7 | + <parent> | ||
8 | + <groupId>org.onlab.onos</groupId> | ||
9 | + <artifactId>onos-of-providers</artifactId> | ||
10 | + <version>1.0.0-SNAPSHOT</version> | ||
11 | + <relativePath>../pom.xml</relativePath> | ||
12 | + </parent> | ||
13 | + | ||
14 | + <artifactId>onos-of-provider-host</artifactId> | ||
15 | + <packaging>bundle</packaging> | ||
16 | + | ||
17 | + <description>ONOS OpenFlow protocol host provider</description> | ||
18 | + | ||
19 | +</project> |
providers/host/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
5 | + <modelVersion>4.0.0</modelVersion> | ||
6 | + | ||
7 | + <parent> | ||
8 | + <groupId>org.onlab.onos</groupId> | ||
9 | + <artifactId>onos-providers</artifactId> | ||
10 | + <version>1.0.0-SNAPSHOT</version> | ||
11 | + <relativePath>../pom.xml</relativePath> | ||
12 | + </parent> | ||
13 | + | ||
14 | + | ||
15 | + <artifactId>onos-host-provider</artifactId> | ||
16 | + <packaging>bundle</packaging> | ||
17 | + | ||
18 | + <description>ONOS host tracking provider</description> | ||
19 | + | ||
20 | +</project> |
1 | +package org.onlab.onos.provider.host.impl; | ||
2 | + | ||
3 | +import org.apache.felix.scr.annotations.Activate; | ||
4 | +import org.apache.felix.scr.annotations.Component; | ||
5 | +import org.apache.felix.scr.annotations.Deactivate; | ||
6 | +import org.apache.felix.scr.annotations.Reference; | ||
7 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
8 | +import org.onlab.onos.net.ConnectPoint; | ||
9 | +import org.onlab.onos.net.Host; | ||
10 | +import org.onlab.onos.net.HostId; | ||
11 | +import org.onlab.onos.net.HostLocation; | ||
12 | +import org.onlab.onos.net.host.DefaultHostDescription; | ||
13 | +import org.onlab.onos.net.host.HostDescription; | ||
14 | +import org.onlab.onos.net.host.HostProvider; | ||
15 | +import org.onlab.onos.net.host.HostProviderRegistry; | ||
16 | +import org.onlab.onos.net.host.HostProviderService; | ||
17 | +import org.onlab.onos.net.packet.PacketContext; | ||
18 | +import org.onlab.onos.net.packet.PacketProcessor; | ||
19 | +import org.onlab.onos.net.packet.PacketService; | ||
20 | +import org.onlab.onos.net.provider.AbstractProvider; | ||
21 | +import org.onlab.onos.net.provider.ProviderId; | ||
22 | +import org.onlab.onos.net.topology.Topology; | ||
23 | +import org.onlab.onos.net.topology.TopologyService; | ||
24 | + | ||
25 | +import org.onlab.packet.ARP; | ||
26 | +import org.onlab.packet.Ethernet; | ||
27 | + | ||
28 | +import org.onlab.packet.IpPrefix; | ||
29 | +import org.onlab.packet.VlanId; | ||
30 | +import org.slf4j.Logger; | ||
31 | + | ||
32 | +import static org.slf4j.LoggerFactory.getLogger; | ||
33 | + | ||
34 | +/** | ||
35 | + * Provider which uses an OpenFlow controller to detect network | ||
36 | + * end-station hosts. | ||
37 | + */ | ||
38 | +@Component(immediate = true) | ||
39 | +public class HostLocationProvider extends AbstractProvider implements HostProvider { | ||
40 | + | ||
41 | + private final Logger log = getLogger(getClass()); | ||
42 | + | ||
43 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
44 | + protected HostProviderRegistry providerRegistry; | ||
45 | + | ||
46 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
47 | + protected PacketService pktService; | ||
48 | + | ||
49 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
50 | + protected TopologyService topologyService; | ||
51 | + | ||
52 | + private HostProviderService providerService; | ||
53 | + | ||
54 | + private final InternalHostProvider processor = new InternalHostProvider(); | ||
55 | + | ||
56 | + | ||
57 | + /** | ||
58 | + * Creates an OpenFlow host provider. | ||
59 | + */ | ||
60 | + public HostLocationProvider() { | ||
61 | + super(new ProviderId("of", "org.onlab.onos.provider.host")); | ||
62 | + } | ||
63 | + | ||
64 | + @Activate | ||
65 | + public void activate() { | ||
66 | + providerService = providerRegistry.register(this); | ||
67 | + pktService.addProcessor(processor, 1); | ||
68 | + log.info("Started"); | ||
69 | + } | ||
70 | + | ||
71 | + @Deactivate | ||
72 | + public void deactivate() { | ||
73 | + providerRegistry.unregister(this); | ||
74 | + pktService.removeProcessor(processor); | ||
75 | + providerService = null; | ||
76 | + log.info("Stopped"); | ||
77 | + } | ||
78 | + | ||
79 | + @Override | ||
80 | + public void triggerProbe(Host host) { | ||
81 | + log.info("Triggering probe on device {}", host); | ||
82 | + } | ||
83 | + | ||
84 | + private class InternalHostProvider implements PacketProcessor { | ||
85 | + | ||
86 | + @Override | ||
87 | + public void process(PacketContext context) { | ||
88 | + Ethernet eth = context.inPacket().parsed(); | ||
89 | + | ||
90 | + VlanId vlan = VlanId.vlanId(eth.getVlanID()); | ||
91 | + ConnectPoint heardOn = context.inPacket().receivedFrom(); | ||
92 | + | ||
93 | + // If this is not an edge port, bail out. | ||
94 | + Topology topology = topologyService.currentTopology(); | ||
95 | + if (topologyService.isInfrastructure(topology, heardOn)) { | ||
96 | + return; | ||
97 | + } | ||
98 | + | ||
99 | + HostLocation hloc = new HostLocation(heardOn, System.currentTimeMillis()); | ||
100 | + | ||
101 | + HostId hid = HostId.hostId(eth.getSourceMAC(), vlan); | ||
102 | + | ||
103 | + // Potentially a new or moved host | ||
104 | + if (eth.getEtherType() == Ethernet.TYPE_ARP) { | ||
105 | + ARP arp = (ARP) eth.getPayload(); | ||
106 | + IpPrefix ip = IpPrefix.valueOf(arp.getSenderProtocolAddress()); | ||
107 | + HostDescription hdescr = | ||
108 | + new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc, ip); | ||
109 | + providerService.hostDetected(hid, hdescr); | ||
110 | + | ||
111 | + } else if (eth.getEtherType() == Ethernet.TYPE_IPV4) { | ||
112 | + //Do not learn new ip from ip packet. | ||
113 | + HostDescription hdescr = | ||
114 | + new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc); | ||
115 | + providerService.hostDetected(hid, hdescr); | ||
116 | + | ||
117 | + } | ||
118 | + } | ||
119 | + } | ||
120 | +} |
providers/openflow/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
... | @@ -38,6 +38,7 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -38,6 +38,7 @@ import static org.slf4j.LoggerFactory.getLogger; |
38 | * end-station hosts. | 38 | * end-station hosts. |
39 | */ | 39 | */ |
40 | @Component(immediate = true) | 40 | @Component(immediate = true) |
41 | +@Deprecated | ||
41 | public class OpenFlowHostProvider extends AbstractProvider implements HostProvider { | 42 | public class OpenFlowHostProvider extends AbstractProvider implements HostProvider { |
42 | 43 | ||
43 | private final Logger log = getLogger(getClass()); | 44 | private final Logger log = getLogger(getClass()); | ... | ... |
-
Please register or login to post a comment