|
|
@ -108,7 +108,15 @@ bool Node::send(Packet packet) |
|
|
|
node = this->findConnection(this->getGatewayIp()); |
|
|
|
|
|
|
|
if (!node) |
|
|
|
return false; //nie ma zadnej trasy do wezla
|
|
|
|
return false; // nie ma zadnej trasy do wezla
|
|
|
|
|
|
|
|
if (packet.getDstPort() == 0) |
|
|
|
return false; // wypada zdefiniowac nadawce oraz docelowy port...
|
|
|
|
|
|
|
|
packet.setSrcIp(this->getIp()); |
|
|
|
// ustaw port zrodlowy na port losowy z zakresu [32768,61000] - zob. empheral port (port emferyczny)
|
|
|
|
srand(time(NULL)); |
|
|
|
packet.setSrcPort(rand() % 32768 + 28233); |
|
|
|
|
|
|
|
node->putPacket(packet); |
|
|
|
|
|
|
@ -166,5 +174,15 @@ string Node::getGatewayIp() |
|
|
|
|
|
|
|
void Node::onRecv() |
|
|
|
{ |
|
|
|
// TESTOWO
|
|
|
|
Packet p = this->recv(); |
|
|
|
if (p.getSrcPort() != 0) |
|
|
|
{ |
|
|
|
cout << endl << "<<<<<< " << this->getHostname() << " >>>>>>" << endl; |
|
|
|
cout << "Odebrano wiadomosc!" << endl; |
|
|
|
cout << "Src: " << p.getSrcIp() << ":" << p.getSrcPort() << endl; |
|
|
|
cout << "Dst: " << p.getDstIp() << ":" << p.getDstPort() << endl; |
|
|
|
cout << "---" << endl << p.getMsg() << endl << endl; |
|
|
|
} |
|
|
|
|
|
|
|
} |