Joint Ranging and Clock Synchronization for Dense Heterogeneous IoT Networks