[Ns-bugs] [Bug 385] Add a generic "sequence number" class

code@nsnam.ece.gatech.edu code at nsnam.ece.gatech.edu
Tue Jun 15 13:38:27 PDT 2010


http://www.nsnam.org/bugzilla/show_bug.cgi?id=385





--- Comment #17 from Tom Henderson <tomh at tomh.org>  2010-06-15 16:38:26 EDT ---
(In reply to comment #16)
> Created an attachment (id=922)
 --> (http://www.nsnam.org/bugzilla/attachment.cgi?id=922) [details]
> Easily traceable general sequence number
> 
> Craig is right that the sequence number should be easily traceable.  Given his
> suggestions and some of the code from the previous two patches, I created a new
> patch that (I think) is headed in the direction that Craig outlined.  If we
> decide to go this route, I would fill in the tests, rename to SequenceNumber,
> and replace sequence numbers in tcp code.
> 
> Now, given that, I'm not so sure this is a good way to do it, because:
> 
> 1) Likely the most expected way to create a generic sequence number class is to
> do something like the previous two patches.  This way a sequence number is
> actually instantiated as a sequence number, and it can only be manipulated as a
> sequence number.  As mentioned above, this is not so good for tracing.
> 
> 2) Related to above slightly, using the easily traceable method, a developer
> could manipulate sequence numbers mistakenly by using operators (>, >=, etc),
> rather than using SequenceNumber static methods.

I don't know whether it is worth the trouble to try to prevent such errors.

I do have a comment about the scope of this.  These are the macros used in TCP:

#define SEQ_LT(a,b)     ((int)((a)-(b)) < 0)
#define SEQ_LEQ(a,b)    ((int)((a)-(b)) <= 0)
#define SEQ_GT(a,b)     ((int)((a)-(b)) > 0)
#define SEQ_GEQ(a,b)    ((int)((a)-(b)) >= 0)
#define SEQ_MIN(a, b)   ((SEQ_LT(a, b)) ? (a) : (b))
#define SEQ_MAX(a, b)   ((SEQ_GT(a, b)) ? (a) : (b))

Do we need more than these operators? 

What about providing the above macros too, for convenience?  

#define SEQ_LT(a,b)     SequenceNumber::IsLess (a,b)

-- 
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the Ns-bugs mailing list