könnte mir jemand zeigen, wie Sie diesen Code zu schreiben, in in einer anderen Weise in OMNeT ++C++ Coding in OMNeT ++
while (Outgate == Port) {
outGate = intuniform(0, n-1);
}
und die anderen:
Leere Txc15 :: forwardMessage (TicTocMsg15 * msg, int port)
{
// inkrementale Anzahl der T-Stücke.
msg->setHopCount(msg->getHopCount()+1);
int outGate, n = gateSize("gate");
if(port != -1){
//we enter here only if the message is forwarded
outGate=port;
//checking for more than one gate!
if (n>1)
{
/**
* It will exit from the while cycle only if the intuniform function
* will choose a port different from the incoming one.
*/
while(outGate==port){
outGate = intuniform(0, n-1);
}
}
EV << "Forwarding message " << msg << " on gate[" << outGate << "]\n";
//forward the message provided following the conditions.
send(msg, "gate$o", outGate);
}else{
//port is equal to -1 if and only if the message in newly generated
outGate = intuniform(0, n-1); // Randomly choose a gate.
EV << "Forwarding message " << msg << " on gate[" << outGate << "]\n";
send(msg, "gate$o", outGate);
}
}
Was meinst du mit "anders"? Kürzer? Weniger fehleranfällig? Weniger wiederholend? Etwas anderes? – molbdnilo