applications: Add SeqTsEchoHeader variant
This commit is contained in:
committed by
Tom Henderson
parent
855d5ce4b4
commit
5fd3f38528
@@ -74,8 +74,8 @@ allows to choose between Block Ack policy and Implicit Block Ack Request policy
|
||||
allows to request an acknowledgment after a configurable number of MPDUs have been
|
||||
transmitted.</li>
|
||||
<li>The MaxSize attribute is removed from the QueueBase base class and moved to subclasses. A new MaxSize attribute is therefore added to the DropTailQueue class, while the MaxQueueSize attribute of the WifiMacQueue class is renamed as MaxSize for API consistency.</li>
|
||||
<li>The applications have now a "EnableE2EStats" attribute.</li>
|
||||
<li>Added a new trace source <b>PhyRxPayloadBegin</b> in WifiPhy for tracing begin of PSDU reception.</li>
|
||||
<li> A new sequence and timestamp header variant for applications has been added. The SeqTsEchoHeader contains an additional timestamp field for use in echoing a timestamp back to a sender.</li>
|
||||
</ul>
|
||||
<h2>Changes to existing API:</h2>
|
||||
<ul>
|
||||
|
||||
135
src/applications/model/seq-ts-echo-header.cc
Normal file
135
src/applications/model/seq-ts-echo-header.cc
Normal file
@@ -0,0 +1,135 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2016 Universita' di Firenze
|
||||
*
|
||||
* 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: Tommaso Pecorella <tommaso.pecorella@unifi.it>
|
||||
*/
|
||||
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/header.h"
|
||||
#include "ns3/simulator.h"
|
||||
#include "seq-ts-echo-header.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("SeqTsEchoHeader");
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (SeqTsEchoHeader);
|
||||
|
||||
SeqTsEchoHeader::SeqTsEchoHeader ()
|
||||
: m_seq (0),
|
||||
m_tsValue (Simulator::Now ()),
|
||||
m_tsEchoReply (Seconds (0))
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
|
||||
void
|
||||
SeqTsEchoHeader::SetSeq (uint32_t seq)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << seq);
|
||||
m_seq = seq;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SeqTsEchoHeader::GetSeq (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
return m_seq;
|
||||
}
|
||||
|
||||
void
|
||||
SeqTsEchoHeader::SetTsValue (Time ts)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
m_tsValue = ts;
|
||||
}
|
||||
|
||||
Time
|
||||
SeqTsEchoHeader::GetTsValue (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
return m_tsValue;
|
||||
}
|
||||
|
||||
void
|
||||
SeqTsEchoHeader::SetTsEchoReply (Time ts)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
m_tsEchoReply = ts;
|
||||
}
|
||||
|
||||
Time
|
||||
SeqTsEchoHeader::GetTsEchoReply (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
return m_tsEchoReply;
|
||||
}
|
||||
|
||||
TypeId
|
||||
SeqTsEchoHeader::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::SeqTsEchoHeader")
|
||||
.SetParent<Header> ()
|
||||
.SetGroupName ("Applications")
|
||||
.AddConstructor<SeqTsEchoHeader> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
TypeId
|
||||
SeqTsEchoHeader::GetInstanceTypeId (void) const
|
||||
{
|
||||
return GetTypeId ();
|
||||
}
|
||||
|
||||
void
|
||||
SeqTsEchoHeader::Print (std::ostream &os) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this << &os);
|
||||
os << "(seq=" << m_seq << " Tx time=" << m_tsValue.As (Time::S) << " Rx time=" << m_tsEchoReply.As (Time::S) << ")";
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SeqTsEchoHeader::GetSerializedSize (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
return 4+8+8;
|
||||
}
|
||||
|
||||
void
|
||||
SeqTsEchoHeader::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this << &start);
|
||||
Buffer::Iterator i = start;
|
||||
i.WriteHtonU32 (m_seq);
|
||||
i.WriteHtonU64 (m_tsValue.GetTimeStep ());
|
||||
i.WriteHtonU64 (m_tsEchoReply.GetTimeStep ());
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SeqTsEchoHeader::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << &start);
|
||||
Buffer::Iterator i = start;
|
||||
m_seq = i.ReadNtohU32 ();
|
||||
m_tsValue = TimeStep (i.ReadNtohU64 ());
|
||||
m_tsEchoReply = TimeStep (i.ReadNtohU64 ());
|
||||
return GetSerializedSize ();
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
98
src/applications/model/seq-ts-echo-header.h
Normal file
98
src/applications/model/seq-ts-echo-header.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2016 Universita' di Firenze
|
||||
*
|
||||
* 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: Tommaso Pecorella <tommaso.pecorella@unifi.it>
|
||||
*/
|
||||
|
||||
#ifndef SEQ_TS_ECHO_HEADER_H
|
||||
#define SEQ_TS_ECHO_HEADER_H
|
||||
|
||||
#include "ns3/header.h"
|
||||
#include "ns3/nstime.h"
|
||||
|
||||
namespace ns3 {
|
||||
/**
|
||||
* \ingroup applications
|
||||
* \class SeqTsEchoHeader
|
||||
* \brief Packet header to carry sequence number and two timestamps
|
||||
*
|
||||
* The header is made of a 32bits sequence number followed by
|
||||
* two 64bits time stamps (Transmit and Receive).
|
||||
*/
|
||||
class SeqTsEchoHeader : public Header
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Get the type ID.
|
||||
* \return the object TypeId
|
||||
*/
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
/**
|
||||
* \brief constructor
|
||||
*/
|
||||
SeqTsEchoHeader ();
|
||||
|
||||
/**
|
||||
* \param seq the sequence number
|
||||
*/
|
||||
void SetSeq (uint32_t seq);
|
||||
|
||||
/**
|
||||
* \return the sequence number
|
||||
*/
|
||||
uint32_t GetSeq (void) const;
|
||||
|
||||
/**
|
||||
* \return A time value set by the sender
|
||||
*/
|
||||
Time GetTsValue (void) const;
|
||||
|
||||
/**
|
||||
* \return A time value echoing the received timestamp
|
||||
*/
|
||||
Time GetTsEchoReply (void) const;
|
||||
|
||||
/**
|
||||
* \brief Set the sender's time value
|
||||
* \param ts Time value to set
|
||||
*/
|
||||
void SetTsValue (Time ts);
|
||||
|
||||
/**
|
||||
* \brief Upon SeqTsEchoHeader reception, the host answers via echoing
|
||||
* back the received timestamp
|
||||
* \param ts received timestamp. If not called, will contain 0
|
||||
*/
|
||||
void SetTsEchoReply (Time ts);
|
||||
|
||||
// Inherited
|
||||
virtual TypeId GetInstanceTypeId (void) const override;
|
||||
virtual void Print (std::ostream &os) const override;
|
||||
virtual uint32_t GetSerializedSize (void) const override;
|
||||
virtual void Serialize (Buffer::Iterator start) const override;
|
||||
virtual uint32_t Deserialize (Buffer::Iterator start) override;
|
||||
|
||||
private:
|
||||
uint32_t m_seq; //!< Sequence number
|
||||
Time m_tsValue; //!< Sender's timestamp
|
||||
Time m_tsEchoReply; //!< Receiver's timestamp
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* SEQ_TS_ECHO_HEADER_H */
|
||||
@@ -9,7 +9,8 @@ def build(bld):
|
||||
'model/udp-client.cc',
|
||||
'model/udp-server.cc',
|
||||
'model/seq-ts-header.cc',
|
||||
'model/e2e-stats-header.cc',
|
||||
'model/seq-ts-size-header.cc',
|
||||
'model/seq-ts-echo-header.cc',
|
||||
'model/udp-trace-client.cc',
|
||||
'model/packet-loss-counter.cc',
|
||||
'model/udp-echo-client.cc',
|
||||
@@ -48,7 +49,8 @@ def build(bld):
|
||||
'model/udp-client.h',
|
||||
'model/udp-server.h',
|
||||
'model/seq-ts-header.h',
|
||||
'model/e2e-stats-header.h',
|
||||
'model/seq-ts-size-header.h',
|
||||
'model/seq-ts-echo-header.h',
|
||||
'model/udp-trace-client.h',
|
||||
'model/packet-loss-counter.h',
|
||||
'model/udp-echo-client.h',
|
||||
|
||||
Reference in New Issue
Block a user