Extremely dense wireless network topologies gradually become a reality, especially through wireless sensors networks and more recently nanonetworks. Electromagnetic nanonetworks are expected to allow a very large amount of extremely small and capability-limited devices to communicate with each others. In nanonetworks, even in a communication range limited to tens of centimeters, thousands of neighbors can be found. Information diffusion and routing protocols would greatly benefit from having an accurate estimation of the density of nodes. However, in this context, most traditional wireless communication protocols are not suited. We propose Density Estimator for Dense Networks (DEDeN), a distributed algorithm able to provide the required density estimation. It allows confidence tuning and can cope with an extreme range of local densities. A formal analysis of DEDeN is provided and corroborated by extensive simulations. DEDeN interest is then demonstrated through application to two information diffusion protocols tailored for very dense networks, and also to a routing protocol specific to nanonetworks.