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.

61 lines
1.0 KiB

  1. /*
  2. * Main.cpp
  3. *
  4. * Created on: 07-01-2017
  5. * Author: Piotr Dergun
  6. */
  7. #include "common.h"
  8. #include "Node.h"
  9. #include "NATRouter.h"
  10. #include "Simulation.h"
  11. void usage(string programName)
  12. {
  13. cerr << endl;
  14. cerr << "Usage:" << endl;
  15. cerr << programName << " p2p\t\t\tP2P simulation" << endl;
  16. cerr << programName << " nat <nodes>\t\tNAT overflow simulation" << endl;
  17. cerr << endl;
  18. exit(1);
  19. }
  20. int main(int argc, char *argv[])
  21. {
  22. char *endptr=NULL;
  23. int nodesCount;
  24. if (argc < 2)
  25. usage(argv[0]);
  26. if (!strcmp(argv[1], "p2p"))
  27. {
  28. Simulation sim;
  29. sim.createThread("timer", SIM_TIMER, &sim);
  30. sim.p2pSimulation();
  31. }
  32. else if (!strcmp(argv[1], "nat"))
  33. {
  34. if (argc < 3)
  35. usage(argv[0]);
  36. nodesCount = strtol(argv[2], &endptr, 10);
  37. if (nodesCount < 1 || nodesCount > 255)
  38. {
  39. cerr << "Invalid number of nodes format [1,255]" << endl;
  40. usage(argv[0]);
  41. }
  42. Simulation sim;
  43. //sim.createThread("timer", SIM_TIMER, &sim);
  44. sim.natOverflowSimulation(nodesCount);
  45. }
  46. else if (!strcmp(argv[1], "-v"))
  47. {
  48. }
  49. else
  50. usage(argv[0]);
  51. return 0;
  52. }