With the increasing amount of information and complexity of communication networks, the issue of routing remains relevant. The routing problem is a classic problem of building a logical structure of a communication network. To solve this problem, many methods are used, such as: genetic algorithms, ant algorithm, swarm intelligence, artificial bee colony algorithm, firefly algorithm, bacterial food search optimization algorithm, etc. Despite the fact that the effectiveness of using the ant algorithm is widely known and described, however, there is no single approach to finding the optimal use case for the algorithm. There is a need to determine the optimal size of the colony when solving the routing problem. The article describes the results of the simulation process of modeling the behavior of ant colonies of different sizes to find the optimal route through the AnyLogic environment. It is determined that by means of simulation it is possible to reproduce the use of the ant algorithm to solve the routing problem in communication networks. To find the optimal ratio of the colony size to the complexity of the task, you can use the grid search methodology. The results clearly demonstrate that with increasing complexity of the task (the number of communication nodes), the same number of ants cope worse with the task. The problem associated with the need to accurately determine the optimal size of a colony is of great practical importance, because an increase in the size of a colony has generally decreasing utility. It was found that for many, an increase in the number of ants from 100 to 500 had a relatively greater effect than an increase in the size of the colony from 1000 to 10000. It is proved that by means of simulation it is possible to reproduce the use of the ant algorithm to solve the routing problem in communication networks.