The problem is about: scheduleAt(time(0)+ exponential(0.5),copy);

28 views
Skip to first unread message

Nawres Kachouti

unread,
Dec 21, 2016, 7:36:17 AM12/21/16
to OMNeT++ Users
hello,
i want to send a copy of msg every 5 seconde, 
help please:
this is the code in the handleMessage :
how can i solve my problem? thanks :


if (dynamic_cast<cMessage *>(msg) )
                {   char msgname[20];
                  sprintf(msgname, "I am here%d", getIndex());
                  cMessage *msg = new cMessage(msgname);
           
             
int n = gateSize("gate");

    for (int i = 0; i < n; i++)
    {
       cMessage *copy = msg->dup();
       send(copy, "gate$o", i);
      scheduleAt(time(0)+ exponential(0.5),copy);
    }
    delete msg;

}

Nawres Kachouti

unread,
Dec 21, 2016, 12:18:38 PM12/21/16
to OMNeT++ Users

Amr Abughazala

unread,
Dec 22, 2016, 7:06:28 AM12/22/16
to OMNeT++ Users
I don't get what is time(0) but if you meant current time then 

replace 
scheduleAt(time(0)+ exponential(0.5),copy);
with 
scheduleAt(simTime()+ exponential(0.5),copy);

Nawres Kachouti

unread,
Jan 3, 2017, 8:16:00 AM1/3/17
to OMNeT++ Users
Hello Amr, thank you for answer;; I did as you told me, but I have this error



Le mercredi 21 décembre 2016 13:36:17 UTC+1, Nawres Kachouti a écrit :

Alfonso Ariza Quintana

unread,
Jan 4, 2017, 5:54:59 AM1/4/17
to omn...@googlegroups.com

You can not schedule a packet that you can send to a gate

    for (int i = 0; i < n; i++)
    {
       cMessage *copy = msg->dup();
       send(copy, "gate$o", i); // send packet
      scheduleAt(time(0)+ exponential(0.5),copy); // Error, it is impossible to schedule a packet that has been sent
    }



If you want to sent this packet delayed, you can use sendDelayed


    for (int i = 0; i < n; i++)

    {
       sendDelayed(msg->dup(), exponential(0.5),"gate$o", i);     
    }




De: omn...@googlegroups.com <omn...@googlegroups.com> en nombre de Nawres Kachouti <nawr...@gmail.com>
Enviado: martes, 3 de enero de 2017 14:16:00
Para: OMNeT++ Users
Asunto: [Omnetpp-l] Re: The problem is about: scheduleAt(time(0)+ exponential(0.5),copy);
 
--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/omnetpp.
For more options, visit https://groups.google.com/d/optout.

Nawres Kachouti

unread,
Jan 6, 2017, 3:48:04 PM1/6/17
to OMNeT++ Users
ok, Thank you very much Alfonso,


Le mercredi 21 décembre 2016 13:36:17 UTC+1, Nawres Kachouti a écrit :
Reply all
Reply to author
Forward
0 new messages