tag OnOff Application packets

409 views
Skip to first unread message

Ahmed Lafta

unread,
Jun 22, 2015, 8:19:46 AM6/22/15
to ns-3-...@googlegroups.com
Anybody can give me a way  to how can tag OnOff Application packets  to indicate Type Of Service (QoS) and how to read this tag.

Konstantinos

unread,
Jun 22, 2015, 8:33:11 AM6/22/15
to ns-3-...@googlegroups.com, phdprojec...@gmail.com
Have you read the manual?
https://www.nsnam.org/docs/models/html/packets.html?#adding-and-removing-tags
There are also several examples that use tags.
Create your own tag (e.g. specifying the TOS) and add it to packets from OnOff application.
Then at the IP-layer read that tag, and construct the IP-header accordingly.

Regards,
K.

Ahmed Lafta

unread,
Jun 22, 2015, 8:37:31 AM6/22/15
to ns-3-...@googlegroups.com
Thanks for your reply, can you give me an example show me these process?

--
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/9bkEpyyG_po/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,
Jun 22, 2015, 8:39:26 AM6/22/15
to ns-3-...@googlegroups.com, phdprojec...@gmail.com
Which process? Of creating tags, adding to packets and reading them? 
They are ALL in the manual (link provided in the previous post).


On Monday, June 22, 2015 at 1:37:31 PM UTC+1, Ahmed Lafta wrote:
Thanks for your reply, can you give me an example show me these process?
On Mon, Jun 22, 2015 at 1:33 PM, Konstantinos <dinos.k...@gmail.com> wrote:
Have you read the manual?
https://www.nsnam.org/docs/models/html/packets.html?#adding-and-removing-tags
There are also several examples that use tags.
Create your own tag (e.g. specifying the TOS) and add it to packets from OnOff application.
Then at the IP-layer read that tag, and construct the IP-header accordingly.

Regards,
K.

On Monday, June 22, 2015 at 1:19:46 PM UTC+1, Ahmed Lafta wrote:
Anybody can give me a way  to how can tag OnOff Application packets  to indicate Type Of Service (QoS) and how to read this tag.

--
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/9bkEpyyG_po/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

Ahmed Lafta

unread,
Jun 22, 2015, 8:45:26 AM6/22/15
to ns-3-...@googlegroups.com
I will read, write code for this case and send to you.
Regards 

On Mon, Jun 22, 2015 at 1:39 PM, Konstantinos <dinos.k...@gmail.com> wrote:
Which process? Of creating tags, adding to packets and reading them? 
They are ALL in the manual (link provided in the previous post).


On Monday, June 22, 2015 at 1:37:31 PM UTC+1, Ahmed Lafta wrote:
Thanks for your reply, can you give me an example show me these process?
On Mon, Jun 22, 2015 at 1:33 PM, Konstantinos <dinos.k...@gmail.com> wrote:
Have you read the manual?
https://www.nsnam.org/docs/models/html/packets.html?#adding-and-removing-tags
There are also several examples that use tags.
Create your own tag (e.g. specifying the TOS) and add it to packets from OnOff application.
Then at the IP-layer read that tag, and construct the IP-header accordingly.

Regards,
K.

On Monday, June 22, 2015 at 1:19:46 PM UTC+1, Ahmed Lafta wrote:
Anybody can give me a way  to how can tag OnOff Application packets  to indicate Type Of Service (QoS) and how to read this tag.

--
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/9bkEpyyG_po/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.

--
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/9bkEpyyG_po/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

Ahmed Lafta

unread,
Jun 23, 2015, 11:56:06 AM6/23/15
to ns-3-...@googlegroups.com
Hi
I wroe a code that represent sending OnOff Application Packets from node 0 to their destination node 2
I tried to add tag to OnOff application packet, but there is error. I did not understand well.
the code is attached
Regards
addtagtest.cc

Konstantinos

unread,
Jun 23, 2015, 12:14:56 PM6/23/15
to ns-3-...@googlegroups.com, phdprojec...@gmail.com
I can/will not debug your code. That is your research.
I will only point out that you haven't understood (a) how Tags works and (b) you need further studying of basic C++.

(a) Tags: 
You need to modify the source code of OnOffApplication to add the Tag to the packets that are send OR use a trace source to tag the packets. 
In the code you provided you just copied and pasted what your read but not understood from the manual

uint8_t tid = 1;
Tag SCTag;
tag
.Set (tid);
packet
->AddPacketTag (SCTag);

In only four lines of code you managed to have errors in three of them. Well done! 
1) Tag is an abstract class
2) tag.Set() is wrong as no 'tag' object is defined.
3) You have not defined the packet object. 


(b) Lack of basic C++ understanding
Given the above analysis, I my interpretation is that you lack basic C++ knowledge. These are not NS-3 errors you had.

Sorry to be strict with you, but you are a PhD student and you need to learn. 
And you are not going to learn if someone else will do the work for you. 

