Localization of nodes in wired and wireless networks