private void internalDequeue(Sim_event ev)
    {
        if (ev == null) {
            return;
        }

        try
        {
            Integer classTypeInt = (Integer) ev.get_data();
            int type = classTypeInt.intValue();

            // check whether the class type is correct or not
            if (type >= packets_.length)
            {
                System.out.println(super.get_name() +
                    ".internalDequeue(): Warning - packet class = " + type +
                    ", num of classes = " + packets_.length);
                type = 0;
            }

            // if no packets in the array, then exit
            if (packets_[type].isEmpty() == true) {
                return;
            }

            // add to final buffer
            Packet pkt = (Packet) packets_[type].remove(0);
            pktList_.add(pkt);

            // send an internal event to itself
            double delay = 0;
            if (pktList_.size() == 1)
            {
                delay = (pkt.getSize() * NetIO.BITS) / baudRate_;
                super.sim_schedule(super.get_id(), delay, DEQUEUE_PACKET);
            }

            // schedule the next packet
            if (packets_[type].isEmpty() == false)
            {
                Packet nextPkt = (Packet) packets_[type].get(0);

                // rate limit next packet
                delay = (nextPkt.getSize() * NetIO.BITS) / rates_[type];
                super.sim_schedule(super.get_id(), delay, INTERNAL_DEQUEUE,
                                   classTypeInt);
            }
        }
        catch (Exception e) {
            // .... empty
        }
    }