Regards,
K.
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/9bkEpyyG_po/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

Ahmed Lafta

unread,
Jun 24, 2015, 5:05:46 AM6/24/15
to ns-3-...@googlegroups.com
Thanks for reply, I agree with you that I need to develop my knowledge about C++ programming. I am trying to but at the same time I am limited with time as I told you before.
I think the second method is simple to add tag for OnOff_1 application packets.
I would like to summarize what I did:

1. I added  "ns3/wifi-module.h" in the include list.
2. I made function called "ServiceClassMarkerTag" before the main program
In this function, I created an object (qosTag); a copy of QosTag class reference, then I set and add to the packet the service class marker. 

void ServiceClassMarkerTag (uint8_t tid,Ptr<const Packet> packet)
{
    QosTag qosTag;
    qosTag.SetTid(tid);
    packet->AddPacketTag(qosTag);
}


3. in the main program and after the installation of OnOff_1 helper, I trace the OnOff_1 packets and called the function for setting and adding the service class marker as:
 // Create a helper called (OnOff_1) which is used to create and configure OnOff application. a protocol type and destination socket address should be given.
OnOffHelper OnOff_1("ns3::UdpSocketFactory",node2socketaddress);
Config::ConnectWithoutContext("/NodeList/*/ApplicationList/*/$ns3::OnOff_1/Tx",MakeBoundCallback (&ServiceClassMarkerTag,AC_VI));

I executed the program without error, but in the output the service class marker is not appear with the packet that is transmitted from node to node. The output was appeared as in the attachment. Should I create Ipv4 Header and add this header to the OnOff_1 packets in order to read the Tag during the simulation processes and appear it on the output screen?
Thanks again for your efforts Dr.
Regards


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/9bkEpyyG_po/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.

--
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/9bkEpyyG_po/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
Screenshot from 2015-06-24 10:02:18.png

Yiannis

unread,
Jun 24, 2015, 5:20:05 AM6/24/15
to ns-3-...@googlegroups.com
There is no need to create a new ip header. All you want is already there, just
extract the information you need from the packet and print it out.

Konstantinos

unread,
Jun 24, 2015, 5:22:57 AM6/24/15
to ns-3-...@googlegroups.com, phdprojec...@gmail.com


On Wednesday, June 24, 2015 at 10:05:46 AM UTC+1, Ahmed Lafta wrote:
Thanks for reply, I agree with you that I need to develop my knowledge about C++ programming. I am trying to but at the same time I am limited with time as I told you before.
I think the second method is simple to add tag for OnOff_1 application packets.
I would like to summarize what I did:

1. I added  "ns3/wifi-module.h" in the include list.

No need to add the whole wifi module, just the QosTag header file.
Your scenario is a wired p2p.
 
2. I made function called "ServiceClassMarkerTag" before the main program
In this function, I created an object (qosTag); a copy of QosTag class reference, then I set and add to the packet the service class marker. 

void ServiceClassMarkerTag (uint8_t tid,Ptr<const Packet> packet)
{
    QosTag qosTag;
    qosTag.SetTid(tid);
    packet->AddPacketTag(qosTag);
}


Ok, you just copied the TagMaker function presented in the list I gave you.

3. in the main program and after the installation of OnOff_1 helper, I trace the OnOff_1 packets and called the function for setting and adding the service class marker as:
 // Create a helper called (OnOff_1) which is used to create and configure OnOff application. a protocol type and destination socket address should be given.
OnOffHelper OnOff_1("ns3::UdpSocketFactory",node2socketaddress);
Config::ConnectWithoutContext("/NodeList/*/ApplicationList/*/$ns3::OnOff_1/Tx",MakeBoundCallback (&ServiceClassMarkerTag,AC_VI));


ok
 
I executed the program without error, but in the output the service class marker is not appear with the packet that is transmitted from node to node. The output was appeared as in the attachment. Should I create Ipv4 Header and add this header to the OnOff_1 packets in order to read the Tag during the simulation processes and appear it on the output screen?

Why do you expect to see something in the output from that function? You do not tell it to print something. It just adds a PacketTag to the transmitted packet, that's all.
Why are you obsessed with creating Ipv4 headers yourself? Do you think that IP headers are not created? I mentioned in my previous reply, you need to understand WHERE the IP header is created, go to that function, read the QosTag that you added to the packet and set the TOS field properly.
 
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/9bkEpyyG_po/unsubscribe.
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/9bkEpyyG_po/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

Dang Tai Tan

