Exemplo n.º 1
0
  /**
   * This method processes cells that are received from the nic
   *
   * @param cell the cell that was received
   * @param nic the nic the cell was received on
   * @since 1.0
   */
  public void receiveCell(ATMCell cell, ATMNIC nic) {
    if (cell.getIsOAM()) {
      String data = cell.getData();
      if (data.startsWith("callpro")) {
        this.receivedCallProceeding(cell);
      } else if (data.startsWith("conn")) {
        this.receivedConnect(cell);
        int vcNum = this.getIntFromEndOfString(data);
        this.vcNumber = vcNum;
        System.out.println("The connection is setup on VC " + this.vcNumber);
        // send connect ack
        ATMCell callackCell = new ATMCell(0, "callack", this.getTraceID());
        callackCell.setIsOAM(true);
        nic.sendCell(callackCell, this);
        this.sentConnectAck(callackCell);
      } else if (data.startsWith("endack")) {
        this.receivedEndAck(cell);
      } else if (data.startsWith("wait")) {
        this.receivedWait(cell);
        // send setup again
        int destAddr = this.getIntFromEndOfString(data);
        ATMCell setupCell = new ATMCell(0, "setup " + destAddr, this.getTraceID());
        setupCell.setIsOAM(true);
        nic.sendCell(setupCell, this);
        this.sentSetup(setupCell);
      }
    } else {

    }
  }
Exemplo n.º 2
0
  /**
   * This method sends an ATM cell containing 'setup' and an address to the router
   *
   * @param toAddress the address we want to connect to
   * @since 1.0
   */
  public void setupConnection(int toAddress) {
    // Create the ATM cell to send
    ATMCell conn = new ATMCell(0, "setup " + toAddress, this.getTraceID());
    conn.setIsOAM(true);

    // Output to the console
    this.sentSetup(conn);

    // send the cell
    this.nic.sendCell(conn, this);
  }
Exemplo n.º 3
0
  /**
   * This method sends an ATM cell saying that we want to end the VC that we currently have open
   * Currently each computer can only have one VC, but the routers can have many VC open
   *
   * @since 1.0
   */
  public void endConnection() {
    if (this.vcNumber < 0) return;
    // Create the ATM cell to send
    ATMCell end = new ATMCell(this.vcNumber, "end " + this.vcNumber, this.getTraceID());
    end.setIsOAM(true);

    // Output to the console
    this.sentEnd(end);
    this.vcNumber = -1;

    // Send the cell
    this.nic.sendCell(end, this);
  }