Application class SendPacket ScheTX

68 views
Skip to first unread message

Osama Gazali

unread,
Nov 12, 2014, 3:53:37 AM11/12/14
to ns-3-...@googlegroups.com
Dear Friend,

concerning sending application packet. I would like to ask if this way of sending first cam via SendPacket and doing if condition in the SendPacket for
scheduling next Cam is correct from implementation perspective. It gives resealable result.

The question is this implementation the right way and can I use if (m_running) in sendPacket as it is by default in SchedTX

void
CAMmanage::SendPacket (void)
{
    Ptr<Packet> packet = Create<Packet> (m_packetSize);
  AddInciPacketTags(packet);

  m_sendCount ++;

  m_socket->DoSendTo(packet, m_c2cAddress, m_port,1,1,m_sendCount);
  if (m_running)
      {
                  if conditions depends on mobility met Then
           {

                  ScheduleTx ();
 
            }
     }

}


void
CAMmanage::ScheduleTx (void)
{

    if (m_running)
    {
        m_sendEvent = Simulator::Schedule (Simulator::Now(), &CAMmanage::SendPacket, this);
    }
}


thanks

Konstantinos

unread,
Nov 12, 2014, 4:47:01 AM11/12/14
to ns-3-...@googlegroups.com
Hi Osama,

I would say that this approach looks wrong, and in certain conditions you would find yourself disabling CAM.

Let's say you send your CAM and your application is_running but the conditions on mobility are not met, so no new CAM is scheduled, then (at least from this code snippet) I do not see any way of resuming sending CAM. 

Therefore, I would suggest to play with the scheduling time depending on the mobility rather than this approach.

The m_running control you have in the ScheduleTx is redundant in my opinion, since in order to call this function you have already checked if it is running in the Send.

Osama Gazali

unread,
Nov 12, 2014, 5:32:11 AM11/12/14
to ns-3-...@googlegroups.com
Thanks a lot Kostantinos,

when you said "Therefore, I would suggest to play with the scheduling time depending on the mobility rather than this approach", I understand that It is better to work in the scheduleTX function rather than do the mobility conditions in SendPacket. Is this what you do mean.

thanks


--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/wrPRugsdRY4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Konstantinos

unread,
Nov 12, 2014, 5:43:15 AM11/12/14
to ns-3-...@googlegroups.com
Yes,

Basically instead of using Simulator::Now() which would send the next packet ... now, 
make your calculations according to the mobility as you mention, and calculate the time after which you want to send the packet.

To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

Osama Gazali

unread,
Nov 12, 2014, 6:08:57 AM11/12/14
to ns-3-...@googlegroups.com
I tried it before but first option did not enter CAMmanage::ScheduleTx at allt and second one gave me freqFaul.
this is the reason why i tried to implement it in sendPacket and it confirm that a few cam have been transmit,



FIRST OPTION ------->  GIVES void
CAMmanage::SendPacket (void)
{
    Ptr<Packet> packet = Create<Packet> (m_packetSize);
  AddInciPacketTags(packet);

  m_sendCount ++;

  m_socket->DoSendTo(packet, m_c2cAddress, m_port,1,1,m_sendCount);
 
}


void
CAMmanage::ScheduleTx (void)
{

    if (m_running)
    {
  if conditions depends on mobility met Then
           {

                  SendPacket ();
 
            }

              ScheduleTx ();
    }
}



Second Option ---> gave me frgFault

void
CAMmanage::SendPacket (void)
{
    Ptr<Packet> packet = Create<Packet> (m_packetSize);
  AddInciPacketTags(packet);

  m_sendCount ++;

  m_socket->DoSendTo(packet, m_c2cAddress, m_port,1,1,m_sendCount);

                  ScheduleTx ();
}


void
CAMmanage::ScheduleTx (void)
{

    if (m_running)
    {
  if conditions depends on mobility met Then
           {

                  SendPacket ();
 
            }

              ScheduleTx ();
    }
}

thanks
.....................................................................................................
.....................................................................................................

To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/wrPRugsdRY4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

Konstantinos

unread,
Nov 12, 2014, 6:32:45 AM11/12/14
to ns-3-...@googlegroups.com
For the first option, yes, it is expected not to enter. I do not see any call for it.

