A method for handling packets in a communications network, said being performed by an electronic device, the method comprising: at a first end of a queue in the electronic device, determining admission of a first packet to the first end of the queue based on a length of the first packet, wherein when the admission of the first packet would cause the queue to become full, the admission is further based on a packet value of the first packet and a data structure tracking packet value distribution of packets in the queue; and at a second end of the queue in the electronic device, dropping a second packet from the second end of the queue when the second packet's corresponding packet value is marked as to be dropped in the data structure upon admitting packets to the first end of the queue, wherein: - the data structure comprises a first histogram of first bytes of packets to be processed, and wherein the first bytes of packets are distributed per packet values, - the data structure further comprises a second histogram of second bytes of packets to be dropped, and wherein the second bytes of packets are distributed per packet values, and - determining the admission comprises, when the packet value is higher than a minimum packet value in the first histogram, moving as many bytes with the minimum packet value as needed from the first histogram to the second histogram to accommodate the first packet, wherein, when the bytes are moved to the second histogram, the bytes are marked to be dropped. at a first end of a queue in the electronic device, determining admission of a first packet to the first end of the queue based on a length of the first packet, wherein when the admission of the first packet would cause the queue to become full, the admission is further based on a packet value of the first packet and a data structure tracking packet value distribution of packets in the queue; and at a second end of the queue in the electronic device, dropping a second packet from the second end of the queue when the second packet's corresponding packet value is marked as to be dropped in the data structure upon admitting packets to the first end of the queue, wherein: - the data structure comprises a first histogram of first bytes of packets to be processed, and wherein the first bytes of packets are distributed per packet values, - the data structure further comprises a second histogram of second bytes of packets to be dropped, and wherein the second bytes of packets are distributed per packet values, and - determining the admission comprises, when the packet value is higher than a minimum packet value in the first histogram, moving as many bytes with the minimum packet value as needed from the first histogram to the second histogram to accommodate the first packet, wherein, when the bytes are moved to the second histogram, the bytes are marked to be dropped. - the data structure comprises a first histogram of first bytes of packets to be processed, and wherein the first bytes of packets are distributed per packet values, - the data structure further comprises a second histogram of second bytes of packets to be dropped, and wherein the second bytes of packets are distributed per packet values, and - determining the admission comprises, when the packet value is higher than a minimum packet value in the first histogram, moving as many bytes with the minimum packet value as needed from the first histogram to the second histogram to accommodate the first packet, wherein, when the bytes are moved to the second histogram, the bytes are marked to be dropped. <EOS>