Skip to content

Commit 7079648

Browse files
committed
fixbug: replace the init method from CreateObject to direct Create
1 parent 1a6fbba commit 7079648

6 files changed

Lines changed: 231 additions & 205 deletions

File tree

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ build_lib(
2020
model/bridge-p4-net-device.cc
2121
model/standard-metadata-tag.cc
2222
model/p4-queue-item.cc
23-
model/p4-logic-pri-rl-queue-disc.cc
2423
model/p4-rr-pri-queue-disc.cc
2524
model/format-utils.cc
2625
model/switch-api.cc
@@ -39,7 +38,6 @@ build_lib(
3938
model/bridge-p4-net-device.h
4039
model/standard-metadata-tag.h
4140
model/p4-queue-item.h
42-
model/p4-logic-pri-rl-queue-disc.h
4341
model/p4-rr-pri-queue-disc.h
4442
model/format-utils.h
4543
model/switch-api.h

model/p4-queue-item.cc

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,60 @@
11
#include "ns3/p4-queue-item.h"
2+
23
#include "ns3/log.h"
34

4-
namespace ns3 {
5+
namespace ns3
6+
{
7+
8+
NS_LOG_COMPONENT_DEFINE("P4QueueItem");
59

6-
NS_LOG_COMPONENT_DEFINE ("P4QueueItem");
10+
// TypeId
11+
// P4QueueItem::GetTypeId()
12+
// {
13+
// static TypeId tid =
14+
// TypeId("ns3::P4QueueItem").SetParent<QueueDiscItem>().AddConstructor<P4QueueItem>();
15+
// return tid;
16+
// }
717

8-
P4QueueItem::P4QueueItem (Ptr<Packet> p, const Address &addr, uint16_t protocol)
9-
: QueueDiscItem (p, addr, protocol), m_sendTime (Seconds (0))
18+
P4QueueItem::P4QueueItem(Ptr<Packet> p, const Address& addr, uint16_t protocol)
19+
: QueueDiscItem(p, addr, protocol),
20+
m_sendTime(Seconds(0))
1021
{
11-
NS_LOG_FUNCTION (this << p << addr << protocol);
22+
NS_LOG_FUNCTION(this << p << addr << protocol);
1223
}
1324

14-
P4QueueItem::~P4QueueItem ()
25+
26+
P4QueueItem::~P4QueueItem()
1527
{
16-
NS_LOG_FUNCTION (this);
28+
NS_LOG_FUNCTION(this);
1729
}
1830

1931
void
20-
P4QueueItem::SetSendTime (Time sendTime)
32+
P4QueueItem::SetSendTime(Time sendTime)
2133
{
22-
NS_LOG_FUNCTION (this << sendTime);
23-
m_sendTime = sendTime;
34+
NS_LOG_FUNCTION(this << sendTime);
35+
m_sendTime = sendTime;
2436
}
2537

2638
Time
27-
P4QueueItem::GetSendTime () const
39+
P4QueueItem::GetSendTime() const
2840
{
29-
NS_LOG_FUNCTION (this);
30-
return m_sendTime;
41+
NS_LOG_FUNCTION(this);
42+
return m_sendTime;
3143
}
3244

3345
bool
34-
P4QueueItem::IsReadyToDequeue (Time currentTime) const
46+
P4QueueItem::IsReadyToDequeue(Time currentTime) const
3547
{
36-
NS_LOG_FUNCTION (this << currentTime);
37-
return currentTime >= m_sendTime;
48+
NS_LOG_FUNCTION(this << currentTime);
49+
return currentTime >= m_sendTime;
3850
}
3951

4052
void
41-
P4QueueItem::Print (std::ostream &os) const
53+
P4QueueItem::Print(std::ostream& os) const
4254
{
43-
NS_LOG_FUNCTION (this);
44-
os << "P4QueueItem: "
45-
<< "SendTime=" << m_sendTime.GetSeconds () << "s, "
46-
<< "PacketSize=" << GetPacket ()->GetSize () << " bytes";
55+
NS_LOG_FUNCTION(this);
56+
os << "P4QueueItem: " << "SendTime=" << m_sendTime.GetSeconds() << "s, "
57+
<< "PacketSize=" << GetPacket()->GetSize() << " bytes";
4758
}
4859

4960
} // namespace ns3

model/p4-queue-item.h

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ namespace ns3 {
1111
class P4QueueItem : public QueueDiscItem
1212
{
1313
public:
14+
15+
// /**
16+
// * \brief Get the type ID.
17+
// * \return the object TypeId
18+
// */
19+
// static TypeId GetTypeId();
20+
21+
1422
/**
1523
* \brief Constructor
1624
* \param p The packet
@@ -19,10 +27,12 @@ class P4QueueItem : public QueueDiscItem
1927
*/
2028
P4QueueItem (Ptr<Packet> p, const Address &addr, uint16_t protocol);
2129

22-
/**
23-
* \brief Destructor
24-
*/
25-
virtual ~P4QueueItem ();
30+
virtual ~P4QueueItem () override;
31+
32+
// Delete default constructor, copy constructor and assignment operator to avoid misuse
33+
P4QueueItem () = delete;
34+
P4QueueItem (const P4QueueItem &) = delete;
35+
P4QueueItem &operator = (const P4QueueItem &) = delete;
2636

2737
/**
2838
* \brief Set the expected send time
@@ -48,6 +58,24 @@ class P4QueueItem : public QueueDiscItem
4858
*/
4959
void Print (std::ostream &os) const override;
5060

61+
void AddHeader() override
62+
{
63+
// @TODO deal with header, keep header and payload separate to allow manipulating the header
64+
return;
65+
}
66+
67+
/**
68+
* \brief Marks the packet as a substitute for dropping it, such as for Explicit Congestion
69+
* Notification
70+
*
71+
* \return true if the packet is marked by this method or is already marked, false otherwise
72+
*/
73+
bool Mark() override
74+
{
75+
//
76+
return false;
77+
}
78+
5179
private:
5280
Time m_sendTime; //!< Expected send time of the packet
5381
};

0 commit comments

Comments
 (0)