Re: Ns-developers Digest, Vol 125, Issue 5

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ns-developers Digest, Vol 125, Issue 5

Kostantinos Katsaros
Hi,

Regarding the 'const' header variable, similar issues with 'const'
parameters (e.g. Packets in some methods) have been resolved just by
creating a non-const variable inside your method (RouteOutput) and copying
the 'const' variable over. They, and for the rest of the method, you will
be using the non-const variable.

Regards,
K.

On 12 April 2017 at 01:02, <[hidden email]> wrote:

> Send Ns-developers mailing list submissions to
>         [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://mailman.isi.edu/mailman/listinfo/ns-developers
> or, via email, send a message with subject or body 'help' to
>         [hidden email]
>
> You can reach the person managing the list at
>         [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Ns-developers digest..."
>
>
> Today's Topics:
>
>    1. Change in the RouteOutput signature of    Ipv4RoutingProtocol
>       (Igor Ribeiro)
>    2. Re: Change in the RouteOutput signature of
>       Ipv4RoutingProtocol (Tom Henderson)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 11 Apr 2017 02:19:16 -0300
> From: Igor Ribeiro <[hidden email]>
> Subject: [Ns-developers] Change in the RouteOutput signature of
>         Ipv4RoutingProtocol
> To: [hidden email]
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset="utf-8"
>
> Hi everyone,
>
> I am currently working on a project that requires the routing protocol to
> be able to change the destination address of the IP header passed as
> argument to the RouteOutput method. The problem is the header parameter is
> passed as a const reference, so I cannot change it?s destination address.
> To overcome this problem I had to change the definition of RouteOutput in
> the class Ipv4RoutingProtocol  and, consequently, in all derived classes.
> So far I compiled the code and no errors were reported but it still lack
> some tests. The reason I am writing this message is that in the future I
> would like to push my project to the ns3 repository and, therefore, I would
> like to know if this modification could potentially prevent me to do so.
>
> Thank you in advance.
>
> Best Regards,
>
> Igor.
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: signature.asc
> Type: application/pgp-signature
> Size: 496 bytes
> Desc: Message signed with OpenPGP
> Url : http://mailman.isi.edu/pipermail/ns-developers/
> attachments/20170411/d4f1b09f/signature-0001.bin
>
> ------------------------------
>
> Message: 2
> Date: Tue, 11 Apr 2017 13:04:02 -0700
> From: Tom Henderson <[hidden email]>
> Subject: Re: [Ns-developers] Change in the RouteOutput signature of
>         Ipv4RoutingProtocol
> To: [hidden email]
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=utf-8; format=flowed
>
> On 04/10/2017 10:19 PM, Igor Ribeiro wrote:
> > Hi everyone,
> >
> > I am currently working on a project that requires the routing protocol
> to be able to change the destination address of the IP header passed as
> argument to the RouteOutput method. The problem is the header parameter is
> passed as a const reference, so I cannot change it?s destination address.
> To overcome this problem I had to change the definition of RouteOutput in
> the class Ipv4RoutingProtocol  and, consequently, in all derived classes.
> So far I compiled the code and no errors were reported but it still lack
> some tests. The reason I am writing this message is that in the future I
> would like to push my project to the ns3 repository and, therefore, I would
> like to know if this modification could potentially prevent me to do so.
> >
> > Thank you in advance.
> >
> > Best Regards,
> >
> > Igor.
> I think we will need to discuss the tradeoffs further.  On the one hand,
> removing the const reference might be the quickest fix but we might
> prefer to be more explicit about returning a modified destination and
> have the transport protocols handle this explicitly.  However, we can
> probably find a solution to this.
>
> - Tom
>
>
>
> ------------------------------
>
> _______________________________________________
> Ns-developers mailing list
> [hidden email]
> http://mailman.isi.edu/mailman/listinfo/ns-developers
>
>
> End of Ns-developers Digest, Vol 125, Issue 5
> *********************************************
>



--
Konstantinos Katsaros
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Fwd: Ns-developers Digest, Vol 125, Issue 5

Natale Patriciello
2017-04-12 11:14 GMT+02:00 Kostantinos Katsaros <[hidden email]>:

> Hi,
>
> Regarding the 'const' header variable, similar issues with 'const'
> parameters (e.g. Packets in some methods) have been resolved just by
> creating a non-const variable inside your method (RouteOutput) and copying
> the 'const' variable over. They, and for the rest of the method, you will
> be using the non-const variable.
>
> Regards,
> K.


It can work with pointers (giving the appropriate const_cast) but not with
references. In general, as Tom said, it is strongly discouraged, because
you go against a design decision.

Then, one can question if the design is correct; well, for a big portion of
the internet module, the answer is no, but in this particular case (routing
protocol) it seems correct. A routing protocol should not modify the
headers. In Linux, these operations are done through the netfilter
framework (surely you have seen iptables) which is a layer below  IP, a
missing part in ns-3.

Nat
Loading...