A scalable distributed stochastic routing algorithm (GODDeS) is developed to effectively exploit high quality paths in lossy ad-hoc wireless environments, typically with a large number of nodes. The routing problem is modeled as an optimal control problem for a decentralized Markov decision process via a probabilistic local broadcast model, with links characterized by locally known or estimated drop probabilities that either remain constant on average or change slowly. Equivalence of this optimization problem to that of performance maximization of probabilistic automata allows us to effectively apply the theory of quantitative measures of probabilistic regular languages, and design a distributed, highly efficient, scalable, and stationary routing policy that very nearly minimizes source-to-sink drop probabilities across the network. Theoretical results provide rigorous guarantees on global performance, showing that the algorithm achieves near-global optimality in polynomial time, and worst case asymptotic convergence time is shown to scale linearly with network size. Furthermore, the theoretical results establish that it is possible to trade off deviation from global optimality against convergence time. It is also argued that GODDeS is significantly congestion-aware and exploits multipath routes optimally. Theoretical development is supported by detailed network simulations. 2513 quality of service (QOS) but scale poorly. The latter have less control traffic, but maintaining QOS is harder. Other approaches use geographic or power information, and in the context of sensor networks, query-based strategies [19] have been proposed.Ad-hoc routing protocols for wireless networks primarily focus on node mobility, rapidly changing topologies, overhead, and scalability, and often ignore the problem of finding high-quality paths over lossy wireless links. Links are assumed to either work well or not work at all, which is unreasonable in the wireless case, where intermediate loss ratios are common. A partial fix is to use new, quality-aware metrics such as the expected transmission count (ETX) [12], where the authors note that "minimizing hop-count maximizes the distance traveled by each hop, which is likely to minimize signal strength and maximize the loss ratio." Even if the best route is one with minimal hop-count, the possibility of multiple routes with the same hop-count with widely varying qualities (particularly in dense networks) implies that an arbitrary choice is unlikely to select the best. The routing protocol is presented with a complex trade-off decision: Long distance links take fewer hops but operate more slowly; short links can operate at high rates, but more hops are required. In this paper, this large scale decision problem is solved via formulating a probabilistic routing policy that very nearly minimizes the end-to-end packet drop probabilities. Communication links are assumed to be imperfect, characterized by locally known expected drop probabilities, which are either constant or change slowly. Local r...