|
|
@ -174,15 +174,15 @@ void Simulation::timer() |
|
|
|
void Simulation::p2pSimulation() |
|
|
|
{ |
|
|
|
this->print("Creating P2P peers"); |
|
|
|
Peer peer1("Peer 1", "192.168.1.2", "255.255.255.0", "192.168.1.1"); |
|
|
|
peer1.setSender(true); |
|
|
|
peer1.setSim(this); |
|
|
|
peer1.setLogParams(0, GREEN, "\t\t"); |
|
|
|
Peer peer2("Peer 2", "10.0.0.2", "255.255.255.0", "10.0.0.1"); |
|
|
|
peer2.setSim(this); |
|
|
|
peer2.setLogParams(4, CYAN, "\t\t"); |
|
|
|
peer1.print("IP 192.168.1.2/24, Gateway: 192.168.1.1"); |
|
|
|
peer2.print("IP 10.0.0.2/24, Gateway: 10.0.0.1"); |
|
|
|
Peer seed("Seed", "192.168.1.2", "255.255.255.0", "192.168.1.1"); |
|
|
|
seed.setSender(true); |
|
|
|
seed.setSim(this); |
|
|
|
seed.setLogParams(0, GREEN, "\t\t"); |
|
|
|
Peer peer("Peer", "10.0.0.2", "255.255.255.0", "10.0.0.1"); |
|
|
|
peer.setSim(this); |
|
|
|
peer.setLogParams(4, CYAN, "\t\t"); |
|
|
|
seed.print("IP 192.168.1.2/24, Gateway: 192.168.1.1"); |
|
|
|
peer.print("IP 10.0.0.2/24, Gateway: 10.0.0.1"); |
|
|
|
sleep(1); |
|
|
|
|
|
|
|
this->print("Creating NAT devices"); |
|
|
@ -210,35 +210,35 @@ void Simulation::p2pSimulation() |
|
|
|
server.print("IP 80.80.90.91/32"); |
|
|
|
sleep(1); |
|
|
|
|
|
|
|
this->print("Plugging Peer1 <---> Router 1"); |
|
|
|
r1.connectNode(&peer1); |
|
|
|
sleep(1); |
|
|
|
this->print("Plugging Peer2 <---> Router 2"); |
|
|
|
r2.connectNode(&peer2); |
|
|
|
sleep(1); |
|
|
|
this->print("Plugging Seed <---> Router 1"); |
|
|
|
r1.connectNode(&seed); |
|
|
|
usleep(600000); |
|
|
|
this->print("Plugging Peer <---> Router 2"); |
|
|
|
r2.connectNode(&peer); |
|
|
|
usleep(600000); |
|
|
|
this->print("Plugging Router 1 <---> Router 2"); |
|
|
|
r1.connectNode(&r2, true); |
|
|
|
sleep(1); |
|
|
|
usleep(600000); |
|
|
|
this->print("Plugging Server <---> Router 1"); |
|
|
|
server.connectNode(&r1); |
|
|
|
sleep(1); |
|
|
|
usleep(600000); |
|
|
|
this->print("Plugging Server <---> Router 2"); |
|
|
|
server.connectNode(&r2); |
|
|
|
sleep(1); |
|
|
|
usleep(600000); |
|
|
|
|
|
|
|
this->print("Starting simulation..."); |
|
|
|
sleep(1); |
|
|
|
|
|
|
|
this->print("Starting simulation..."); |
|
|
|
this->createThread("r1", NODE_RECV, &r1); |
|
|
|
this->createThread("r2", NODE_RECV, &r2); |
|
|
|
this->createThread("s1", NODE_RECV, &server); |
|
|
|
|
|
|
|
this->print("Connecting peers to P2P server"); |
|
|
|
peer1.connectToServer("80.80.90.91", 6565); |
|
|
|
peer2.connectToServer("80.80.90.91", 6565); |
|
|
|
sleep(1); |
|
|
|
this->createThread("p1", NODE_RECV, &peer1); |
|
|
|
this->createThread("p2", NODE_RECV, &peer2); |
|
|
|
seed.connectToServer("80.80.90.91", 6565); |
|
|
|
peer.connectToServer("80.80.90.91", 6565); |
|
|
|
sleep(3); |
|
|
|
this->createThread("p1", NODE_RECV, &seed); |
|
|
|
this->createThread("p2", NODE_RECV, &peer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|