--- a/SConstruct Mon Oct 02 11:25:07 2006 +0200
+++ b/SConstruct Mon Oct 02 11:32:31 2006 +0200
@@ -80,8 +80,6 @@
common.add_sources ([
'buffer.cc',
'header.cc',
- 'chunk.cc',
- 'chunk-constant-data.cc',
'packet.cc',
'tags.cc',
'pcap-writer.cc',
@@ -91,9 +89,7 @@
])
common.add_inst_headers ([
'buffer.h',
- 'chunk.h',
'header.h',
- 'chunk-constant-data.h',
'tags.h',
'packet.h',
'ui-variable-tracer.h',
--- a/src/common/chunk-constant-data.cc Mon Oct 02 11:25:07 2006 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/* -*- Mode:C++; c-basic-offset:4; tab-width:4; indent-tabs-mode:f -*- */
-/*
- * Copyright (c) 2005 INRIA
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-
-#include "chunk-constant-data.h"
-
-namespace ns3 {
-
-ChunkConstantData::ChunkConstantData (uint32_t len, uint8_t data)
- : m_len (len), m_data (data)
-{}
-
-ChunkConstantData::~ChunkConstantData ()
-{}
-
-
-void
-ChunkConstantData::print (std::ostream *os) const
-{
- *os << "(constant data)"
- << " len=" << m_len
- << ", data=" << m_data;
-}
-
-void
-ChunkConstantData::addTo (Buffer *buffer) const
-{
- buffer->addAtStart (m_len);
-#ifndef NDEBUG
- buffer->begin ().writeU8 (m_data, m_len);
-#endif
-}
-void
-ChunkConstantData::peekFrom (Buffer const *buffer)
-{
- m_len = buffer->getSize ();
- m_data = buffer->begin ().readU8 ();
-}
-void
-ChunkConstantData::removeFrom (Buffer *buffer)
-{
- buffer->removeAtStart (m_len);
-}
-
-
-}; // namespace ns3
--- a/src/common/chunk-constant-data.h Mon Oct 02 11:25:07 2006 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/* -*- Mode:C++; c-basic-offset:4; tab-width:4; indent-tabs-mode:f -*- */
-/*
- * Copyright (c) 2005 INRIA
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-
-#ifndef CHUNK_CONSTANT_DATA_H
-#define CHUNK_CONSTANT_DATA_H
-
-#include "chunk.h"
-#include <stdint.h>
-
-namespace ns3 {
-
-
-class ChunkConstantData : public Chunk {
-public:
- ChunkConstantData (uint32_t len, uint8_t data);
- ~ChunkConstantData ();
-
-private:
- virtual void print (std::ostream *os) const;
- virtual void addTo (Buffer *buffer) const;
- virtual void peekFrom (Buffer const *buffer);
- virtual void removeFrom (Buffer *buffer);
- uint32_t m_len;
- uint8_t m_data;
-};
-
-}; // namespace ns3
-
-#endif /* CHUNK_CONSTANT_DATA_H */
--- a/src/common/chunk.cc Mon Oct 02 11:25:07 2006 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/* -*- Mode:C++; c-basic-offset:4; tab-width:4; indent-tabs-mode:f -*- */
-/*
- * Copyright (c) 2005 INRIA
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-
-#include "chunk.h"
-#include <cassert>
-
-namespace ns3 {
-
-Chunk::Chunk ()
- : m_mustPeekBeforeRemove (false) {}
-
-void
-Chunk::print (std::ostream &os) const
-{
- printTo (os);
-}
-void
-Chunk::add (Buffer *buffer) const
-{
- addTo (buffer);
-}
-void
-Chunk::peek (Buffer const *buffer)
-{
- peekFrom (buffer);
- m_mustPeekBeforeRemove = true;
-}
-void
-Chunk::remove (Buffer *buffer)
-{
- assert (m_mustPeekBeforeRemove);
- removeFrom (buffer);
- m_mustPeekBeforeRemove = false;
-}
-
-
-
-Chunk::~Chunk ()
-{}
-
-std::ostream& operator<< (std::ostream& os, Chunk const& chunk)
-{
- chunk.print (os);
- return os;
-}
-
-}; // namespace ns3
--- a/src/common/chunk.h Mon Oct 02 11:25:07 2006 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/* -*- Mode:C++; c-basic-offset:4; tab-width:4; indent-tabs-mode:f -*- */
-/*
- * Copyright (c) 2005 INRIA
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-
-#ifndef CHUNK_H
-#define CHUNK_H
-
-#include <stdint.h>
-#include <ostream>
-#include "buffer.h"
-
-namespace ns3 {
-
-/**
- * \brief Protocol header serialization and deserialization.
- *
- * Every Protocol header which needs to be inserted and removed
- * from a Packet instance must derive from this abstract base class
- * and implement the private pure virtual methods listed below:
- * - ns3::Chunk::addTo
- * - ns3::Chunk::removeFrom
- * - ns3::Chunk::peekFrom
- * - ns3::Chunk::print
- */
-class Chunk {
-public:
- Chunk ();
- /**
- * Derived classes must provide an explicit virtual destructor
- */
- virtual ~Chunk () = 0;
-
- void print (std::ostream &os) const;
-
- void add (Buffer *buffer) const;
- void peek (Buffer const *buffer);
- void remove (Buffer *buffer);
-private:
- bool m_mustPeekBeforeRemove;
- /**
- * \param os the std output stream in which this
- * protocol header must print itself.
- */
- virtual void printTo (std::ostream &os) const = 0;
-
- /**
- * \param buffer the buffer in which the protocol header
- * must serialize itself.
- *
- * This method must:
- * - reserve room for its serialized representation in the input buffer
- * - serialize itself in this reserved room
- */
- virtual void addTo (Buffer *buffer) const = 0;
- /**
- * \param buffer the buffer from which the protocol header must
- * deserialize itself.
- *
- */
- virtual void peekFrom (Buffer const *buffer) = 0;
- /**
- * \param buffer the buffer from which the protocol header
- * must remove itself.
- *
- * This method must remove its serialized representation
- * from the input buffer. This method does not need to deserialize
- * the data itself.
- */
- virtual void removeFrom (Buffer *buffer) = 0;
-};
-
-std::ostream& operator<< (std::ostream& os, Chunk const& chunk);
-
-}; // namespace ns3
-
-#endif /* CHUNK_H */
--- a/src/common/packet.cc Mon Oct 02 11:25:07 2006 +0200
+++ b/src/common/packet.cc Mon Oct 02 11:32:31 2006 +0200
@@ -58,23 +58,6 @@
}
void
-Packet::add (Chunk const&chunk)
-{
- chunk.add (&m_buffer);
-}
-
-void
-Packet::peek (Chunk &chunk) const
-{
- chunk.peek (&m_buffer);
-}
-
-void
-Packet::remove (Chunk &chunk)
-{
- chunk.remove (&m_buffer);
-}
-void
Packet::add (Header const &header)
{
m_buffer.addAtStart (header.getSize ());
--- a/src/common/packet.h Mon Oct 02 11:25:07 2006 +0200
+++ b/src/common/packet.h Mon Oct 02 11:32:31 2006 +0200
@@ -23,7 +23,6 @@
#include <stdint.h>
#include "buffer.h"
-#include "chunk.h"
#include "header.h"
#include "tags.h"
#include "ns3/callback.h"
@@ -34,8 +33,8 @@
* \brief network packets
*
* Each network packet contains a byte buffer and a list of tags.
- * - The byte buffer stores the serialized content of the chunks added
- * to a packet. The serialized representation of these chunks is expected
+ * - The byte buffer stores the serialized content of the headers and trailers
+ * added to a packet. The serialized representation of these headers is expected
* to match that of real network packets bit for bit (although nothing
* forces you to do this) which means that the content of a packet buffer
* is expected to be that of a real packet.
@@ -47,10 +46,10 @@
* 16 bytes big. Trying to attach bigger data structures will trigger
* crashes at runtime.
*
- * Implementing a new type of Chunk for a new protocol is pretty easy
- * and is a matter of creating a subclass of the ns3::Chunk base class,
- * and implementing the 4 pure virtual methods defined in ns3::Chunk.
- * Sample code which shows how to create such a new Chunk, how to use
+ * Implementing a new type of Header for a new protocol is pretty easy
+ * and is a matter of creating a subclass of the ns3::Header base class,
+ * and implementing the 4 pure virtual methods defined in ns3::Header.
+ * Sample code which shows how to create such a new Header, how to use
* it, and how to manipulate tags is shown below:
* \include samples/main-packet.cc
*
@@ -118,32 +117,29 @@
*/
uint32_t getSize (void) const;
/**
- * Add chunk to this packet. This method invokes the
- * ns3::Chunk::addTo method to request the chunk to serialize
+ * Add header to this packet. This method invokes the
+ * ns3::Header::serializeTo method to request the header to serialize
* itself in the packet buffer.
*
- * \param chunk a pointer to the chunk to add to this packet.
- */
- void add (Chunk const&chunk);
- /**
- * Deserialize chunk from this packet. This method invokes the
- * ns3::Chunk::peekFrom method to request the chunk to deserialize
- * itself from the packet buffer. This method does not remove
- * the chunk from the buffer.
- *
- * \param chunk a pointer to the chunk to deserialize from the buffer
+ * \param header a reference to the header to add to this packet.
*/
- void peek (Chunk &chunk) const;
+ void add (Header const &header);
/**
- * Remove a deserialized chunk from the internal buffer.
- * This method invokes ns3::Chunk::removeFrom to complete
- * the work initiated by Packet::peek and ns3::Chunk::peekFrom.
+ * Deserialize header from this packet. This method invokes the
+ * ns3::Header::deserializeFrom method to request the header to deserialize
+ * itself from the packet buffer. This method does not remove
+ * the data from the buffer. It merely reads it.
*
- * \param chunk a pointer to the chunk to remove from the internal buffer.
+ * \param header a reference to the header to deserialize from the buffer
*/
- void remove (Chunk &chunk);
- void add (Header const &header);
void peek (Header &header);
+ /**
+ * Remove a deserialized header from the internal buffer.
+ * This method removes the bytes read by Packet::peek from
+ * the packet buffer.
+ *
+ * \param header a reference to the header to remove from the internal buffer.
+ */
void remove (Header const &header);
/**
* Attach a tag to this packet. The tag is fully copied