src/common/packet.h
changeset 84 63b3ed9ce4e4
parent 82 2b6f5d8f8b41
child 90 d670ba9f726e
equal deleted inserted replaced
83:430203344318 84:63b3ed9ce4e4
    44  * These tags typically contain per-packet cross-layer information or 
    44  * These tags typically contain per-packet cross-layer information or 
    45  * flow identifiers. Each tag stored in the tag list can be at most
    45  * flow identifiers. Each tag stored in the tag list can be at most
    46  * 16 bytes big. Trying to attach bigger data structures will trigger
    46  * 16 bytes big. Trying to attach bigger data structures will trigger
    47  * crashes at runtime.
    47  * crashes at runtime.
    48  *
    48  *
       
    49  * Implementing a new type of Chunk for a new protocol is pretty easy
       
    50  * and is a matter of creating a subclass of the ns3::Chunk base class,
       
    51  * and implementing the 4 pure virtual methods defined in ns3::Chunk.
       
    52  * Sample code which shows how to create such a new Chunk, how to use
       
    53  * it, and how to manipulate tags is shown below:
       
    54  * \include samples/main-packet.cc
       
    55  *
    49  * The current implementation of the byte buffers and tag list is based
    56  * The current implementation of the byte buffers and tag list is based
    50  * on COW (Copy On Write). An introduction to COW can be found in Scott 
    57  * on COW (Copy On Write. An introduction to COW can be found in Scott 
    51  * Meyer's "More Effective C++", items 17 and 29. What this means is that
    58  * Meyer's "More Effective C++", items 17 and 29). What this means is that
    52  * copying packets without modifying them is very cheap (in terms of cpu
    59  * copying packets without modifying them is very cheap (in terms of cpu
    53  * and memory usage). What is key for proper COW implementations is being
    60  * and memory usage) and modifying them can be also very cheap. What is 
       
    61  * key for proper COW implementations is being
    54  * able to detect when a given modification of the state of a packet triggers
    62  * able to detect when a given modification of the state of a packet triggers
    55  * a full copy of the data prior to the modification: COW systems need
    63  * a full copy of the data prior to the modification: COW systems need
    56  * to detect when an operation is "dirty".
    64  * to detect when an operation is "dirty".
    57  *
    65  *
    58  * Dirty operations:
    66  * Dirty operations:
    59  *   - ns3::Packet::removeTag
    67  *   - ns3::Packet::removeTag
    60  *   - ns3::Packet::add
    68  *   - ns3::Packet::add
    61  *   - both versions of ns3::Packet::addAtEnd
    69  *   - both versions of ns3::Packet::addAtEnd
       
    70  *
    62  * Non-dirty operations:
    71  * Non-dirty operations:
    63  *   - ns3::Packet::addTag
    72  *   - ns3::Packet::addTag
    64  *   - ns3::Packet::removeAllTags
    73  *   - ns3::Packet::removeAllTags
    65  *   - ns3::Packet::peekTag
    74  *   - ns3::Packet::peekTag
    66  *   - ns3::Packet::peek
    75  *   - ns3::Packet::peek