unread,
Jun 25, 2015, 11:55:32 AM6/25/15
to ns-3-...@googlegroups.com, phdprojec...@gmail.com
I think maybe it due to the value of AC_VI 
let's look at this
QosUtilsMapTidToAc (uint8_t tid)
{
  switch (tid)
    {
    case 0:
      return AC_BE;
      break;
    case 1:
      return AC_BK;
      break;
    case 2:
      return AC_BK;
      break;
    case 3:
      return AC_BE;
      break;
    case 4:
      return AC_VI;
      break;
    case 5:
      return AC_VI;
      break;
    case 6:
      return AC_VO;
      break;
    case 7:
      return AC_VO;
      break;
    }
  

if you want to add tag AC_VI , so i think you can assign value of AC_VI in your scenario, for example 5 or 4 it is ok.

I hope I understand correctly, 
if so, i hope this help


Vào 18:22:57 UTC+9 Thứ Tư, ngày 24 tháng 6 năm 2015, Konstantinos đã viết:
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/9bkEpyyG_po/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.

--
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/9bkEpyyG_po/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

Ahmed Lafta

unread,
Jun 26, 2015, 6:09:58 AM6/26/15
to ns-3-...@googlegroups.com

Thanks Dr. Konstantinos,

Regarding to your commands: 


"Why do you expect to see something in the output from that function? You do not tell it to print something. It just adds a PacketTag to the transmitted packet, that's all.

Yes that is correct, I did not give a print order. I thought that by adding tag to OnOff_1 packets, the tag would appear as the output.

 

"Why are you obsessed with creating Ipv4 headers yourself? Do you think that IP headers are not created?"

I reviewed yours previous comments, you said that “ by default OnOffApplication does not add any headerthis thing pushed me to thought that the OnOff application generate packets without header. From your explanation, OnOff application packets contain a header with empty fields  

  

 

 

"I mentioned in my previous reply, you need to understand WHERE the IP header is created, go to that function, read the QosTag that you added to the packet and set the TOS field properly."

As I know IP header is constructed at layer-3 (packet layer) and TCP/UDP at the upper layer, so I should go to ns3::Ipv4L3Protocol Class Reference (not Ipv4 Class Reference that is used for upper layer). By creating an object from Ipv4L3Protocol in the main program, read the QosTag and set the ToS field of IP header for OnOff_1 application packets with QosTag that is added to the packets. If this correct, I will write the codes and send to you.


Regards

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/9bkEpyyG_po/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.

--
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/9bkEpyyG_po/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.

--
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/9bkEpyyG_po/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

Konstantinos

unread,
Jun 26, 2015, 6:30:59 AM6/26/15
to ns-3-...@googlegroups.com, phdprojec...@gmail.com


On Friday, June 26, 2015 at 11:09:58 AM UTC+1, Ahmed Lafta wrote:

Thanks Dr. Konstantinos,

Regarding to your commands: 


"Why do you expect to see something in the output from that function? You do not tell it to print something. It just adds a PacketTag to the transmitted packet, that's all.

Yes that is correct, I did not give a print order. I thought that by adding tag to OnOff_1 packets, the tag would appear as the output.

 

"Why are you obsessed with creating Ipv4 headers yourself? Do you think that IP headers are not created?"

I reviewed yours previous comments, you said that “ by default OnOffApplication does not add any headerthis thing pushed me to thought that the OnOff application generate packets without header. From your explanation, OnOff application packets contain a header with empty fields  

  

 


What I said is still valid. OnOff does not add any headers. I did not say that it adds empty fields. IP headers are created in the place that they are needed. 
Please study the documentation more carefully. Particularly this section will clarify some points https://www.nsnam.org/docs/models/html/internet-stack.html#example-path-of-a-packet
 

 

"I mentioned in my previous reply, you need to understand WHERE the IP header is created, go to that function, read the QosTag that you added to the packet and set the TOS field properly."

As I know IP header is constructed at layer-3 (packet layer) and TCP/UDP at the upper layer, so I should go to ns3::Ipv4L3Protocol Class Reference (not Ipv4 Class Reference that is used for upper layer). By creating an object from Ipv4L3Protocol in the main program, read the QosTag and set the ToS field of IP header for OnOff_1 application packets with QosTag that is added to the packets. If this correct, I will write the codes and send to you.



You do not need to create an object for Ipv4L3Protocol. It is automatically created and assigned to a node when you install the InternetStack to it. 
The rest seem correct, i.e. go in the Ipv4L3Protocol and find where the IP header is constructed, read the QosTag and set the ToS field.

However, I would suggest to study the Ipv4L3Protocol a bit more. 
e.g. in Ipv4L3Protocol::Send you can find this. Which is what you want. So there is some code in the Socket that adds TOS information. YOU need to study and find out how.

630  uint8_t tos = m_defaultTos;
631  SocketIpTosTag ipTosTag;
632  found = packet->RemovePacketTag (ipTosTag);
633  if (found)
634  {
635  tos = ipTosTag.GetTos ();
636  }
637 
 
Regards

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/9bkEpyyG_po/unsubscribe.
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/9bkEpyyG_po/unsubscribe.
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/9bkEpyyG_po/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages