Optimizing bandwidth allocation for heterogeneous traffic in IoT