NSG controls the flow of traffic by specifying which traffic is allowed to enter or exit the network.