NS3 MAC design (change RTS, CTS)

316 views
Skip to first unread message

Alim

unread,
Dec 14, 2015, 5:29:17 AM12/14/15
to ns-3-users
Dear Experts,
 
I am new in NS3 as well as new in C++.
However, I am trying to do my simulations in Ns3. I want to simulate a MAC layer design.

Please make me clear about the following matters (I am using NS 3.20):


 Question.1). I want to add 2 bits at the end of RTS and CTS ( in wifi-mac-header.cc). According to the bits I want to add some conditions. How can I do this? 
                     Should I use packet tag? If I am correct, please let me know how and where should I use this packet tag?
                       If possible, give example please.


Thanks a lot in advance.
--Alim


Konstantinos

unread,
Dec 14, 2015, 9:33:27 AM12/14/15
to ns-3-users
Hi Alim,

Since you want to change the contents of RTS/CTS packets, you will not work with packet tags. 
You should directly alter the headers, since these packets are implemented as Header types that are appended onto dummy packets. Introduce your new elements/variables, serialize/deserialize them (i.e. write/read) and update the serializedSize which is how many bytes you read/write.
The minimum amount you can read/write is 1 byte = 8bits. So you can have 2bits for your information and the rest 6 'reserved' as zero and only read/write 1 byte.

As a side note, PLEASE upgrade to the latest NS-3 release. The WiFi module has been significantly improved since ns-3.20 with additions of new capabilities and fixing bugs with existing code.

Regards,
K.

Alim

unread,
Dec 14, 2015, 8:44:55 PM12/14/15
to ns-3-users
Dear Konstantinos;
Thanks a lot for your reply.

So, there is no way to add only two bits, right? I have to add 1 byte. 

Thanks a lot.
-Alim

Tommaso Pecorella

unread,
Dec 15, 2015, 4:53:15 AM12/15/15
to ns-3-users
Hi,

it's a layering problem. At L3 and above you don't use bits, you use (at least) bytes. I say at least because in many cases there are further restrictions. E.g., IP options have multi-byte requirements.
At L2 or below you can use bits, or even symbols.
This is a bit of an issue for ns-3 tho, but it can be done (usually it's in the lower MAC parts, and it's where you calculate the Tx time for each packet type).
Check WifiPhy::CalculateTxDuration, it's where you should start to understand it.

Cheers,

T.

Alim

unread,
Dec 15, 2015, 7:51:49 PM12/15/15
to ns-3-users
Hi Tommaso,
Thanks a lot.
-Alim

Alim

unread,
Jan 9, 2016, 2:56:47 AM1/9/16
to ns-3-users
Dear Tommaso Pecorella ,
Actually, I want add exactly 2 bits in RTS and CTS.
So, I am not clear what you have said. Do you please explain. I have read WifiPhy::CalculateTxDuration, but I could get the idea to add only two bits.
As, Mr. Konstantinos said me to add 1 bytes, I thought it will work. 
But problem is that it will not be the exact simulation that I wanted.

So please give me the idea that how can I add only two bits at the end of RTS and CTS.
I am waiting for your reply.
Thanks and regards.
Alim.


On Tuesday, 15 December 2015 01:53:15 UTC-8, Tommaso Pecorella wrote:

Tommaso Pecorella

unread,
Jan 9, 2016, 10:07:34 AM1/9/16
to ns-3-users
Hi,

I'll try to make it clearer, there's always a shred of hope.
At L3 you work with BYTES, not bits.
At L2 you work with BITS.
At L1 you work with SYMBOLS.

L2 datagrams are almost always made of a payload (multiple of bytes) and a preamble/header, which could be any number of bits.
RTS and CTS are L2 datagrams (like ACKs), thus you could add 2 bits. The problem is that you have not said WHERE you want to add them. This is a major mistake.
Now, I could add them in the right place for you, but this is your task.

What I can give you is a suggestion: decide where you want to add these 2 bits.
The Wi-Fi packet (at le lowest level) is made by preambles, headers and the payload. Payload is a multiple of 8 bits. The MAC header is a multiple of 8 bits (it's not mandatory in general, but it's true for 802.11). The preambles are... different.
If you check the WifiPhy::CalculateTxDuration this difference is evident.

As a consequence, if you add these 2 bits to the preamble, you can modify the corresponding functions (but are the 2 bits a part of the preamble ?). If there elsewhere you'll be in trouble, because we followed the standard and in the standard everything is a multiple of 8 bits. As a consequence you'll have to modify a LOT of functions.

T.

Alim

unread,
Jan 10, 2016, 8:46:00 PM1/10/16
to ns-3-users
Dear Tommaso Pecorella,
Thanks a lot for your description.
This will be a great help for me.

Actually I want to add 2 bits at the end of RTS and CTS, also I will add some other new control frame (as MAC header, for example RTSD.) I don't want to add them as a preamble.
So, please clear me about the following things:
   (i) How can I add these 2 bits at the end of RTS or CTS (before FCS)? Please let me know the ways.
   (ii) I want to make some new sequence of MAC header. For example, in general the data is transmitted after RTS and CTS transmission; but I want to make it as first RTS, CTS, then new RTSD; after these data will be transmitted. 
         I don't want to follow the 802.11 standard.
        My question, where will I make these new sequence? 

Thanks a lot in advance.
Alim

Tommaso Pecorella

unread,
Jan 10, 2016, 8:52:38 PM1/10/16
to ns-3-users
Hi Alim,

to be honest the help we can give is limited to what we already did. If you don't want to follow the standard, you'll have to develop your own module, eventually by modifying the existing Wi-Fi module.
However, it's well beyond our duties and possibilities to help you in all the details. The Wi-Fi module is extremely complex and showing exactly how to do what you want to do is, basically, doing it (i.e., doing your work).
From what you said, the thing you're planning to do is a quite radical modification of the standard. As a consequence, it will be quite difficult to do. Not impossible, but hard. As a consequence, instead of focusing on the small details (where to add the bits), start studying the wifi module. By when you'll have a clear overview of it, you'll be able to add your own stuff to it.

Have fun studying,

T.

Alim

unread,
Jan 10, 2016, 9:24:58 PM1/10/16
to ns-3-users
Dear Tommaso Pecorella,
Ok, I got it.
Thanks a lot for your suggestions.
 
With best regards.
Alim
Reply all
Reply to author
Forward
0 new messages