[Ns-bugs] [Bug 639] New: implementation of Buffer::CopyData(std::ostream* os, uint32_t size) is not correct

code@nsnam.ece.gatech.edu code at nsnam.ece.gatech.edu
Wed Jul 15 09:36:08 PDT 2009


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

           Summary: implementation of Buffer::CopyData(std::ostream* os,
                    uint32_t size) is not correct
           Product: ns-3
           Version: ns-3-dev
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P5
         Component: simulation core
        AssignedTo: ns-bugs at isi.edu
        ReportedBy: nbaldo at cttc.es
   Estimated Hours: 0.01


PcapWriter writes packet data to file using Buffer::CopyData(std::ostream *os,
uint32_t size). The function interface is not documented. One would expect that
the size parameter allows the caller to specify the maximum amount of
bytes to copy. However, this is not the actual behavior. 

Looking at the implementation of the function, I can't really understand the
reason for this check: 
if (size == GetSize ())

The only code calling this method is PcapWriter (which calls it through
Packet::CopyData(std::ostream *os, uint32_t size)), I could see no other use of
this function. PcapWriter passes packet->.GetSize () as the value of the size
parameter, so the above check is always true, and the "else" part of the
statement is never executed. Furthremore, this "else" part does not limit the
size of the write operation (I wonder what it was meant to do).

Making the size parameter limit the size of the write operation is desirable,
e.g., to implement a capture size limit for PCAP traces.


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


More information about the Ns-bugs mailing list