20 #include "ns3/system-wall-clock-ms.h"
21 #include "ns3/packet.h"
22 #include "ns3/packet-metadata.h"
35 bool IsOk (
void)
const;
37 static TypeId GetTypeId (
void);
38 virtual TypeId GetInstanceTypeId (
void)
const;
39 virtual void Print (std::ostream &os)
const;
40 virtual uint32_t GetSerializedSize (
void)
const;
44 static std::string GetTypeName (
void);
64 std::ostringstream oss;
65 oss <<
"ns3::BenchHeader<" << N <<
">";
108 for (
int i = 0; i < N; i++)
123 std::ostringstream oss;
124 oss <<
"anon::BenchTag<" << N <<
">";
130 .AddConstructor<BenchTag > ()
131 .HideFromDocumentation ()
142 for (uint32_t i = 0; i < N; ++i)
148 for (uint32_t i = 0; i < N; ++i)
153 virtual void Print (std::ostream &os)
const {
169 for (uint32_t i = 0; i < n; i++) {
191 for (uint32_t i = 0; i < n; i++) {
207 for (uint32_t i = 0; i < n; i++) {
236 for (uint32_t i = 0; i < n; i++) {
246 runBench (
void (*bench) (uint32_t), uint32_t n,
char const *name)
251 uint64_t deltaMs = time.
End ();
255 std::cout << ps <<
" packets/s"
256 <<
" (" << deltaMs <<
" ms elapsed)\t"
261 int main (
int argc,
char *argv[])
265 if (strncmp (
"--n=", argv[0],strlen (
"--n=")) == 0)
267 char const *nAscii = argv[0] + strlen (
"--n=");
268 std::istringstream iss;
272 if (strncmp (
"--enable-printing", argv[0], strlen (
"--enable-printing")) == 0)
274 Packet::EnablePrinting ();
281 std::cerr <<
"Error-- number of packets must be specified " <<
282 "by command-line argument --n=(number of packets)" << std::endl;
285 std::cout <<
"Running bench-packets with n=" << n << std::endl;
286 std::cout <<
"All tests begin by adding UDP and IPv4 headers." << std::endl;
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
static void C1(Ptr< Packet > p)
void AddPacketTag(const Tag &tag) const
Add a packet tag.
#define NS_ASSERT(condition)
static std::string GetName(void)
TAG_BUFFER_INLINE uint8_t ReadU8(void)
iterator in a Buffer instance
measure elapsed time in milliseconds
static void benchA(uint32_t n)
virtual uint32_t GetSerializedSize(void) const
int main(int argc, char *argv[])
void Start(void)
Start a measure.
static void benchD(uint32_t n)
static void benchB(uint32_t n)
static TypeId GetTypeId(void)
Ptr< Packet > Copy(void) const
tag a set of bytes in a packet
virtual TypeId GetInstanceTypeId(void) const
virtual void Serialize(TagBuffer buf) const
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
static void runBench(void(*bench)(uint32_t), uint32_t n, char const *name)
void WriteU8(uint8_t data)
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
virtual void Print(std::ostream &os) const
static void C2(Ptr< Packet > p)
static void benchC(uint32_t n)
int64_t End(void)
Stop measuring the time since Start() was called.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void AddHeader(const Header &header)
Add header to this packet.
virtual void Deserialize(TagBuffer buf)