A method for communication, comprising: receiving from a packet data network, via ingress interfaces (2 6) of a switching element, packets (32, 34, 3 6) belonging to multiple flows, and forwarding the packets to respective egress interfaces of the switching element for transmission to the network; for each egress interface of the switching element, queuing the packets, belonging to a plurality of the flows, that have been forwarded for transmission through the egress interface; and for each of one or more of the egress interfaces, in each of a succession of arbitration cycles: assessing a respective number of the packets in each of the plurality of the flows that are queued for transmission through the egress interface; assigning the flows for which the respective number is zero to a first group, while assigning the flows for which the respective number is non-zero to a second group; and placing the packets that are forwarded to the egress interface after assigning the flows and that belong to the flows in the first group into a queue having high priority, placing the packets that are forwarded to the egress interface after assigning the flows and that belong to the flows in the second group into a queue having low priority, and transmitting to the network packets placed in the queue with high priority with a higher priority than packets placed in the queue with low priority. receiving from a packet data network, via ingress interfaces (2 6) of a switching element, packets (32, 34, 3 6) belonging to multiple flows, and forwarding the packets to respective egress interfaces of the switching element for transmission to the network; for each egress interface of the switching element, queuing the packets, belonging to a plurality of the flows, that have been forwarded for transmission through the egress interface; and for each of one or more of the egress interfaces, in each of a succession of arbitration cycles: assessing a respective number of the packets in each of the plurality of the flows that are queued for transmission through the egress interface; assigning the flows for which the respective number is zero to a first group, while assigning the flows for which the respective number is non-zero to a second group; and placing the packets that are forwarded to the egress interface after assigning the flows and that belong to the flows in the first group into a queue having high priority, placing the packets that are forwarded to the egress interface after assigning the flows and that belong to the flows in the second group into a queue having low priority, and transmitting to the network packets placed in the queue with high priority with a higher priority than packets placed in the queue with low priority. assessing a respective number of the packets in each of the plurality of the flows that are queued for transmission through the egress interface; assigning the flows for which the respective number is zero to a first group, while assigning the flows for which the respective number is non-zero to a second group; and placing the packets that are forwarded to the egress interface after assigning the flows and that belong to the flows in the first group into a queue having high priority, placing the packets that are forwarded to the egress interface after assigning the flows and that belong to the flows in the second group into a queue having low priority, and transmitting to the network packets placed in the queue with high priority with a higher priority than packets placed in the queue with low priority.