In this paper, we propose a mobile agent-based routing algorithm in which the traffic cost is considered. We define a traffic cost function for each link based on known traffic information and find the probability distribution that mobile agents may select a neighboring node and move to. We theoretically analyze the probability distribution and provide the optimal probability distribution that makes inference on the known traffic information and approximates to a unbiased distribution.