Added application that adds a topology overlay displaying additional statistics of links.

Change-Id: Ie82ce67ead64b9b62d6ab55f3ef8ac0f62946d9f
diff --git a/apps/linkprops/BUCK b/apps/linkprops/BUCK
new file mode 100644
index 0000000..324bd22
--- /dev/null
+++ b/apps/linkprops/BUCK
@@ -0,0 +1,16 @@
+COMPILE_DEPS = [
+    '//lib:CORE_DEPS',
+    '//lib:JACKSON',
+    '//incubator/api:onos-incubator-api'
+]
+
+osgi_jar_with_tests (
+    deps = COMPILE_DEPS,
+)
+
+onos_app (
+  title = 'Link Properties',
+  description = 'Shows more link properties',
+  category = 'Monitoring',
+  url = 'https://onosproject.org/',
+)
diff --git a/apps/linkprops/pom.xml b/apps/linkprops/pom.xml
new file mode 100644
index 0000000..2f5594d
--- /dev/null
+++ b/apps/linkprops/pom.xml
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2017 Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  --><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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.onosproject.linkprops</groupId>
+    <artifactId>linkprops</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <description>Link Properties ONOS Application</description>
+    <url>http://onosproject.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <onos.version>1.11.0-SNAPSHOT</onos.version>
+        <onos.app.name>org.onosproject.linkprops</onos.app.name>
+        <onos.app.title>Link Properties App</onos.app.title>
+        <onos.app.category>default</onos.app.category>
+        <onos.app.url>http://onosproject.org</onos.app.url>
+        <onos.app.readme>link properties</onos.app.readme>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+            <version>${onos.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-osgi</artifactId>
+            <version>${onos.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+            <version>${onos.version}</version>
+            <scope>test</scope>
+            <classifier>tests</classifier>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <version>1.9.12</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-incubator-api</artifactId>
+            <version>1.11.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>3.0.1</version>
+                <extensions>true</extensions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.5.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+                <version>1.21.0</version>
+                <executions>
+                    <execution>
+                        <id>generate-scr-srcdescriptor</id>
+                        <goals>
+                            <goal>scr</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <supportedProjectTypes>
+                        <supportedProjectType>bundle</supportedProjectType>
+                        <supportedProjectType>war</supportedProjectType>
+                    </supportedProjectTypes>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.onosproject</groupId>
+                <artifactId>onos-maven-plugin</artifactId>
+                <version>1.10</version>
+                <executions>
+                    <execution>
+                        <id>cfg</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>cfg</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>swagger</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>swagger</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>app</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>app</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/apps/linkprops/src/main/java/org/onosproject/linkprops/LinkPropApp.java b/apps/linkprops/src/main/java/org/onosproject/linkprops/LinkPropApp.java
new file mode 100644
index 0000000..e3c577c
--- /dev/null
+++ b/apps/linkprops/src/main/java/org/onosproject/linkprops/LinkPropApp.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2017-present Open Networking Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.linkprops;
+
+import com.google.common.collect.ImmutableList;
+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.onosproject.ui.UiExtension;
+import org.onosproject.ui.UiExtensionService;
+import org.onosproject.ui.UiMessageHandlerFactory;
+import org.onosproject.ui.UiTopoOverlayFactory;
+import org.onosproject.ui.UiView;
+import org.onosproject.ui.UiViewHidden;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+/**
+ * Skeletal ONOS UI Topology-Overlay application component.
+ */
+@Component(immediate = true)
+public class LinkPropApp {
+
+    private static final ClassLoader CL = LinkPropApp.class.getClassLoader();
+    private static final String VIEW_ID = "lpTopov";
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected UiExtensionService uiExtensionService;
+
+    // List of application views
+    private final List<UiView> uiViews = ImmutableList.of(
+            new UiViewHidden(VIEW_ID)
+    );
+
+    // Factory for UI message handlers
+    private final UiMessageHandlerFactory messageHandlerFactory =
+            () -> ImmutableList.of(
+                    new LinkPropsTopovMessageHandler()
+            );
+
+    // Factory for UI topology overlays
+    private final UiTopoOverlayFactory topoOverlayFactory =
+            () -> ImmutableList.of(
+                    new LinkPropsTopovOverlay()
+            );
+
+    // Application UI extension
+    protected UiExtension extension =
+            new UiExtension.Builder(CL, uiViews)
+                    .resourcePath(VIEW_ID)
+                    .messageHandlerFactory(messageHandlerFactory)
+                    .topoOverlayFactory(topoOverlayFactory)
+                    .build();
+
+    @Activate
+    protected void activate() {
+        uiExtensionService.register(extension);
+        log.info("Started");
+    }
+
+    @Deactivate
+    protected void deactivate() {
+        uiExtensionService.unregister(extension);
+        log.info("Stopped");
+    }
+
+}
diff --git a/apps/linkprops/src/main/java/org/onosproject/linkprops/LinkPropsTopovMessageHandler.java b/apps/linkprops/src/main/java/org/onosproject/linkprops/LinkPropsTopovMessageHandler.java
new file mode 100644
index 0000000..908c65c
--- /dev/null
+++ b/apps/linkprops/src/main/java/org/onosproject/linkprops/LinkPropsTopovMessageHandler.java
@@ -0,0 +1,369 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.linkprops;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableSet;
+import org.onlab.osgi.ServiceDirectory;
+import org.onlab.util.Bandwidth;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Element;
+import org.onosproject.net.HostId;
+import org.onosproject.net.Link;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.host.HostService;
+import org.onosproject.net.link.LinkService;
+import org.onosproject.net.resource.ContinuousResource;
+import org.onosproject.ui.RequestHandler;
+import org.onosproject.ui.UiConnection;
+import org.onosproject.ui.UiMessageHandler;
+import org.onosproject.ui.topo.Highlights;
+import org.onosproject.ui.topo.TopoJson;
+import org.onosproject.net.resource.DiscreteResourceId;
+import org.onosproject.net.resource.Resources;
+import org.onosproject.net.resource.ResourceQueryService;
+import org.onosproject.incubator.net.PortStatisticsService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * ONOS UI Topology overlay for LinkProps. Creates the highlights for each link
+ * depending on the selected mode (rate,byte,band) and adds labels to egress
+ * links of the device being hovered over.
+ */
+public class LinkPropsTopovMessageHandler extends UiMessageHandler {
+
+    private static final String LP_TOPOV_DISPLAY_START = "linkPropsTopovDisplayStart";
+    private static final String LP_TOPOV_DISPLAY_UPDATE = "linkPropsTopovDisplayUpdate";
+    private static final String LP_TOPOV_DISPLAY_STOP = "linkPropsTopovDisplayStop";
+
+    private static final String ID = "id";
+    private static final String MODE = "mode";
+
+    private enum Mode { IDLE, RATE, BYTE, BAND }
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private DeviceService deviceService;
+    private HostService hostService;
+    private LinkService linkService;
+    private PortStatisticsService portStatisticsService;
+    private ResourceQueryService resourceQueryService;
+
+    private Mode currentMode = Mode.IDLE;
+    private Element elementOfNote;
+
+
+    // ===============-=-=-=-=-=-======================-=-=-=-=-=-=-================================
+
+
+    @Override
+    public void init(UiConnection connection, ServiceDirectory directory) {
+        super.init(connection, directory);
+        deviceService = directory.get(DeviceService.class);
+        hostService = directory.get(HostService.class);
+        linkService = directory.get(LinkService.class);
+        portStatisticsService = directory.get(PortStatisticsService.class);
+        resourceQueryService = directory.get(ResourceQueryService.class);
+    }
+
+    @Override
+    protected Collection<RequestHandler> createRequestHandlers() {
+        return ImmutableSet.of(
+                new DisplayStartHandler(),
+                new DisplayUpdateHandler(),
+                new DisplayStopHandler()
+        );
+    }
+
+    // === -------------------------
+    // === Handler classes
+
+    private final class DisplayStartHandler extends RequestHandler {
+        public DisplayStartHandler() {
+            super(LP_TOPOV_DISPLAY_START);
+        }
+
+        @Override
+        public void process(ObjectNode payload) {
+            String mode = string(payload, MODE);
+
+            log.debug("Start Display: mode [{}]", mode);
+            clearState();
+            clearForMode();
+
+            switch (mode) {
+                case "rate":
+                    currentMode = Mode.RATE;
+                    sendRateData();
+                    break;
+
+                case "byte":
+                    currentMode = Mode.BYTE;
+                    sendByteData();
+                    break;
+
+                case "band":
+                    currentMode = Mode.BAND;
+                    sendBandwidth();
+                    break;
+
+                default:
+                    currentMode = Mode.IDLE;
+                    break;
+            }
+        }
+    }
+
+    private final class DisplayUpdateHandler extends RequestHandler {
+        public DisplayUpdateHandler() {
+            super(LP_TOPOV_DISPLAY_UPDATE);
+        }
+
+        @Override
+        public void process(ObjectNode payload) {
+            String id = string(payload, ID);
+            log.debug("Update Display: id [{}]", id);
+            if (!Strings.isNullOrEmpty(id)) {
+                updateForMode(id);
+            } else {
+                clearForMode();
+            }
+        }
+    }
+
+    private final class DisplayStopHandler extends RequestHandler {
+        public DisplayStopHandler() {
+            super(LP_TOPOV_DISPLAY_STOP);
+        }
+
+        @Override
+        public void process(ObjectNode payload) {
+            log.debug("Stop Display");
+            clearState();
+            clearForMode();
+        }
+    }
+
+    // === ------------
+
+    private void clearState() {
+        currentMode = Mode.IDLE;
+        elementOfNote = null;
+    }
+
+    private void updateForMode(String id) {
+        log.debug("host service: {}", hostService);
+        log.debug("device service: {}", deviceService);
+
+        try {
+            HostId hid = HostId.hostId(id);
+            log.debug("host id {}", hid);
+            elementOfNote = hostService.getHost(hid);
+            log.debug("host element {}", elementOfNote);
+
+        } catch (Exception e) {
+            try {
+                DeviceId did = DeviceId.deviceId(id);
+                log.debug("device id {}", did);
+                elementOfNote = deviceService.getDevice(did);
+                log.debug("device element {}", elementOfNote);
+
+            } catch (Exception e2) {
+                log.debug("Unable to process ID [{}]", id);
+                elementOfNote = null;
+            }
+        }
+
+        switch (currentMode) {
+            case RATE:
+                sendRateData();
+                break;
+
+            case BYTE:
+                sendByteData();
+                break;
+
+            case BAND:
+                sendBandwidth();
+                break;
+
+            default:
+                break;
+        }
+
+    }
+
+    private void clearForMode() {
+        sendHighlights(new Highlights());
+    }
+
+    private void sendHighlights(Highlights highlights) {
+        sendMessage(TopoJson.highlightsMessage(highlights));
+    }
+
+
+    private void sendRateData() {
+        if (elementOfNote != null && elementOfNote instanceof Device) {
+            DeviceId devId = (DeviceId) elementOfNote.id();
+            Set<Link> links = linkService.getDeviceEgressLinks(devId);
+            Highlights highlights = getLinkSpeed(links, devId);
+            sendHighlights(highlights);
+        }
+    }
+
+    private void sendBandwidth() {
+        if (elementOfNote != null && elementOfNote instanceof Device) {
+            DeviceId devId = (DeviceId) elementOfNote.id();
+            Set<Link> links = linkService.getDeviceEgressLinks(devId);
+            Highlights highlights = getBandwidth(links, devId);
+            sendHighlights(highlights);
+        }
+    }
+
+    /**
+     * Gets the links connected to the highlighted device.
+     * Creates a ContinuousResource object for each link
+     * and gets the bandwidth of the link from the query
+     * and sets the label of the link as the bandwidth value.
+     */
+    private Highlights getBandwidth(Set<Link> links, DeviceId devId) {
+        LpLinkMap linkMap = new LpLinkMap();
+        if (links != null) {
+            log.debug("Processing {} links", links.size());
+            links.forEach(linkMap::add);
+        } else {
+            log.debug("No egress links found for device {}", devId);
+        }
+
+        Highlights highlights = new Highlights();
+
+        PortNumber portnum = PortNumber.portNumber((int) links.iterator().next().src().port().toLong());
+
+        for (LpLink dlink : linkMap.biLinks()) {
+            DiscreteResourceId parent = Resources.discrete(devId, portnum).id();
+            ContinuousResource continuousResource =
+                    (ContinuousResource) resourceQueryService.getAvailableResources(parent,
+                                                                                    Bandwidth.class).iterator().next();
+            double availBandwidth = continuousResource.value();
+
+            dlink.makeImportant().setLabel(Double.toString(availBandwidth) + " bytes/s");
+            highlights.add(dlink.highlight(null));
+        }
+        return highlights;
+    }
+
+    /**
+     * Gets the links connected to the highlighted device.
+     * Uses PortStatisticsService to get a load object of
+     * the links and find the rate of data flow out of the
+     * device via that link (src) and into the device via
+     * that link (dst), because dlink.two() gives a
+     * NullPointerException. Creates a label which displays
+     * the src and dst rates for the link.
+     */
+    private Highlights getLinkSpeed(Set<Link> links, DeviceId devId) {
+        LpLinkMap linkMap = new LpLinkMap();
+        if (links != null) {
+            log.debug("Processing {} links", links.size());
+            links.forEach(linkMap::add);
+        } else {
+            log.debug("No egress links found for device {}", devId);
+        }
+
+        Highlights highlights = new Highlights();
+
+        for (LpLink dlink : linkMap.biLinks()) {
+            String rate = "Out: " + getSpeedString((portStatisticsService.load(dlink.one().src()).rate())) + " | In: "
+                    + getSpeedString((portStatisticsService.load(dlink.one().dst()).rate()));
+            dlink.makeImportant().setLabel(rate);
+            highlights.add(dlink.highlight(null));
+        }
+        return highlights;
+    }
+
+    private String getSpeedString(Long speed) {
+        if (speed > 1_000_000_000) {
+            return Long.toString(speed / 1_000_000_000) + "Gb/s";
+        } else if (speed > 1_000_000) {
+            return Long.toString(speed / 1_000_000) + "Mb/s";
+        } else if (speed > 1_000) {
+            return Long.toString(speed / 1_000) + "kb/s";
+        } else {
+            return Long.toString(speed) + "bytes/s";
+        }
+    }
+
+    private void sendByteData() {
+        if (elementOfNote != null && elementOfNote instanceof Device) {
+            DeviceId devId = (DeviceId) elementOfNote.id();
+            Set<Link> links = linkService.getDeviceEgressLinks(devId);
+            Highlights highlights = getTotalBytes(links, devId);
+            sendHighlights(highlights);
+        }
+    }
+
+    /**
+     * Gets the links connected to the highlighted device.
+     * Uses PortStatisticsService to get a load object of
+     * the links and find the total number of bytes sent out
+     * of the device via that link (src) and into the device
+     * via that link (dst), because dlink.two() gives a
+     * NullPointerException. Creates a label which displays
+     * the src and dst total bytes for the link.
+     */
+    private Highlights getTotalBytes(Set<Link> links, DeviceId devId) {
+        LpLinkMap linkMap = new LpLinkMap();
+        if (links != null) {
+            log.debug("Processing {} links", links.size());
+            links.forEach(linkMap::add);
+        } else {
+            log.debug("No egress links found for device {}", devId);
+        }
+
+        Highlights highlights = new Highlights();
+
+        for (LpLink dlink : linkMap.biLinks()) {
+            String bytes = "Out: " + getBytesString(portStatisticsService.load(dlink.one().src()).latest()) + " | In: "
+                    + getBytesString(portStatisticsService.load(dlink.one().dst()).latest());
+            dlink.makeImportant().setLabel(bytes);
+            highlights.add(dlink.highlight(null));
+        }
+        return highlights;
+    }
+
+    private String getBytesString(Long bytes) {
+        final long tb = (long) 1_000_000_000_000.0;
+        if (bytes > tb) {
+            return Long.toString(bytes / tb) + "Tb";
+        } else if (bytes > 1_000_000_000) {
+            return Long.toString(bytes / 1_000_000_000) + "Gb";
+        } else if (bytes > 1_000_000) {
+            return Long.toString(bytes / 1_000_000) + "Mb";
+        } else if (bytes > 1_000) {
+            return Long.toString(bytes / 1_000) + "kb";
+        } else {
+            return Long.toString(bytes) + "bytes";
+        }
+    }
+
+}
diff --git a/apps/linkprops/src/main/java/org/onosproject/linkprops/LinkPropsTopovOverlay.java b/apps/linkprops/src/main/java/org/onosproject/linkprops/LinkPropsTopovOverlay.java
new file mode 100644
index 0000000..63f51d7
--- /dev/null
+++ b/apps/linkprops/src/main/java/org/onosproject/linkprops/LinkPropsTopovOverlay.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.linkprops;
+
+import org.onosproject.ui.UiTopoOverlay;
+import org.onosproject.ui.topo.PropertyPanel;
+import org.onosproject.ui.GlyphConstants;
+
+import static org.onosproject.ui.topo.TopoConstants.Properties.FLOWS;
+import static org.onosproject.ui.topo.TopoConstants.Properties.INTENTS;
+import static org.onosproject.ui.topo.TopoConstants.Properties.TOPOLOGY_SSCS;
+import static org.onosproject.ui.topo.TopoConstants.Properties.TUNNELS;
+import static org.onosproject.ui.topo.TopoConstants.Properties.VERSION;
+
+/**
+ * Link Properties topology overlay.
+ */
+public class LinkPropsTopovOverlay extends UiTopoOverlay {
+
+    // NOTE: this must match the ID defined in sampleTopov.js
+    private static final String OVERLAY_ID = "linkprops-overlay";
+
+    private static final String MY_TITLE = "Link Properties";
+    private static final String MY_VERSION = "Beta-1.0.0042";
+
+
+    public LinkPropsTopovOverlay() {
+        super(OVERLAY_ID);
+    }
+
+
+    @Override
+    public void modifySummary(PropertyPanel pp) {
+        pp.title(MY_TITLE)
+                .glyphId(GlyphConstants.CROWN)
+                .removeProps(
+                        TOPOLOGY_SSCS,
+                        INTENTS,
+                        TUNNELS,
+                        FLOWS,
+                        VERSION
+                )
+                .addProp(VERSION, MY_VERSION);
+    }
+
+}
diff --git a/apps/linkprops/src/main/java/org/onosproject/linkprops/LpLink.java b/apps/linkprops/src/main/java/org/onosproject/linkprops/LpLink.java
new file mode 100644
index 0000000..8b74dd2
--- /dev/null
+++ b/apps/linkprops/src/main/java/org/onosproject/linkprops/LpLink.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.linkprops;
+
+import org.onosproject.net.Link;
+import org.onosproject.net.LinkKey;
+import org.onosproject.ui.topo.BiLink;
+import org.onosproject.ui.topo.LinkHighlight;
+import org.onosproject.ui.topo.LinkHighlight.Flavor;
+
+/**
+ * Our demo concrete class of a bi-link. We give it state so we can decide
+ * how to create link highlights.
+ */
+public class LpLink extends BiLink {
+
+    private boolean important = false;
+    private String label = null;
+
+    public LpLink(LinkKey key, Link link) {
+        super(key, link);
+    }
+
+    public LpLink makeImportant() {
+        important = true;
+        return this;
+    }
+
+    public LpLink setLabel(String label) {
+        this.label = label;
+        return this;
+    }
+
+    @Override
+    public LinkHighlight highlight(Enum<?> anEnum) {
+        Flavor flavor = important ? Flavor.PRIMARY_HIGHLIGHT
+                : Flavor.SECONDARY_HIGHLIGHT;
+        return new LinkHighlight(this.linkId(), flavor)
+                .setLabel(label);
+    }
+}
diff --git a/apps/linkprops/src/main/java/org/onosproject/linkprops/LpLinkMap.java b/apps/linkprops/src/main/java/org/onosproject/linkprops/LpLinkMap.java
new file mode 100644
index 0000000..f840f44
--- /dev/null
+++ b/apps/linkprops/src/main/java/org/onosproject/linkprops/LpLinkMap.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.linkprops;
+
+import org.onosproject.net.Link;
+import org.onosproject.net.LinkKey;
+import org.onosproject.ui.topo.BiLinkMap;
+
+/**
+ * Our concrete link map.
+ */
+public class LpLinkMap extends BiLinkMap<LpLink> {
+    @Override
+    protected LpLink create(LinkKey linkKey, Link link) {
+        return new LpLink(linkKey, link);
+    }
+}
diff --git a/apps/linkprops/src/main/java/org/onosproject/linkprops/package-info.java b/apps/linkprops/src/main/java/org/onosproject/linkprops/package-info.java
new file mode 100644
index 0000000..f51ba13
--- /dev/null
+++ b/apps/linkprops/src/main/java/org/onosproject/linkprops/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * GUI topology view overlay that displays link properties.
+ */
+package org.onosproject.linkprops;
\ No newline at end of file
diff --git a/apps/linkprops/src/main/resources/app/view/lpTopov/lpTopov.css b/apps/linkprops/src/main/resources/app/view/lpTopov/lpTopov.css
new file mode 100644
index 0000000..cbf460f
--- /dev/null
+++ b/apps/linkprops/src/main/resources/app/view/lpTopov/lpTopov.css
@@ -0,0 +1,2 @@
+/* css for sample app topology overlay  */
+
diff --git a/apps/linkprops/src/main/resources/app/view/lpTopov/lpTopov.html b/apps/linkprops/src/main/resources/app/view/lpTopov/lpTopov.html
new file mode 100644
index 0000000..b1c9acb
--- /dev/null
+++ b/apps/linkprops/src/main/resources/app/view/lpTopov/lpTopov.html
@@ -0,0 +1,4 @@
+<!-- partial HTML -->
+<div id="ov-sample-topov">
+    <p>This is a hidden view .. just a placeholder to house the javascript</p>
+</div>
diff --git a/apps/linkprops/src/main/resources/app/view/lpTopov/lpTopov.js b/apps/linkprops/src/main/resources/app/view/lpTopov/lpTopov.js
new file mode 100644
index 0000000..5596a82
--- /dev/null
+++ b/apps/linkprops/src/main/resources/app/view/lpTopov/lpTopov.js
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ Module containing the "business logic" for the Link Props topology overlay.
+ */
+
+(function () {
+    'use strict';
+
+    // injected refs
+    var $log, fs, flash, wss;
+
+    // constants
+    var displayStart = 'linkPropsTopovDisplayStart',
+        displayUpdate = 'linkPropsTopovDisplayUpdate',
+        displayStop = 'linkPropsTopovDisplayStop';
+
+    // internal state
+    var currentMode = null;
+
+
+    // === ---------------------------
+    // === Helper functions
+
+    function sendDisplayStart(mode) {
+        wss.sendEvent(displayStart, {
+            mode: mode
+        });
+    }
+
+    function sendDisplayUpdate(what) {
+        wss.sendEvent(displayUpdate, {
+            id: what ? what.id : ''
+        });
+    }
+
+    function sendDisplayStop() {
+        wss.sendEvent(displayStop);
+    }
+
+    // === ---------------------------
+    // === Main API functions
+
+    function startDisplay(mode) {
+        if (currentMode === mode) {
+            $log.debug('(in mode', mode, 'already)');
+        } else {
+            currentMode = mode;
+            sendDisplayStart(mode);
+            flash.flash('Starting display mode: ' + mode);
+        }
+    }
+
+    function updateDisplay(m) {
+        if (currentMode) {
+            sendDisplayUpdate(m);
+        }
+    }
+
+    function stopDisplay() {
+        if (currentMode) {
+            currentMode = null;
+            sendDisplayStop();
+            flash.flash('Canceling display mode');
+            return true;
+        }
+        return false;
+    }
+
+    // === ---------------------------
+    // === Module Factory Definition
+
+    angular.module('ovLpTopov', [])
+        .factory('LinkPropsTopovService',
+        ['$log', 'FnService', 'FlashService', 'WebSocketService',
+
+        function (_$log_, _fs_, _flash_, _wss_) {
+            $log = _$log_;
+            fs = _fs_;
+            flash = _flash_;
+            wss = _wss_;
+
+            return {
+                startDisplay: startDisplay,
+                updateDisplay: updateDisplay,
+                stopDisplay: stopDisplay
+            };
+        }]);
+}());
diff --git a/apps/linkprops/src/main/resources/app/view/lpTopov/lpTopovOverlay.js b/apps/linkprops/src/main/resources/app/view/lpTopov/lpTopovOverlay.js
new file mode 100644
index 0000000..7cb966f
--- /dev/null
+++ b/apps/linkprops/src/main/resources/app/view/lpTopov/lpTopovOverlay.js
@@ -0,0 +1,110 @@
+// Link props topology overlay - client side
+//
+// This is the glue that binds our business logic (in lpTopov.js)
+// to the overlay framework.
+
+(function () {
+    'use strict';
+
+    // injected refs
+    var $log, tov, stds;
+
+    // internal state should be kept in the service module (not here)
+
+    // our overlay definition
+    var overlay = {
+        // NOTE: this must match the ID defined in AppUiTopovOverlay
+        overlayId: 'linkprops-overlay',
+        glyphId: 'topo',
+        tooltip: 'Link Properties',
+
+        activate: function () {
+            $log.debug("Link Props topology overlay ACTIVATED");
+        },
+        deactivate: function () {
+            stds.stopDisplay();
+            $log.debug("Link Props topology overlay DEACTIVATED");
+        },
+
+        // Key bindings for traffic overlay buttons
+        // NOTE: fully qual. button ID is derived from overlay-id and key-name
+        keyBindings: {
+            0: {
+                cb: function () { stds.stopDisplay(); },
+                tt: 'Cancel Display Mode',
+                gid: 'xMark'
+            },
+            V: {
+                cb: function () { stds.startDisplay('rate'); },
+                tt: 'Start Rate Mode',
+                gid: 'ports'
+            },
+            F: {
+                cb: function () { stds.startDisplay('byte'); },
+                tt: 'Start Total Byte Mode',
+                gid: 'allTraffic'
+            },
+            C: {
+                cb: function () { stds.startDisplay('band'); },
+                tt: 'Start Available Bandwidth Mode',
+                gid: 'triangleUp'
+            },
+            G: {
+                cb: buttonCallback,
+                tt: 'Uses the G key',
+                gid: 'crown'
+            },
+
+            _keyOrder: [
+                '0', 'V', 'F', 'C', 'G'
+            ]
+        },
+
+        hooks: {
+            // hook for handling escape key
+            // Must return true to consume ESC, false otherwise.
+            escape: function () {
+                // Must return true to consume ESC, false otherwise.
+                return stds.stopDisplay();
+            },
+
+            // hooks for when the selection changes...
+            empty: function () {
+                selectionCallback('empty');
+            },
+            single: function (data) {
+                selectionCallback('single', data);
+            },
+            mouseover: function (m) {
+                // m has id, class, and type properties
+                $log.debug('mouseover:', m);
+                stds.updateDisplay(m);
+            },
+            mouseout: function () {
+                $log.debug('mouseout');
+                stds.updateDisplay();
+            }
+        }
+    };
+
+
+    function buttonCallback(x) {
+        $log.debug('Toolbar-button callback', x);
+    }
+
+    function selectionCallback(x, d) {
+        $log.debug('Selection callback', x, d);
+    }
+
+    // invoke code to register with the overlay service
+    angular.module('ovLpTopov')
+        .run(['$log', 'TopoOverlayService', 'LinkPropsTopovService',
+
+        function (_$log_, _tov_, _stds_) {
+            $log = _$log_;
+            tov = _tov_;
+            stds = _stds_;
+            tov.register(overlay);
+        }]);
+
+}());
\ No newline at end of file
diff --git a/apps/linkprops/src/main/resources/lpTopov/css.html b/apps/linkprops/src/main/resources/lpTopov/css.html
new file mode 100644
index 0000000..177e456
--- /dev/null
+++ b/apps/linkprops/src/main/resources/lpTopov/css.html
@@ -0,0 +1 @@
+<link rel="stylesheet" href="app/view/lpTopov/lpTopov.css">
\ No newline at end of file
diff --git a/apps/linkprops/src/main/resources/lpTopov/js.html b/apps/linkprops/src/main/resources/lpTopov/js.html
new file mode 100644
index 0000000..d07d258
--- /dev/null
+++ b/apps/linkprops/src/main/resources/lpTopov/js.html
@@ -0,0 +1,2 @@
+<script src="app/view/lpTopov/lpTopov.js"></script>
+<script src="app/view/lpTopov/lpTopovOverlay.js"></script>
\ No newline at end of file