For the second, I do not see any scheduling of a new event... 
I would say there is a possibility that you enter an infinite loop. 
e.g. You send your CAM, you call ScheduleTx and 'mobility' conditions are not met, then you call ScheduleTx.
Since NS-3 is an event-based simulator, the above would be a loop (there is no increment in time, so no new event is parsed).

Can you please explain what you want to achieve? What are the mobility conditions you mention? 
Just read my previous replies more carefully and analyse your code step by step.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/wrPRugsdRY4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

Tommaso Pecorella

unread,
Nov 12, 2014, 7:22:19 AM11/12/14
to ns-3-...@googlegroups.com
I'm ready to bet that this is relevant: http://en.wikipedia.org/wiki/CAN_bus

He's trying to send packets if a given condition on mobility is met (e.g., if speed is above a threshold).
Guess why I didn't reply ?

Cheers,

T.

Konstantinos

unread,
Nov 12, 2014, 7:41:29 AM11/12/14
to ns-3-...@googlegroups.com
Hi Tommaso,

I see your bet and raise it he is working on co-operative awareness messages (CAMs)

I think he is trying to implement the following [1]:

CAMs are generated by the CAM Management and passed to lower layers according to following rules:
a. maximum time interval between CAM generations: 1s
b. minimum time interval between CAM generations is 0,1s
c. generate CAM when absolute difference between current heading (towards North) and last CAM heading > 4°;
d. generate CAM when distance between current position and last CAM position > 5 m;
e. generate CAM when absolute difference between current speed and last CAM speed > 1 m/s; 
f. the generation rules are checked every 100 ms. 

Which is basically a two part task (WARNING: SPOILER ALERT):
1) Have the timer for 100ms-1s --> very easy to implement either fixed or with random variables.
2) Asynchronous send based on events... guess what? Tracing framework in NS-3 has already implemented this. Use the mobility trace and hook it on a new method to check the heading, position, speed changes.
Then with a little intelligence and checks you can implement this dynamic CAM generation mechanism.

[1] ETSI TS 102 637-2, Intelligent Transport Systems (ITS); Vehicular Communications; Basic Set of Applications; Part 2: Specification of Cooperative Awareness Basic Service, 2011 

K.

Osama Gazali

unread,
Nov 12, 2014, 7:59:18 AM11/12/14
to ns-3-...@googlegroups.com
Yes it is almost what you said. I thank you guys for supporting.


--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/wrPRugsdRY4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

Osama Gazali

unread,
Nov 12, 2014, 8:08:27 AM11/12/14
to ns-3-...@googlegroups.com
I am integrating Decentralized Congestion Control mechanism into ns3. One of those DCC mechanism is triggering based DCC which use ITSs dynamic as trigger to send CAM.

After integrate it into ns3, I build scenario and do simulations yo evaluate such a mechanism.

osama

Osama Gazali

unread,
Nov 12, 2014, 11:33:41 AM11/12/14
to ns-3-...@googlegroups.com

                if (move_dist > 5) {NS_LOG_INFO("Node "<<m_node->GetId()<<" INSIDE THE T-DCC LOOP " <<interTXCAM<<" at Time "<<Simulator::Now ().GetMilliSeconds ()<<" at Position "<<positionCar<< "distance\n");}
                if (speed_change > 2) {NS_LOG_INFO("Node "<<m_node->GetId()<<" INSIDE THE T-DCC LOOP " <<interTXCAM<<" at Time "<<Simulator::Now ().GetMilliSeconds ()<<" at Position "<<positionCar<< "speed\n");}
                if (interTXCAM >= 1000.0) {NS_LOG_INFO("Node "<<m_node->GetId()<<" INSIDE THE T-DCC LOOP " <<interTXCAM<<" at Time "<<Simulator::Now ().GetMilliSeconds ()<<" at Position "<<positionCar<< "TXtime\n");}

Osama Gazali

unread,
Nov 12, 2014, 11:34:36 AM11/12/14
to ns-3-...@googlegroups.com
sorry for previous message. was directed wrongly.


have a nice evening
Reply all
Reply to author
Forward
0 new messages