From 0d7f5468cba655c6e5b748638d5dc63c7e053b0e Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 28 Oct 2008 16:57:08 +0000 Subject: [PATCH] removed old uAODV code --- .../cooja/examples/project_uaodv/cooja.config | 5 - .../project_uaodv/java/UAODVControl.java | 158 ------------------ .../examples/project_uaodv/java/VisUAODV.java | 113 ------------- .../examples/project_uaodv/uaodv-example.c | 78 --------- 4 files changed, 354 deletions(-) delete mode 100644 tools/cooja/examples/project_uaodv/cooja.config delete mode 100644 tools/cooja/examples/project_uaodv/java/UAODVControl.java delete mode 100644 tools/cooja/examples/project_uaodv/java/VisUAODV.java delete mode 100644 tools/cooja/examples/project_uaodv/uaodv-example.c diff --git a/tools/cooja/examples/project_uaodv/cooja.config b/tools/cooja/examples/project_uaodv/cooja.config deleted file mode 100644 index 01189e433..000000000 --- a/tools/cooja/examples/project_uaodv/cooja.config +++ /dev/null @@ -1,5 +0,0 @@ -se.sics.cooja.GUI.PLUGINS = + VisUAODV UAODVControl -## Not needed since update 2006-08-21. -## Processfiles are thrown to compilation explicitly. -#se.sics.cooja.contikimote.ContikiMoteType.C_SOURCES = + uaodv-example.c - diff --git a/tools/cooja/examples/project_uaodv/java/UAODVControl.java b/tools/cooja/examples/project_uaodv/java/UAODVControl.java deleted file mode 100644 index ae66bee7b..000000000 --- a/tools/cooja/examples/project_uaodv/java/UAODVControl.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Id: UAODVControl.java,v 1.1 2007/03/23 23:33:54 fros4943 Exp $ - */ - -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import javax.swing.*; -import org.apache.log4j.Logger; - -import se.sics.cooja.*; -import se.sics.cooja.contikimote.interfaces.ContikiRS232; -import se.sics.cooja.interfaces.*; - -/** - * @author Fredrik Osterlind - */ -@ClassDescription("uAODV Control") -@PluginType(PluginType.SIM_PLUGIN) -public class UAODVControl extends VisPlugin { - private static final long serialVersionUID = 1L; - private static Logger logger = Logger.getLogger(UAODVControl.class); - private Simulation mySimulation; - private JComboBox sourceComboBox; - private JComboBox destComboBox; - - /** - * @param simulationToVisualize Current simulation - */ - public UAODVControl(Simulation simulationToVisualize, GUI gui) { - super("uAODV Control (uses RS232)", gui); - mySimulation = simulationToVisualize; - - Container mainPane = this.getContentPane(); - mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); - JLabel label; - JPanel smallPane; - - // Create available nodes list - Vector nodeDescs = new Vector(); - for (int i=0; i < mySimulation.getMotesCount(); i++) { - Mote currentMote = mySimulation.getMote(i); - nodeDescs.add("ID=" - + currentMote.getInterfaces().getMoteID().getMoteID() - + ", IP=" - + currentMote.getInterfaces().getIPAddress().getIPString()); - } - - // Create source combo box - label = new JLabel("Select RREQ source"); - - sourceComboBox = new JComboBox(nodeDescs); - if (sourceComboBox.getItemCount() < 1) { - logger.warn("No nodes available"); - } else - sourceComboBox.setSelectedIndex(0); - label.setLabelFor(sourceComboBox); - - smallPane = new JPanel(); - smallPane.add(label); - smallPane.add(Box.createHorizontalStrut(10)); - smallPane.add(sourceComboBox); - - mainPane.add(smallPane); - - // Create destination combo box - label = new JLabel("Select RREQ destination"); - - destComboBox = new JComboBox(nodeDescs); - if (destComboBox.getItemCount() < 1) { - logger.warn("No nodes available"); - } else - destComboBox.setSelectedIndex(0); - label.setLabelFor(destComboBox); - - smallPane = new JPanel(); - smallPane.add(label); - smallPane.add(Box.createHorizontalStrut(10)); - smallPane.add(destComboBox); - - mainPane.add(smallPane); - - // Add set button - smallPane = new JPanel(new BorderLayout()); - JButton setDestinationButton = new JButton("Set IP and send RREQ"); - setDestinationButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - logger.debug("Sending RS232 command now"); - Mote sourceMote = mySimulation.getMote(sourceComboBox.getSelectedIndex()); - Mote destMote = mySimulation.getMote(destComboBox.getSelectedIndex()); - if (sourceMote == null || destMote == null) { - logger.error("Error in mote selection"); - return; - } - - // Get destination IP - IPAddress destIP = destMote.getInterfaces().getIPAddress(); - if (destIP == null) { - logger.error("Error when fetching destination IP"); - return; - } - - // Set destination and start sending by using RS232 - ContikiRS232 rs232 = sourceMote.getInterfaces().getInterfaceOfType(ContikiRS232.class); - if (rs232 == null) { - logger.error("RS232 interface is null!"); - return; - } - - rs232.sendSerialMessage("SENDTO>" + destIP.getIPString()); - } - }); - smallPane.add(BorderLayout.EAST, setDestinationButton); - mainPane.add(smallPane); - - - pack(); - - // Tries to select this plugin - try { - setSelected(true); - } catch (java.beans.PropertyVetoException e) { - // Could not select - } - - } - - public void closePlugin() { - } - -} diff --git a/tools/cooja/examples/project_uaodv/java/VisUAODV.java b/tools/cooja/examples/project_uaodv/java/VisUAODV.java deleted file mode 100644 index e6812451e..000000000 --- a/tools/cooja/examples/project_uaodv/java/VisUAODV.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Id: VisUAODV.java,v 1.2 2008/10/15 09:00:52 nifi Exp $ - */ - -import java.awt.*; -import se.sics.cooja.*; -import se.sics.cooja.interfaces.*; -import se.sics.cooja.plugins.*; - -/** - * VisUAODV is a 2D graphical visualizer for simulations with motes running - * UAODV protocol. - * RREQs are painted red, and RREPs green. - * The rest of sent data is painted black. - * - * Interactions with motes are available via registered mote plugins. - * - * @author Fredrik Osterlind - */ -@ClassDescription("uAODV Visualizer") -@PluginType(PluginType.SIM_PLUGIN) -public class VisUAODV extends VisTraffic { - private static final long serialVersionUID = 1L; - - /** - * Creates a new VisUAODV visualizer. - * @param simulationToVisualize Simulation to visualize - */ - public VisUAODV(Simulation simulationToVisualize, GUI gui) { - super(simulationToVisualize, gui); - setTitle("uAODV Visualizer"); - } - - protected void paintConnection(RadioConnection connection, Graphics g2d) { - Point sourcePixelPosition = transformPositionToPixel(connection.getSource().getPosition()); - for (Radio destRadio: connection.getDestinations()) { - Position destPosition = destRadio.getPosition(); - Point destPixelPosition = transformPositionToPixel(destPosition); - g2d.setColor(getColorOf(connection)); - - RadioPacket radioPacket = destRadio.getLastPacketReceived(); - if (radioPacket != null) { - byte[] packet = radioPacket.getPacketData(); - if (isRouteReply(packet)) { - ((Graphics2D) g2d).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f)); - } - - g2d.drawLine(sourcePixelPosition.x, sourcePixelPosition.y, - destPixelPosition.x, destPixelPosition.y); - - int hopCount = getHopCount(packet); - if (hopCount >= 0) - g2d.drawString("" + hopCount, sourcePixelPosition.x, sourcePixelPosition.y); - } - } - } - - protected Color getColorOf(RadioConnection conn) { - RadioPacket radioPacket = conn.getSource().getLastPacketReceived(); - if (radioPacket != null) { - byte[] packet = radioPacket.getPacketData(); - if (isRouteRequest(packet)) - return Color.RED; - else if (isRouteReply(packet)) - return Color.GREEN; - } - return Color.BLACK; - } - - private boolean isRouteRequest(byte[] data) { - if (data.length > 28) - return data[28] == 1; - return false; - } - private boolean isRouteReply(byte[] data) { - if (data.length > 28) - return data[28] == 2; - return false; - } - private int getHopCount(byte[] data) { - if (data.length > 31) - return data[31]; - return -1; - } - -} diff --git a/tools/cooja/examples/project_uaodv/uaodv-example.c b/tools/cooja/examples/project_uaodv/uaodv-example.c deleted file mode 100644 index d1784ee31..000000000 --- a/tools/cooja/examples/project_uaodv/uaodv-example.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Id: uaodv-example.c,v 1.1 2007/03/23 23:33:54 fros4943 Exp $ - */ - -#include -#include "contiki-net.h" -#include "net/uaodv.h" -#include "net/uaodv-rt.h" - -#include "lib/sensors.h" -#include "sys/log.h" - -#include "dev/button-sensor.h" -#include "dev/serial.h" - -/*---------------------------------------------------------------------------*/ -PROCESS(uaodv_example_process, "uAODV example"); - -AUTOSTART_PROCESSES(&uaodv_process, &uaodv_example_process); - -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(uaodv_example_process, ev, data) -{ - static uip_ipaddr_t addr; - - PROCESS_BEGIN(); - - int ipA, ipB, ipC, ipD; - char buf[200]; - - button_sensor.activate(); - serial_init(); - - while(1) { - PROCESS_WAIT_EVENT(); - if(ev == sensors_event && data == &button_sensor && button_sensor.value(0)) { - uip_ipaddr(&addr, 10,10,0,1); - log_message("Sending RREQ to (static) 10.10.0.1\n", ""); - uaodv_request_route_to(&addr); - } else if(ev == serial_event_message) { - sscanf(data, "SENDTO>%d.%d.%d.%d", &ipA, &ipB, &ipC, &ipD); - sprintf(buf, "Sending RREQ to %d.%d.%d.%d .. \n", ipA, ipB, ipC, ipD); - log_message(buf, ""); - uip_ipaddr(&addr, ipA, ipB, ipC, ipD); - uaodv_request_route_to(&addr); - } - } - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/