private void dhcpDiscover(){
        int discoverTime = -1;

        // create discover packet
        LOG.info("create discover packet");
        byte[] discoverMessage = createDiscoverMessage();
        DatagramPacket discoverPacket = null;
        try {
            discoverPacket = new DatagramPacket(discoverMessage,
                    discoverMessage.length,
                    InetAddress.getByName(BroadcastIp),
                    DHCPServerPort);
        } catch (UnknownHostException e) {
        }

        // send discover packet
        LOG.info("begin to send discover message");
        long startTime = System.currentTimeMillis();
        try {
            socket.send(discoverPacket);
            socket.setSoTimeout(DiscoverTimeOut);
        } catch (IOException e) {
            LOG.error("failed to send discover message", e);
            result.setDiscoverTime(discoverTime);
            result.setError(DetectResult.DHCP_SEND_DISCOVER_FAILED, "Failed to send discover message");

            return;
        }

        // wait offer response message
        LOG.info("wait for DHCP offer message");
        boolean gotMessage = false;
        byte[] offerMessage = new byte[512];
        DatagramPacket offerDatagramPacket = new DatagramPacket(offerMessage, offerMessage.length);
        try {
            while (!gotMessage){
                socket.receive(offerDatagramPacket);

                // parse received message
                LOG.info("received a message and parse it");
                // charge transition id
                byte[] byteOfXID = new byte[]{offerMessage[4],offerMessage[5], offerMessage[6],offerMessage[7] };
                int offerXid = Util.bytes2Int(byteOfXID);
                LOG.info("offerXid of the received message is " + offerXid + ", and transactionID is " + transactionID);

                if (offerXid == transactionID){
                    DHCPPacket offerDHCPPacket = DHCPPacket.getPacket(offerDatagramPacket);
                    short offerMessageType = offerDHCPPacket.getOption(DHCPConstants.DHO_DHCP_MESSAGE_TYPE).getValue()[0];

                    if (offerMessageType == DHCPConstants.DHCPOFFER){   // for offer message
                        result.setError(DetectResult.DETECT_SUCCESS, "");
                        gotMessage = true;

                        // get server identifier
                        serverIdentifier = offerDHCPPacket.getOption(DHCPConstants.DHO_DHCP_SERVER_IDENTIFIER).getValue();
                        LOG.info("server identifier of offer message is: "+Util.bytes2Str(serverIdentifier, "."));
                    } else {
                        LOG.error("the received message is not offer message, the message type is "+offerMessageType);
                    }
                }
            }

            discoverTime = (int)(System.currentTimeMillis() - startTime);
        } catch(SocketTimeoutException e){
            LOG.error("Time out exception happened while wait for DHCP Offer message", e);
            result.setError(DetectResult.DHCP_RECV_OFFER_TIMEOUT, "Wait for DHCP Offer message timeout");
        } catch (IOException e) {
            LOG.error("IO exception happened while wait for DHCP Offer message", e);
            result.setError(DetectResult.DHCP_RECV_OFFER_FAILED, "Failed to receive DHCP Offer message");
        }

        result.setDiscoverTime(discoverTime);
    }