Bonjour,
J'aimerai simuler un réseau d'entreprise avec ns-3.
L'entreprise est localisé dans 2 villes différentes.
Sur chacun de ces lieux, elle a des PC connectés en wifi, des PC connecté en LAN et un serveur.
Voici le schéma :
http://www.hostingpics.net/viewer.php?id=131548Network.png
Pour chaque machine, environ 30% des paquets envoyés vont vers internet, 40% vers le serveur interne et 30% vers le serveur de l'autre lieu.
Je veux montrer qu'il y a de la congestion au niveau des liens entre mes 2 entreprises et que c'est ce lien qu'il faudrait privilégier si le nombre d'employer augmente.
Je veux aussi montrer les vulnérabilité de mon réseau face à une attaque DDoS.
J'ai déjà construit le réseau mais maintenant je voudrais simuler les flux de paquets et je ne sais pas trop comment faire.
int main (int argc, char *argv[]) { //====================== DECLARATION DES LOGS ============================== LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); //====================== DECLARATION DES VARIABLES ========================= // Paramètres office 1 uint32_t nCsma1 = 10; uint32_t nWifi1 = 10; //uint32_t nPackets1 = 100; //uint32_t nInternetPackets1 = (nPackets1 * 3)/10; //uint32_t nExternalServerPackets1 = nInternetPackets1; //uint32_t nLocalServerPackets1 = nPackets1 - nInternetPackets1 - nExternalServerPackets1; std::string dataRate10 = "5Mbps"; std::string dataRate11 = "5Mbps"; std::string dataRate12 = "5Mbps"; std::string dataRate13 = "5Mbps"; std::string dataRateCsma1 = "100Mbps"; std::string delay10 = "2ms"; std::string delay11 = "2ms"; std::string delay12 = "2ms"; std::string delay13 = "2ms"; uint32_t delayCsma1 = 6560; // Paramètres office 2 uint32_t nCsma2=10; uint32_t nWifi2=10; std::string dataRate20 = "5Mbps"; std::string dataRate21 = "5Mbps"; std::string dataRate22 = "5Mbps"; std::string dataRate23 = "5Mbps"; std::string dataRateCsma2 = "100Mbps"; std::string delay20 = "2ms"; std::string delay21 = "2ms"; std::string delay22 = "2ms"; std::string delay23 = "2ms"; uint32_t delayCsma2 = 6560; //====================== OFFICE n°1 ====================================== //Construction des PointToPointHelper PointToPointHelper pointToPoint10; pointToPoint10.SetDeviceAttribute ("DataRate", StringValue (dataRate10)); pointToPoint10.SetChannelAttribute ("Delay", StringValue (delay10)); PointToPointHelper pointToPoint11; pointToPoint11.SetDeviceAttribute ("DataRate", StringValue (dataRate11)); pointToPoint11.SetChannelAttribute ("Delay", StringValue (delay11)); PointToPointHelper pointToPoint12; pointToPoint12.SetDeviceAttribute ("DataRate", StringValue (dataRate12)); pointToPoint12.SetChannelAttribute ("Delay", StringValue (delay12)); PointToPointHelper pointToPoint13; pointToPoint13.SetDeviceAttribute ("DataRate", StringValue (dataRate13)); pointToPoint13.SetChannelAttribute ("Delay", StringValue (delay13)); // Construction des noeuds10 NodeContainer p2pNodes10; p2pNodes10.Create (2); NetDeviceContainer p2pDevices10; p2pDevices10 = pointToPoint10.Install (p2pNodes10); // Construction des noeuds11 NodeContainer p2pNodes11; p2pNodes11.Add (p2pNodes10.Get(1)); p2pNodes11.Create (1); NetDeviceContainer p2pDevices11; p2pDevices11 = pointToPoint11.Install (p2pNodes11); // Construction des noeuds12 NodeContainer p2pNodes12; p2pNodes12.Add (p2pNodes11.Get(0)); p2pNodes12.Create (1); NetDeviceContainer p2pDevices12; p2pDevices12 = pointToPoint12.Install (p2pNodes12); // Construction des noeuds13 NodeContainer p2pNodes13; p2pNodes13.Add (p2pNodes11.Get(0)); p2pNodes13.Create(1); NetDeviceContainer p2pDevices13; p2pDevices13 = pointToPoint13.Install (p2pNodes13); // Construction des noeuds Csma1 NodeContainer csmaNodes1; csmaNodes1.Add (p2pNodes11.Get (1)); csmaNodes1.Create (nCsma1); CsmaHelper csma1; csma1.SetChannelAttribute ("DataRate", StringValue (dataRateCsma1)); csma1.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (delayCsma1))); NetDeviceContainer csmaDevices1; csmaDevices1 = csma1.Install (csmaNodes1); // Construction des noeuds Wifi1 NodeContainer wifiStaNodes1; wifiStaNodes1.Create(nWifi1); NodeContainer wifiApNode1 = p2pNodes12.Get(1); YansWifiChannelHelper channel1 = YansWifiChannelHelper::Default(); YansWifiPhyHelper phy1 = YansWifiPhyHelper::Default (); phy1.SetChannel (channel1.Create()); WifiHelper wifi1 = WifiHelper::Default (); wifi1.SetRemoteStationManager ("ns3::AarfWifiManager"); NqosWifiMacHelper mac1 = NqosWifiMacHelper::Default (); Ssid ssid1 = Ssid ("ns-3-ssid"); mac1.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid1), "ActiveProbing", BooleanValue (false)); NetDeviceContainer staDevices1; staDevices1 = wifi1.Install (phy1, mac1, wifiStaNodes1); mac1.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid1)); NetDeviceContainer apDevices1; apDevices1 = wifi1.Install (phy1, mac1, wifiApNode1); MobilityHelper mobility1; mobility1.SetPositionAllocator ("ns3::GridPositionAllocator", "MinX", DoubleValue (0.0), "MinY", DoubleValue (0.0), "DeltaX", DoubleValue(5.0), "DeltaY", DoubleValue (10.0), "GridWidth", UintegerValue (3), "LayoutType", StringValue ("RowFirst")); mobility1.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50))); mobility1.Install (wifiStaNodes1); mobility1.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility1.Install (wifiApNode1); //========================= OFFICE n°2 ========================================== // Constuction des PointToPointHelper PointToPointHelper pointToPoint20; pointToPoint20.SetDeviceAttribute ("DataRate", StringValue (dataRate20)); pointToPoint20.SetChannelAttribute ("Delay", StringValue (delay20)); PointToPointHelper pointToPoint21; pointToPoint21.SetDeviceAttribute ("DataRate", StringValue (dataRate21)); pointToPoint21.SetChannelAttribute ("Delay", StringValue (delay21)); PointToPointHelper pointToPoint22; pointToPoint22.SetDeviceAttribute ("DataRate", StringValue (dataRate22)); pointToPoint22.SetChannelAttribute ("Delay", StringValue (delay22)); PointToPointHelper pointToPoint23; pointToPoint23.SetDeviceAttribute ("DataRate", StringValue (dataRate23)); pointToPoint23.SetChannelAttribute ("Delay", StringValue (delay23)); // Construction des noeuds20 NodeContainer p2pNodes20; p2pNodes20.Add (p2pNodes10.Get(0)); p2pNodes20.Create (1); NetDeviceContainer p2pDevices20; p2pDevices20 = pointToPoint20.Install (p2pNodes20); // Construction des noeuds21 NodeContainer p2pNodes21; p2pNodes21.Add (p2pNodes20.Get(1)); p2pNodes21.Create (1); NetDeviceContainer p2pDevices21; p2pDevices21 = pointToPoint21.Install (p2pNodes21); // Construction des noeuds22 NodeContainer p2pNodes22; p2pNodes22.Add (p2pNodes20.Get(1)); p2pNodes22.Create (1); NetDeviceContainer p2pDevices22; p2pDevices22 = pointToPoint22.Install (p2pNodes22); // Construction des noeuds23 NodeContainer p2pNodes23; p2pNodes23.Add (p2pNodes20.Get(1)); p2pNodes23.Create (1); NetDeviceContainer p2pDevices23; p2pDevices23 = pointToPoint23.Install (p2pNodes23); // Construction des noeuds CSMA2 NodeContainer csmaNodes2; csmaNodes2.Add (p2pNodes21.Get (1)); csmaNodes2.Create (nCsma2); CsmaHelper csma2; csma2.SetChannelAttribute ("DataRate", StringValue (dataRateCsma2)); csma2.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (delayCsma2))); NetDeviceContainer csmaDevices2; csmaDevices2 = csma2.Install (csmaNodes2); // Construction des noeuds Wifi2 NodeContainer wifiStaNodes2; wifiStaNodes2.Create(nWifi2); NodeContainer wifiApNode2 = p2pNodes22.Get(1); YansWifiChannelHelper channel2 = YansWifiChannelHelper::Default(); YansWifiPhyHelper phy2 = YansWifiPhyHelper::Default (); phy2.SetChannel (channel2.Create()); WifiHelper wifi2 = WifiHelper::Default (); wifi2.SetRemoteStationManager ("ns3::AarfWifiManager"); NqosWifiMacHelper mac2 = NqosWifiMacHelper::Default (); Ssid ssid2 = Ssid ("ns-3-ssid"); mac2.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid2), "ActiveProbing", BooleanValue (false)); NetDeviceContainer staDevices2; staDevices2 = wifi2.Install (phy2, mac2, wifiStaNodes2); mac2.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid2)); NetDeviceContainer apDevices2; apDevices2 = wifi2.Install (phy2, mac2, wifiApNode2); MobilityHelper mobility2; mobility2.SetPositionAllocator ("ns3::GridPositionAllocator", "MinX", DoubleValue (0.0), "MinY", DoubleValue (0.0), "DeltaX", DoubleValue(5.0), "DeltaY", DoubleValue (10.0), "GridWidth", UintegerValue (3), "LayoutType", StringValue ("RowFirst")); mobility2.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50))); mobility2.Install (wifiStaNodes2); mobility2.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility2.Install (wifiApNode2); //======================== CONSTRUCTION D'INTERNET ============================== // Construction du PointToPointHelper PointToPointHelper pointToPoint00; pointToPoint00.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); pointToPoint00.SetChannelAttribute ("Delay", StringValue ("2ms")); // Construction des noeuds00 NodeContainer p2pNodes00; p2pNodes00.Add (p2pNodes10.Get(0)); p2pNodes00.Create (1); NetDeviceContainer p2pDevices00; p2pDevices00 = pointToPoint00.Install (p2pNodes00); //======================== PROTOCOLES ET ADRESSAGE ============================== InternetStackHelper stack; // Installation des piles du 1er site stack.Install (csmaNodes1); stack.Install (p2pNodes13); stack.Install (wifiApNode1); stack.Install (wifiStaNodes1); // Installation des piles du 2ème site stack.Install (csmaNodes2); stack.Install (p2pNodes23); stack.Install (wifiApNode2); stack.Install (wifiStaNodes2); // Installation des piles d'internet stack.Install (p2pNodes00); Ipv4AddressHelper address; // Allocation des adresses IP du 1er site address.SetBase ("10.1.1.0", "255.255.255.0"); Ipv4InterfaceContainer p2pInterfaces10; p2pInterfaces10 = address.Assign (p2pDevices10); address.SetBase ("10.1.2.0", "255.255.255.0"); Ipv4InterfaceContainer p2pInterfaces11; p2pInterfaces11 = address.Assign (p2pDevices11); address.SetBase ("10.1.3.0", "255.255.255.0"); Ipv4InterfaceContainer p2pInterfaces12; p2pInterfaces12 = address.Assign (p2pDevices12); address.SetBase ("10.1.4.0", "255.255.255.0"); Ipv4InterfaceContainer p2pInterfaces13; p2pInterfaces13 = address.Assign (p2pDevices13); address.SetBase ("10.1.5.0", "255.255.255.0"); Ipv4InterfaceContainer csmaInterfaces1; csmaInterfaces1 = address.Assign (csmaDevices1); address.SetBase ("10.1.6.0", "255.255.255.0"); address.Assign (staDevices1); address.Assign (apDevices1); Ipv4AddressHelper address2; // Allocation des adresses IP du 2ème site address2.SetBase ("10.2.1.0", "255.255.255.0"); Ipv4InterfaceContainer p2pInterfaces20; p2pInterfaces20 = address2.Assign (p2pDevices20); address2.SetBase ("10.2.2.0", "255.255.255.0"); Ipv4InterfaceContainer p2pInterfaces21; p2pInterfaces21 = address2.Assign (p2pDevices21); address2.SetBase ("10.2.3.0", "255.255.255.0"); Ipv4InterfaceContainer p2pInterfaces22; p2pInterfaces22 = address2.Assign (p2pDevices22); address2.SetBase ("10.2.4.0", "255.255.255.0"); Ipv4InterfaceContainer p2pInterfaces23; p2pInterfaces23 = address2.Assign (p2pDevices23); address2.SetBase ("10.2.5.0", "255.255.255.0"); Ipv4InterfaceContainer csmaInterfaces2; csmaInterfaces2 = address2.Assign (csmaDevices2); address2.SetBase ("10.2.6.0", "255.255.255.0"); address2.Assign (staDevices2); address2.Assign (apDevices2); // Allocation de l'adresse IP d'internet address2.SetBase ("10.3.1.0", "255.255.255.0"); Ipv4InterfaceContainer p2pInterfaces00; p2pInterfaces00 = address2.Assign (p2pDevices00);
Afficher la suite