Skip to content

added steps to run example in ns-3#713

Open
Vineet1101 wants to merge 5 commits intop4lang:masterfrom
Vineet1101:master
Open

added steps to run example in ns-3#713
Vineet1101 wants to merge 5 commits intop4lang:masterfrom
Vineet1101:master

Conversation

@Vineet1101
Copy link
Contributor

No description provided.

@Vineet1101
Copy link
Contributor Author

@jafingerhut @fruffy I have added the steps to run p4 programs inside ns-3


---
## 5. Run an Example
Before running the example you need to **copy and paste** that particular example inside `ns3's scratch` folder then you can run a built-in example using:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the commands to copy exampleA? In other words, I would provide the exact set of commands that you need to follow at each step.

Copy link
Contributor Author

@Vineet1101 Vineet1101 Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added more details can you review it and tell if anything else is required

@Vineet1101 Vineet1101 requested a review from Dscano February 15, 2026 10:09
Copy link
Contributor

@Dscano Dscano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a clear explanation of why those changes are needed and what is the purpose of this PR?

```

---
## 4. Running an example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why section 4 and 5 have the same name? Which should be the difference?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vineet1101 why this?

Copy link
Contributor Author

@Vineet1101 Vineet1101 Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to write Prepare an example but forgot to replace that


---
## 5. Run an Example
Before running the example you need to **copy and paste** that particular example inside `ns3's scratch` folder then you can run a example using:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add also the commands for copy paste the execise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are just ctrl+c and ctrl+v. Should I add them??

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m suggesting you add a bash commands to do that, so people can easily copy and paste the example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 91 to 94
std::string p4JsonPath = "/home/p4/workdir/ns3.39/contrib/p4sim/examples/p4src/p4_basic/p4_basic.json";
std::string flowTableDirPath ="/home/p4/workdir/ns3.39/contrib/p4sim/examples/p4src/p4_basic/";// path to flow table folder where all flow tables are located.
std::string topoInput ="/home/p4/workdir/ns3.39/contrib/p4sim/examples/p4src/p4_basic/topo.txt";//path to topo file that the example uses
// This is for p4-basic-controller.cc file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why previusly you remove this line and now you added them again?

@Vineet1101
Copy link
Contributor Author

Can you provide a clear explanation of why those changes are needed and what is the purpose of this PR?

ok the previous PR was for installing ns-3 and p4sim and this PR is for adding more detailed instructions on how to run a program inside ns-3

```

---
## 4. Running an example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vineet1101 why this?

Signed-off-by: Vineet1101 <Vineetgoel692@gmail.com>
Signed-off-by: Vineet1101 <Vineetgoel692@gmail.com>
Signed-off-by: Vineet1101 <Vineetgoel692@gmail.com>
@Vineet1101
Copy link
Contributor Author

@Dscano I have added bash script for copy and paste commands and also added more and clear details for running an example. Please review it and tell if anything else is needed

@Vineet1101 Vineet1101 requested a review from Dscano February 17, 2026 03:20
Signed-off-by: Vineet1101 <Vineetgoel692@gmail.com>
Copy link
Contributor

@Dscano Dscano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you combine sections 4 and 5 into a single section, section 4, and titled it "Run a Simulation Example".

Signed-off-by: Vineet1101 <Vineetgoel692@gmail.com>
@Vineet1101
Copy link
Contributor Author

Can you combine sections 4 and 5 into a single section, section 4, and titled it "Run a Simulation Example".

done

@Vineet1101 Vineet1101 requested a review from Dscano February 17, 2026 15:28
```

### 7. Run a Simulation Example
### 7. Run a Simulation Example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have repeated twice section 7

Copy link
Contributor Author

@Vineet1101 Vineet1101 Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes because the original P4Sim documentation repeats this section so I kept it that way. Should I remove one and make a reference to the other??

@Dscano
Copy link
Contributor

Dscano commented Feb 17, 2026

@jafingerhut can you merge this PR, I'm not authorized to push it.

@jafingerhut
Copy link
Collaborator

@jafingerhut can you merge this PR, I'm not authorized to push it.

I am authorized to do so, but I would really appreciate if the submitter would consider simplifying the steps to run an example, based upon a comment I have made twice so far:

Without copying any files at all after installing ns3, I was able to run the command below, and it gave lots of output that seem like it did something:

./ns3 run contrib/p4sim/examples/p4-basic-controller.cc

If that works for you, too, without copying any files, I would recommend giving the command above as an example, and OMIT all of the instructions for copying files, running sed, etc. They seem unnecessarily complicated to me, if the single command above works.

@Vineet1101
Copy link
Contributor Author

@jafingerhut can you merge this PR, I'm not authorized to push it.

I am authorized to do so, but I would really appreciate if the submitter would consider simplifying the steps to run an example, based upon a comment I have made twice so far:

Without copying any files at all after installing ns3, I was able to run the command below, and it gave lots of output that seem like it did something:

./ns3 run contrib/p4sim/examples/p4-basic-controller.cc

If that works for you, too, without copying any files, I would recommend giving the command above as an example, and OMIT all of the instructions for copying files, running sed, etc. They seem unnecessarily complicated to me, if the single command above works.

@jafingerhut There is a difference between the two approaches:

When an example is placed in the scratch folder, ns-3 automatically handles building the file and linking dependencies, so it can be run directly. This approach is convenient for quick testing and prototyping.

When an example is placed inside a module directory such as contrib/p4sim/examples, it must be declared in the corresponding CMakeLists.txt file. This allows ns-3 to build and integrate it properly. The reason p4-basic-controller.cc can be run directly is that it is already declared in the CMakeLists.txt file. This is the intended approach when contributing examples to the repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments