Skip to content

Commit 74df90f

Browse files
committed
Merge branch 'waf'
2 parents fbafe55 + c8902c3 commit 74df90f

126 files changed

Lines changed: 29112 additions & 4561 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@ build_lib(
1818
model/p4-switch-core.cc
1919
model/p4-switch-interface.cc
2020
model/bridge-p4-net-device.cc
21-
model/standard-metadata-tag.cc
22-
model/p4-queue-item.cc
23-
model/p4-rr-pri-queue-disc.cc
2421
model/format-utils.cc
2522
model/switch-api.cc
2623
helper/p4sim-helper.cc
27-
helper/priority-port-tag.cc
2824
helper/global.cc
2925
helper/p4-exception-handle.cc
3026
helper/p4-topology-reader-helper.cc
@@ -36,14 +32,10 @@ build_lib(
3632
model/p4-switch-core.h
3733
model/p4-switch-interface.h
3834
model/bridge-p4-net-device.h
39-
model/standard-metadata-tag.h
40-
model/p4-queue-item.h
41-
model/p4-rr-pri-queue-disc.h
4235
model/format-utils.h
4336
model/switch-api.h
4437
model/register_access.h
4538
helper/p4sim-helper.h
46-
helper/priority-port-tag.h
4739
helper/global.h
4840
helper/p4-exception-handle.h
4941
helper/p4-topology-reader-helper.h

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
[Quick Note with Google Docs](https://docs.google.com/document/d/18QQqo4PK8ycuZovrbAacRtFtqWSIqS0v9hRiiUYgvU8/edit?usp=sharing)
44

5+
## Virtual Machine as virtual env
56

6-
## Virtual Machine
7+
`p4sim` integrates an NS-3-based P4 simulation environment with virtual machine configuration files sourced via sparse checkout from the [P4Lang tutorials repository](https://github.com/p4lang/tutorials/tree/master). The `vm` directory contains setup files, including Vagrant configurations and bootstrap scripts, for Ubuntu-based virtual machines (`24.04` Recommended) that simplify the process of installing NS-3 and its dependencies. Using these pre-configured virtual machines is highly recommended for a streamlined setup, ensuring compatibility and minimizing installation issues.
78

8-
`p4sim` integrates an NS-3-based P4 simulation environment with virtual machine configuration files sourced via sparse checkout from the [P4Lang tutorials repository](https://github.com/p4lang/tutorials/tree/master). The `vm` directory contains setup files, including Vagrant configurations and bootstrap scripts, for Ubuntu-based virtual machines (`20.04` and `24.04`) that simplify the process of installing NS-3 and its dependencies. Using these pre-configured virtual machines is highly recommended for a streamlined setup, ensuring compatibility and minimizing installation issues.
9+
This code is tested with the following commit from the P4Lang tutorials repository:
10+
- Commit: `3acf7d1e9bb7635c76cc8fc60cd34f9919bb59d4`
11+
- Date: `2024-Dec-01`

deprecated/custom-onoff-helper.cc

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2+
/*
3+
* Copyright (c) 2008 INRIA
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License version 2 as
7+
* published by the Free Software Foundation;
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17+
*
18+
* Author: Mathieu Lacage <[email protected]>
19+
*/
20+
#include "custom-onoff-helper.h"
21+
#include "ns3/inet-socket-address.h"
22+
#include "ns3/packet-socket-address.h"
23+
#include "ns3/string.h"
24+
#include "ns3/data-rate.h"
25+
#include "ns3/uinteger.h"
26+
#include "ns3/names.h"
27+
#include "ns3/random-variable-stream.h"
28+
#include "ns3/onoff-application.h"
29+
30+
namespace ns3 {
31+
32+
CustomOnOffHelper::CustomOnOffHelper (std::string protocol, Address address)
33+
{
34+
m_factory.SetTypeId ("ns3::OnOffApplication");
35+
m_factory.Set ("Protocol", StringValue (protocol));
36+
m_factory.Set ("Remote", AddressValue (address));
37+
}
38+
39+
void
40+
CustomOnOffHelper::SetAttribute (std::string name, const AttributeValue &value)
41+
{
42+
m_factory.Set (name, value);
43+
}
44+
45+
ApplicationContainer
46+
CustomOnOffHelper::Install (Ptr<Node> node) const
47+
{
48+
return ApplicationContainer (InstallPriv (node));
49+
}
50+
51+
ApplicationContainer
52+
CustomOnOffHelper::Install (std::string nodeName) const
53+
{
54+
Ptr<Node> node = Names::Find<Node> (nodeName);
55+
return ApplicationContainer (InstallPriv (node));
56+
}
57+
58+
ApplicationContainer
59+
CustomOnOffHelper::Install (NodeContainer c) const
60+
{
61+
ApplicationContainer apps;
62+
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
63+
{
64+
apps.Add (InstallPriv (*i));
65+
}
66+
67+
return apps;
68+
}
69+
70+
Ptr<Application>
71+
CustomOnOffHelper::InstallPriv (Ptr<Node> node) const
72+
{
73+
Ptr<Application> app = m_factory.Create<Application> ();
74+
node->AddApplication (app);
75+
76+
return app;
77+
}
78+
79+
int64_t
80+
CustomOnOffHelper::AssignStreams (NodeContainer c, int64_t stream)
81+
{
82+
int64_t currentStream = stream;
83+
Ptr<Node> node;
84+
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
85+
{
86+
node = (*i);
87+
for (uint32_t j = 0; j < node->GetNApplications (); j++)
88+
{
89+
Ptr<OnOffApplication> onoff = DynamicCast<OnOffApplication> (node->GetApplication (j));
90+
if (onoff)
91+
{
92+
currentStream += onoff->AssignStreams (currentStream);
93+
}
94+
}
95+
}
96+
return (currentStream - stream);
97+
}
98+
99+
void
100+
CustomOnOffHelper::SetConstantRate (DataRate dataRate, uint32_t packetSize)
101+
{
102+
m_factory.Set ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1000]"));
103+
m_factory.Set ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
104+
m_factory.Set ("DataRate", DataRateValue (dataRate));
105+
m_factory.Set ("PacketSize", UintegerValue (packetSize));
106+
}
107+
108+
} // namespace ns3

deprecated/custom-onoff-helper.h

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#ifndef CUSTOM_ONOFF_HELPER_H
2+
#define CUSTOM_ONOFF_HELPER_H
3+
4+
#include <stdint.h>
5+
#include <string>
6+
#include "ns3/object-factory.h"
7+
#include "ns3/address.h"
8+
#include "ns3/attribute.h"
9+
#include "ns3/net-device.h"
10+
#include "ns3/node-container.h"
11+
#include "ns3/application-container.h"
12+
#include "ns3/onoff-application.h"
13+
14+
namespace ns3 {
15+
16+
class DataRate;
17+
18+
/**
19+
* \ingroup onoff
20+
* \brief A helper to make it easier to instantiate an ns3::CustomOnOffApplication
21+
* on a set of nodes.
22+
*/
23+
class CustomOnOffHelper
24+
{
25+
public:
26+
/**
27+
* Create an CustomOnOffHelper to make it easier to work with CustomOnOffApplications
28+
*
29+
* \param protocol the name of the protocol to use to send traffic
30+
* by the applications. This string identifies the socket
31+
* factory type used to create sockets for the applications.
32+
* A typical value would be ns3::UdpSocketFactory.
33+
* \param address the address of the remote node to send traffic
34+
* to.
35+
*/
36+
CustomOnOffHelper (std::string protocol, Address address);
37+
38+
/**
39+
* Helper function used to set the underlying application attributes.
40+
*
41+
* \param name the name of the application attribute to set
42+
* \param value the value of the application attribute to set
43+
*/
44+
void SetAttribute (std::string name, const AttributeValue &value);
45+
46+
/**
47+
* Helper function to set a constant rate source. Equivalent to
48+
* setting the attributes OnTime to constant 1000 seconds, OffTime to
49+
* constant 0 seconds, and the DataRate and PacketSize set accordingly
50+
*
51+
* \param dataRate DataRate object for the sending rate
52+
* \param packetSize size in bytes of the packet payloads generated
53+
*/
54+
void SetConstantRate (DataRate dataRate, uint32_t packetSize = 512);
55+
56+
/**
57+
* Install an ns3::CustomOnOffApplication on each node of the input container
58+
* configured with all the attributes set with SetAttribute.
59+
*
60+
* \param c NodeContainer of the set of nodes on which an CustomOnOffApplication
61+
* will be installed.
62+
* \returns Container of Ptr to the applications installed.
63+
*/
64+
ApplicationContainer Install (NodeContainer c) const;
65+
66+
/**
67+
* Install an ns3::CustomOnOffApplication on the node configured with all the
68+
* attributes set with SetAttribute.
69+
*
70+
* \param node The node on which an CustomOnOffApplication will be installed.
71+
* \returns Container of Ptr to the applications installed.
72+
*/
73+
ApplicationContainer Install (Ptr<Node> node) const;
74+
75+
/**
76+
* Install an ns3::CustomOnOffApplication on the node configured with all the
77+
* attributes set with SetAttribute.
78+
*
79+
* \param nodeName The node on which an CustomOnOffApplication will be installed.
80+
* \returns Container of Ptr to the applications installed.
81+
*/
82+
ApplicationContainer Install (std::string nodeName) const;
83+
84+
/**
85+
* Assign a fixed random variable stream number to the random variables
86+
* used by this model. Return the number of streams (possibly zero) that
87+
* have been assigned. The Install() method should have previously been
88+
* called by the user.
89+
*
90+
* \param stream first stream index to use
91+
* \param c NodeContainer of the set of nodes for which the CustomOnOffApplication
92+
* should be modified to use a fixed stream
93+
* \return the number of stream indices assigned by this helper
94+
*/
95+
int64_t AssignStreams (NodeContainer c, int64_t stream);
96+
97+
private:
98+
/**
99+
* Install an ns3::CustomOnOffApplication on the node configured with all the
100+
* attributes set with SetAttribute.
101+
*
102+
* \param node The node on which an CustomOnOffApplication will be installed.
103+
* \returns Ptr to the application installed.
104+
*/
105+
Ptr<Application> InstallPriv (Ptr<Node> node) const;
106+
107+
ObjectFactory m_factory; //!< Object factory.
108+
};
109+
110+
} // namespace ns3
111+
112+
#endif // CUSTOM_ONOFF_HELPER_H

doc/changes.patch

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
diff --git a/src/network/utils/bit-deserializer.h b/src/network/utils/bit-deserializer.h
2+
index 01d5c2a15..4844788b4 100644
3+
--- a/src/network/utils/bit-deserializer.h
4+
+++ b/src/network/utils/bit-deserializer.h
5+
@@ -23,6 +23,7 @@
6+
7+
#include <vector>
8+
#include <deque>
9+
+#include <cstdint> // 添加这行以引入 uint8_t 和 uint64_t 类型
10+
11+
namespace ns3 {
12+
13+
diff --git a/src/network/utils/bit-serializer.h b/src/network/utils/bit-serializer.h
14+
index acaf1feaf..e5bbe4ec0 100644
15+
--- a/src/network/utils/bit-serializer.h
16+
+++ b/src/network/utils/bit-serializer.h
17+
@@ -22,6 +22,7 @@
18+
#define BITSERIALIZER_H_
19+
20+
#include <vector>
21+
+#include <cstdint> // 添加这行以引入 uint8_t 和 uint64_t 类型
22+
23+
namespace ns3 {
24+
25+
diff --git a/src/wifi/model/block-ack-type.cc b/src/wifi/model/block-ack-type.cc
26+
index e47387e5a..a62f3351f 100644
27+
--- a/src/wifi/model/block-ack-type.cc
28+
+++ b/src/wifi/model/block-ack-type.cc
29+
@@ -20,6 +20,7 @@
30+
31+
#include "block-ack-type.h"
32+
#include "ns3/fatal-error.h"
33+
+#include <cstdint> // 添加这行以引入 uint8_t 和 uint64_t 类型
34+
35+
namespace ns3 {
36+
37+
diff --git a/src/wifi/model/block-ack-type.h b/src/wifi/model/block-ack-type.h
38+
index 07b21fb43..2e32689f8 100644
39+
--- a/src/wifi/model/block-ack-type.h
40+
+++ b/src/wifi/model/block-ack-type.h
41+
@@ -23,6 +23,7 @@
42+
43+
#include <ostream>
44+
#include <vector>
45+
+#include <cstdint> // 添加这行以引入 uint8_t 和 uint64_t 类型
46+
47+
namespace ns3 {
48+

doc/examples.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# P4sim examples
2+

doc/waf.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
```bash
3+
pkg-config --list-all | grep xxx
4+
simple_switch simple switch - Behavioral Model Target Simple Switch
5+
bm BMv2 - Behavioral Model
6+
boost_system Boost System - Boost System
7+
```

0 commit comments

Comments
 (0)