To add to what Atiff has written, when NetSim is used in in combination with MATLAB, the flight dynamics is handled by MATLAB while network communication (including adhoc routing) is managed by NetSim.
See this link https://support.tetcos.com/support/solutions/articles/14000087704-can-i-simulate-uav-networks-in-netsim-
Also this earlier discussion may be useful https://www.researchgate.net/post/Is_it_possible_to_implement_Flying_Ad-Hoc_Networks_FANET_UAV-assisted_routing_protocol_for_example_with_VANET_by_MATLAB
You can see this paper of Univ of Cranfield, UK on UAV simulation using NetSim https://dspace.lib.cranfield.ac.uk/bitstream/handle/1826/17737/Integration_of_Unmanned_Aerial_Vehicles-2022.pdf?sequence=1&isAllowed=y