Browse Source

poprawka liczenia dstPortu (odwrotnie zakres)

master
Piotr Dergun 7 years ago
parent
commit
54b111bf0d
3 changed files with 3 additions and 4 deletions
  1. +1
    -2
      NATRouter.cpp
  2. +1
    -1
      Node.cpp
  3. +1
    -1
      Simulation.cpp

+ 1
- 2
NATRouter.cpp View File

@ -158,7 +158,6 @@ void NATRouter::sNAT(Packet *packet)
stringstream ss;
// mozliwe, ze juz port zostal zaalokowany, to trzeba wykorzystac
// TO
port = this->getAllocatedPort(packet->getSrcIp(), packet->getSrcPort());
if (port == -1)
while ((port = this->getFreePort()) == -1)
@ -283,7 +282,7 @@ void NATRouter::freePorts()
if (ports < peak)
peak = ports;
ss << "Free/Reserved:\t" << ports << " (" << peak << ")/" << (NAT_TABLE_LEN-ports-1); // poprawka na nieuzywany port 0
ss << "Free/Reserved:\t" << ports << " (" << peak << ")/" << (NAT_TABLE_LEN-ports-1) << " (" << (NAT_TABLE_LEN-peak-1) << ")"; // poprawka na nieuzywany port 0
portsLog.print(ss.str());
portsLog.printProgressBar(4, 4, "Utilization", (float)(NAT_TABLE_LEN-ports-1)/(NAT_TABLE_LEN-1));

+ 1
- 1
Node.cpp View File

@ -173,7 +173,7 @@ int Node::send(Packet packet, bool isRouter)
if (packet.getSrcPort() == 0)
{
// ustaw port zrodlowy na port losowy z zakresu [32768,61000] - zob. empheral port (port emferyczny)
packet.setSrcPort(rand() % 32768 + 28233);
packet.setSrcPort(rand() % 28233 + 32768);
}
}
node->putPacket(packet);

+ 1
- 1
Simulation.cpp View File

@ -325,7 +325,7 @@ void Simulation::natOverflowSimulation(int nNodes)
currentSrcPort[i] = 1;
//p.setSrcPort(currentSrcPort[i]++);
//p.setSrcPort(0);
p.setSrcPort(0);
client[i].send(p);
this->delay(150);

Loading…
Cancel
Save