public void terminal() {
    try {
      run();
      InputStreamReader isReader = new InputStreamReader(System.in);
      BufferedReader br = new BufferedReader(isReader);
      System.out.print(">> ");
      String command = br.readLine();
      while (true) {
        if (command.startsWith("detect ")) {
          String[] cmdLine = command.split(" ");
          processDetect(cmdLine[1]);
        } else {
          if (command.startsWith("disconnect ")) {
            String[] cmdLine = command.split(" ");
            processDisconnect(Short.parseShort(cmdLine[1]));
          } else {
            if (command.startsWith("quit")) {
              break;
            } else {
              if (command.startsWith("attach ")) {
                if (validPortNum >= 4) {
                  System.out.println("the router's ports has been full");
                } else {
                  String[] cmdLine = command.split(" ");
                  processAttach(cmdLine[1], Short.parseShort(cmdLine[2]),
                          cmdLine[3], Short.parseShort(cmdLine[4]));
                }
              } else {
                if (command.equals("start")) {
                  //TODO: broadcast the Hello

                }
              }
            }
          }
        }
        System.out.print(">> ");
        command = br.readLine();
      }
      isReader.close();
      br.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }