Symulacja NAT na przedmiot Symulacje Komputerowe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

70 lines
1.3 KiB

/**
* @file Main.cpp
*
* Created on: 07-01-2017
* @author Piotr Dergun
*/
#include "common.h"
#include "Node.h"
#include "NATRouter.h"
#include "Simulation.h"
/**
* zwraca na stderr informację o parametrach uruchomienia programu
* @param programName nazwa pliku wykonywalnego
*/
void usage(string programName)
{
cerr << endl;
cerr << "Usage:" << endl;
cerr << programName << " p2p\t\t\tP2P simulation" << endl;
cerr << programName << " nat <nodes>\t\tNAT overflow simulation" << endl;
cerr << endl;
exit(1);
}
/**
* główna funkcja programu
* @param argc ilość argumentów
* @param argv tablica z argumentami
*/
int main(int argc, char *argv[])
{
char *endptr=NULL;
int nodesCount;
if (argc < 2)
usage(argv[0]);
if (!strcmp(argv[1], "p2p"))
{
Simulation sim;
sim.createThread("timer", SIM_TIMER, &sim);
sim.p2pSimulation();
}
else if (!strcmp(argv[1], "nat"))
{
if (argc < 3)
usage(argv[0]);
nodesCount = strtol(argv[2], &endptr, 10);
if (nodesCount < 1 || nodesCount > 253)
{
cerr << "Invalid number of nodes format [1,253]" << endl;
usage(argv[0]);
}
Simulation sim;
sim.createThread("timer", SIM_TIMER, &sim);
sim.natOverflowSimulation(nodesCount);
}
else if (!strcmp(argv[1], "-v"))
{
}
else
usage(argv[0]);
return 0;
}