Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored to ns-3.42 version #99

Open
wants to merge 2 commits into
base: app-ns-3.36+
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ns3-gym change history
## 1.1.0 - 2024-09-01 :: by [rogerio-silva](https://github.com/rogerio-silva)
- Added support for ns-3.42
* ‘ns3::TestSuite::UNIT’ is deprecated: Use ‘Type::UNIT’ instead
* ‘ns3::TestCase::QUICK’ is deprecated: Use ‘Duration::QUICK’ instead
* ‘class ns3::InetSocketAddress’ has no member named ‘SetTos’: Refactored the code by adding a socket and setting the TOS field using the SetIpTos method
* Refatored the `linear-mesh` and `linear-mesh-2` examples code in the following way:
```c++
Ptr<Socket> socket = Socket::CreateSocket (srcNode, UdpSocketFactory::GetTypeId ());
socket->SetIpTos (0x70); // AC_BE
# ...
source.SetAttribute ("Socket", PointerValue (socket));
```
## [1.0.0] - 2021-06-01
- Custom implementation
2 changes: 1 addition & 1 deletion NS3-VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release ns-3.36
release ns-3.42
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ns3-gym
============
*Updated version of ns3-gym for ns-3 release ns-3.42.

[OpenAI Gym](https://gym.openai.com/) is a toolkit for reinforcement learning (RL) widely used in research. The network simulator [ns-3](https://www.nsnam.org/) is the de-facto standard for academic and industry studies in the areas of networking protocols and communication technologies. ns3-gym is a framework that integrates both OpenAI Gym and ns-3 in order to encourage usage of RL in networking research.

Expand All @@ -26,7 +27,7 @@ apt-get install pkg-config
cd ./contrib
git clone https://github.com/tkn-tub/ns3-gym.git ./opengym
cd opengym/
git checkout app-ns-3.36+
git checkout app-ns-3.42
```
Check [working with cmake](https://www.nsnam.org/docs/manual/html/working-with-cmake.html)

Expand Down
7 changes: 4 additions & 3 deletions examples/linear-mesh-2/sim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,13 @@ main (int argc, char *argv[])
Ipv4Address dest_ip_addr = dest_ipv4_int_addr.GetLocal ();

InetSocketAddress destAddress (dest_ip_addr, port);
destAddress.SetTos (0x70); //AC_BE
Ptr<Socket> socket = Socket::CreateSocket (srcNode, UdpSocketFactory::GetTypeId ());
socket->SetIpTos (0x70); // AC_BE
UdpClientHelper source (destAddress);
source.SetAttribute ("MaxPackets", UintegerValue (pktPerSec * simulationTime));
source.SetAttribute ("PacketSize", UintegerValue (payloadSize));
Time interPacketInterval = Seconds (1.0/pktPerSec);
source.SetAttribute ("Interval", TimeValue (interPacketInterval)); //packets/s
source.SetAttribute ("Interval", TimeValue (Seconds (1.0 / pktPerSec))); // packets/s
source.SetAttribute ("Socket", PointerValue (socket));

ApplicationContainer sourceApps = source.Install (srcNode);
sourceApps.Start (Seconds (0.0));
Expand Down
7 changes: 4 additions & 3 deletions examples/linear-mesh/sim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,13 @@ main (int argc, char *argv[])
Ipv4Address dest_ip_addr = dest_ipv4_int_addr.GetLocal ();

InetSocketAddress destAddress (dest_ip_addr, port);
destAddress.SetTos (0x70); //AC_BE
Ptr<Socket> socket = Socket::CreateSocket (srcNode, UdpSocketFactory::GetTypeId ());
socket->SetIpTos (0x70); // AC_BE
UdpClientHelper source (destAddress);
source.SetAttribute ("MaxPackets", UintegerValue (pktPerSec * simulationTime));
source.SetAttribute ("PacketSize", UintegerValue (payloadSize));
Time interPacketInterval = Seconds (1.0/pktPerSec);
source.SetAttribute ("Interval", TimeValue (interPacketInterval)); //packets/s
source.SetAttribute ("Interval", TimeValue (Seconds (1.0 / pktPerSec))); // packets/s
source.SetAttribute ("Socket", PointerValue (socket));

ApplicationContainer sourceApps = source.Install (srcNode);
sourceApps.Start (Seconds (0.0));
Expand Down
4 changes: 3 additions & 1 deletion model/ns3gym/ns3gym/start_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def start_sim_script(port=5555, sim_seed=0, sim_args={}, debug=False):

os.chdir(base_ns3_dir)

ns3_string = ns3_path + ' run "' + sim_script_name
# Add '\sim' to the path to run the ns-3 simulation script
# ns3_string = ns3_path + ' run "' + sim_script_name
ns3_string = ns3_path + ' run "' + sim_script_name + '/sim'

if port:
ns3_string += ' --openGymPort=' + str(port)
Expand Down
4 changes: 2 additions & 2 deletions test/opengym-test-suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ class OpengymTestSuite : public TestSuite
};

OpengymTestSuite::OpengymTestSuite ()
: TestSuite ("opengym", UNIT)
: TestSuite ("opengym", Type::UNIT)
{
// TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER
AddTestCase (new OpengymTestCase1, TestCase::QUICK);
AddTestCase (new OpengymTestCase1, Duration::QUICK);
}

// Do not forget to allocate an instance of this TestSuite
Expand Down