public void run() {
		// declaration section:
		// declare a server socket and a client socket for the server
		// declare an input and an output stream
		ServerSocket echoServer = null;
		ObjectInputStream ois;
		PrintStream os;
		Socket clientSocket = null;
		// Try to open a server socket on port 9999
		// Note that we can't choose a port less than 1023 if we are not
		// privileged users (root)
		try {
			echoServer = new ServerSocket(port);
			System.out.println("server is running");
		}
		catch (IOException e) {
			System.out.println(e);
		}
		// Create a socket object from the ServerSocket to listen and accept
		// connections.
		// Open input and output streams
		while (true) {
			try {
				clientSocket = echoServer.accept();
				System.out.println("client detected");
				ois = new ObjectInputStream(clientSocket.getInputStream());
				os = new PrintStream(clientSocket.getOutputStream());
				// As long as we receive data, echo that data back to the client.
				while (true) {
					Message message = (Message) ois.readObject();
					System.out.println("message received");
					System.out.println(message);
					Status status = Status.OK;
					for (Rule rule : MessagePasser.getReceiveRule()) {
						status = MessagePasser.checkRule(message, rule);
						// if message matches one rule, then mark this action
						if (!status.equals(Status.OK)) {
							break;
						}
					}
					// if message matches no rule at all, then add it to queue
					if (status.equals(Status.OK)) {
						MessagePasser.addToReceiveBuffer(message);
					} else if (status.equals(Status.DUP)) {
						Message dupM = new Message(message);
						dupM.set_seqNum(message.getSeqNum());
						dupM.set_source(message.getSrc());
						dupM.set_duplicate(true);
						MessagePasser.addToReceiveBuffer(message);
						MessagePasser.addToReceiveBuffer(dupM);
					} else if (status.equals(Status.DELAY)) {
						MessagePasser.addToReceiveDelayBuffer(message);
					}
					System.out.println("send buffer size: " + MessagePasser.receiveBuffer.size());

				}
			}

			catch (IOException | ClassNotFoundException e) {
				System.out.println(e);
			}
		}
	}