Package ch.rakudave.jnetmap.model

Examples of ch.rakudave.jnetmap.model.Connection


  private static Type type = Type.Ethernet;
  private static double speed = 100;

  @Override
  public Connection create() {
    return new Connection(type, speed);
  }
View Full Code Here


  }

  public void addToMap(final java.util.Map<InetAddress, PingMethod> hosts, final Map map) {
    if (hosts == null || hosts.isEmpty() || map == null) return;
    // TODO devices are added at [0,0], find way to layout properly!
    Connection gToS = new Connection();
    Device gateway = null;
    Device aSwitch = null;
    NetworkIF gatewayIF = null;
    try { // try to find the gateway
      gatewayIF = tryFindIP(map, InetAddress.getByName(subnet.getInfo().getLowAddress()));
    } catch (UnknownHostException ex) {
      Logger.debug("Unable to find gateway-interface", ex);
    }
    if (gatewayIF == null) { // create a gateway if none was found
      gateway = new Host(Type.Router);
      gatewayIF = new PhysicalIF(gateway, gToS, subnet.getInfo().getLowAddress());
      map.addVertex(gateway);
      gateway.addInterface(gatewayIF);
    } else {
      gateway = gatewayIF.getDevice();
    }
    try { // try to find the switch attached to the gateway
      aSwitch = map.getOpposite(gateway, gatewayIF.getConnection());
      // if the opposite is not a switch, reset
      if (aSwitch != null && !aSwitch.getType().toString().toLowerCase().contains("switch")) aSwitch = null;
    } catch (Exception e) {
      Logger.debug("Unable to find opposite", e);
    }
    if (aSwitch == null) { // create a switch if necessary
      aSwitch = new Host(Type.Switch);
      map.addVertex(aSwitch);
      aSwitch.addInterface(new TransparentIF(aSwitch, gToS, gatewayIF));
      map.addEdge(gToS, gateway, aSwitch);
    }
    final Device gw = gateway, sw = aSwitch;
    final NetworkIF gif = gatewayIF;
    for (final InetAddress address : hosts.keySet()) {
      Scheduler.execute(new Runnable() {
        @Override
        public void run() {
          try {
            if (!address.equals(gif.getAddress())) {
              if (tryFindIP(map, address) != null) return;
              Logger.debug("Adding Interface "+address);
              Connection c = new Connection();
              Device d = new Host();
                d.setName(address.getHostName());
                PhysicalIF pif = new PhysicalIF(d, c, address.getHostAddress());
                  pif.setPingMethod(hosts.get(address));
                  pif.setSubnet(subnet.getInfo().getNetmask());
View Full Code Here

          .getPickSupport();
      if (pickSupport != null) {
        final Device vertex = pickSupport.getVertex(layout, p.getX(), p.getY());
        if (vertex != null && startVertex != null) {
          Graph<Device, Connection> graph = vv.getGraphLayout().getGraph();
          Connection newEdge = edgeFactory.create();
          graph.addEdge(newEdge, startVertex, vertex,  edgeIsDirected);
          if (startVertex.equals(vertex)) {
            new InterfaceProperties(owner, vertex.getInterfaceFor(newEdge));
          } else {
            new ConnectionProperties(owner, newEdge);
View Full Code Here

    final Point2D p = e.getPoint();
    final Point2D ivp = p;
    GraphElementAccessor<Device, Connection> pickSupport = vv.getPickSupport();
    if (pickSupport != null) {
      vertex = pickSupport.getVertex(layout, ivp.getX(), ivp.getY());
      final Connection edge = pickSupport.getEdge(layout, ivp.getX(), ivp.getY());
      final PickedState<Device> pickedVertexState = vv.getPickedVertexState();
      final PickedState<Connection> pickedEdgeState = vv.getPickedEdgeState();

      if (vertex != null) {
        pickedVertexState.pick(vertex, false);
View Full Code Here

  LinkedList<NetworkIF> ifs;
  Connection c;

  @Before
  public void setUp() {
    c = new Connection();
    c.setBandwidth(100);
    c.setType(Type.Ethernet);
    c.setStatus(i, Status.UP);
    h = new Host();
    i = new PhysicalIF(h, c, "192.168.0.35");
    ii = new LogicalIF(h, new Connection(), "127.0.0.1");
    iii = null;
    interfaces = new LinkedList<NetworkIF>();
    ifs = new LinkedList<NetworkIF>();
    interfaces.add(0, i);
    interfaces.add(1, ii);
View Full Code Here

  @Before
  public void setUp() {
    status = Status.UP;
    lastSeen = new Date();
    Connection c = new Connection();
    c.setBandwidth(100);
    Host host = new Host();
    pif = new PhysicalIF(host, c, address1);
    pif2 = new PhysicalIF(host, c, address2);
  }
View Full Code Here

  public String gateway = "192.168.0.1";
  Subnet sub = new Subnet(address3);

  @Before
  public void setUp() {
    Connection c = new Connection();
    c.setBandwidth(100);
    Host host = new Host();
    pif = new PhysicalIF(host, c, address1);
    pif2 = new PhysicalIF(host, c, address2);
    tif = new TransparentIF(host, c, pif);
    tif2 = new TransparentIF(host, c, pif2);
View Full Code Here

  public void setUP() {
    Host parent = new Host();
    address = "192.168.0.16";
    address2 = "170.234.120.11";
    failaddress = "Ringo";
    LIF = new LogicalIF(parent, new Connection(), address);
    LIF2 = new LogicalIF(parent, new Connection(), address);
  }
View Full Code Here

TOP

Related Classes of ch.rakudave.jnetmap.model.Connection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.