Wireless body area networks (WBANs) are characterized by large fluctuations in channel losses due to body shadowing. These fluctuations follow the patterns of the user's body movements. For example, in the case of walking and running, channel losses follow cyclical patterns. This paper presents an algorithm for transmission power control (TPC) and dynamic routing in WBANs when the user performs periodic body movements. The objective of the algorithm is to decrease the average power consumption to deliver packets to a common sink provided that a desired packet delivery rate (PDR) is guaranteed. This problem is important in WBANs given that replacing batteries is detrimental to several applications of WBANs, especially when sensors of the WBAN are implanted on the user's body. To the best of our knowledge, the proposed algorithm is the first to consider the joint problem of TPC and dynamic routing while not relying on non-local data (i.e., measurements of received power). This characteristic is important because traditional algorithms rely on data not local to transmitters, so these data have to be transmitted, consuming power unnecessarily. Traditional algorithms are also limited to the star topology only, so routing is not considered, which decreases network connectivity and transmission-power savings. The proposed algorithm is implemented on a WBAN of Shimmer wireless sensors. Experimental results show a reduction in power consumption of 23.4% to 50.4% when compared against transmissions at maximum power and a PDR within 5.6% of the desired value. The power consumption of the overhead of the proposed algorithm can be as small as 11% of that one of traditional algorithms. The algorithm's complexity is shown to be O(N 3), where N is the number of sensors. Finally, the algorithm is compared with traditional algorithms which reduce power consumption by 39.0% on average at most.