Comments (5)
It seems that:
- you might not have declared the
cpu_in
header, missing declaration:struct headers_t { ( . . . ) cpu_in_t cpu_in; }
- or, that you probably have to refer to it as
hdr.cpu_in.ingress
- or, if this is a variable, you might have also not declared it:
bit<n> cpu_in;
Regards,
from ngsdn-tutorial.
Hi,
My recommendation is that your first complete the P4 tutorial: https://github.com/p4lang/tutorials/. You will most likely feel lost in most exercises of NG SDN repo without having a basic understanding of P4. That tutorial will get you up to date in the language to some extent.
In terms of your problem, I was just writing some general code, so my examples will probably not work by just copy pasting it. In your case, the header is already declared (as per your link exercise). So do not modify this line:
struct parsed_headers_t {
...
cpu_in_header_t cpu_in;
...
}
According to the exercise and your error I guess what you are trying to do is complete this part of the exercise:
if (standard_metadata.egress_port == CPU_PORT) {
// *** TODO EXERCISE 4
// Implement logic such that if the packet is to be forwarded to the
// CPU port, e.g., if in ingress we matched on the ACL table with
// action send/clone_to_cpu...
// 1. Set cpu_in header as valid
// 2. Set the cpu_in.ingress_port field to the original packet's
// ingress port (standard_metadata.ingress_port).
}
In this case you need to:
- use
setValid()
to set thecpu_in
header valid.
(info: https://p4.org/p4-spec/docs/P4-16-v1.2.1.html#sec-ops-on-hdrs)
- Assign the
ingress_port
field the packet's ingress port (which is stored instandard_metadata
asingress_port
, i.e.standard_metadata.ingress_port
) tocpu_in
'singress_port
field. That is:hdr.cpu_in.ingress_port
equalsstandard_metadata.ingress_port
;
To refer to the cpu_in
header be sure you refer to it as hdr.cpu_in
always, else making it valid and assigning a value to its ingress_port
field will be wrong. I still recommend you to do the aforementioned P4 tutorial. I am letting you complete the exercise but if you need further help on the exact code let us know.
Regards,
from ngsdn-tutorial.
Hi,
Ok so let me explain some parts.
This part seems wrong for several reasons:
if (cpu_in.ingress_port.egress_port == 255) {
The original code wrote this line instead, and it should stay in the same way (AFAIK):
if (standard_metadata.egress_port == CPU_PORT) {
}
The errors also refers to the fact that cpu_in
should be written hdr.cpu_in
instead. Finally, ingress_port
is a field in the cpu_in
header but egress_port
is not, so a reference like cpu_in.ingress_port.egress_port
is wrong.
You should write something like:
if (standard_metadata.egress_port == CPU_PORT) {
hdr.cpu_in.setValid();
hdr.cpu_in.ingress_port = standard_metadata.ingress_port;
hdr.cpu_in._pad = 0;
}
This piece of code is trying express this: "So... if the output port that we defined in the Ingress part of the pipeline is the actual CPU port (so we are sending this packet to the controller), then we have to first make cpu_in
header valid because we need to prepend it to the packet. In this way, the controller can know the ingress_port
from which it came from."
Once again, I really encourage you to first complete the P4 tutorial from the link I sent in my previous message. I imagine it is difficult to understand some of the suggestions I make here.
If you need help to understand any exercises from the P4 tutorial you can preferably write to the P4 Slack or the p4-dev mailing list but you can write to me if you want to.
Regards,
from ngsdn-tutorial.
Hi
For clarity, I will try to point out some errors I see from your last message:
if (hdr.cpu_out.setValid()) {
should beif (hdr.cpu_out.isValid()) {
. setValid makes a header valid (so it can be deparsed and put into the wire) andisValid()
is letting you know if the header is valid or not.
2 and 3) Second error "Field cpu_in is not a member of structure header cpu_in_header_t" is confusing. You should have both defined and declared the cpu_in header. The following structures should be in your program:
@controller_header("packet_in")
header cpu_in_header_t {
port_num_t ingress_port;
bit<7> _pad;
}
and
struct parsed_headers_t {
cpu_out_header_t cpu_out;
cpu_in_header_t cpu_in;
// more headers
}
- The rest of the errors are difficult to clarify with the original code (you can attach a file in next messages you post, so we can debug it. It looks like, maybe, you might have not closed some structures or control blocks.
Don't worry about the time. I think you can come to anyone on the ONOS or P4 community and everyone will try to help as long as they have free time. I definitely think that the P4 tutorials will bring you the knowledge you need before you face the NG-SDN tutorials. It will be of much help.
Let us know if you need more help. You can close the issues if you want to.
Cheers,
from ngsdn-tutorial.
OK.
from ngsdn-tutorial.
Related Issues (20)
- How do I link ONOS by using mininet in my VM? HOT 4
- How to continuously change the forwarding flow table of the switch at intervals?
- help!QAQ
- Problem running the onos-cli in Excercise 3 HOT 6
- Ternary Match Issue in Advanced Branch
- Custom Topologies HOT 1
- Iperf UDP in Exercise 7 HOT 2
- New Entry in Table overriding the previous one
- pingall not working but ping works after Exercise 1
- How to create my own Topology? HOT 1
- Error pushing the netcfg to the controller HOT 5
- branch master - mininet container exit issue HOT 1
- [ASK] about to push p4 switch to ELK server HOT 1
- [ASK] how logging packet_in packet_out?
- Can I use the ONOS app in Excersice 5 for IPv4?
- Problem running make netcfg
- Are member variables in ONOS Component Classes thread safe and persistent. (Question)
- The mininet container cannot use xterm and wireshark HOT 5
- pushing netcfg when using IPv4 topology on mininet HOT 1
- Service Function Chaining Implementation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngsdn-tutorial.