protected synchronized boolean insertPacketIntoQueue(Packet pnp)
    {
        int srcID = pnp.getSrcID();     // source entity id
        int destID = pnp.getDestID();   // destination entity id
        int type = pnp.getNetServiceType();     // packet service type

        Double nextTime = (Double) flowTable.get("" + srcID + destID + type);
        if (nextTime == null)
        {
            nextTime = new Double(CF);
            flowTable.put("" + srcID + destID + type, nextTime);
        }

        double pktTime = calculateFinishTime(pnp, nextTime.doubleValue());
        flowTable.put("" + srcID + destID + type, new Double(pktTime));
        insert(pnp, pktTime); // Sort the queue list

        // Keep an statistic regarding the size of the buffers.
        int bufferSize = this.size();

        if (storeStats)
        {
            if (bufferSize > maxBufferSize)
            {
                maxBufferSize = bufferSize;

                fw_write(GridSim.clock() + ", " + bufferSize + ", " +
                        getAvg() + ", " + maxBufferSize + "\n",
                        this.getSchedName() + "_MaxBufferSize.csv");
            }
        }

        return true;
    }