You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I tried to create a topology using mesh Wi-Fi and P4 AP, but it failed to pass the ping test at all during the test. After opening the Wireshark program, I found that the source MAC address and destination MAC address will become the same in ping test.
The topology and P4 code are as follows:
basic.p4
/* -*- P4_16 -*- */#include<core.p4>#include<v1model.p4>constbit<16>TYPE_IPV4=0x800;
/************************************************************************************************ H E A D E R S ************************************************************************************************************/typedefbit<9>egressSpec_t;
typedefbit<48>macAddr_t;
typedefbit<32>ip4Addr_t;
headerethernet_t {
macAddr_tdstAddr;
macAddr_tsrcAddr;
bit<16>etherType;
}
headeripv4_t {
bit<4>version;
bit<4>ihl;
bit<8>diffserv;
bit<16>totalLen;
bit<16>identification;
bit<3>flags;
bit<13>fragOffset;
bit<8>ttl;
bit<8>protocol;
bit<16>hdrChecksum;
ip4Addr_tsrcAddr;
ip4Addr_tdstAddr;
}
structmetadata {
/* empty */
}
structheaders {
ethernet_tethernet;
ipv4_tipv4;
}
/************************************************************************************************ P A R S E R ************************************************************************************************************/parserMyParser(packet_inpacket,
outheadershdr,
inoutmetadatameta,
inoutstandard_metadata_tstandard_metadata) {
statestart {
packet.extract(hdr.ethernet);
transitionselect(hdr.ethernet.etherType){
TYPE_IPV4: ipv4;
default: accept;
}
}
stateipv4 {
packet.extract(hdr.ipv4);
transitionaccept;
}
}
/************************************************************************************* C H E C K S U M V E R I F I C A T I O N **************************************************************************************/controlMyVerifyChecksum(inoutheadershdr, inoutmetadatameta) {
apply { }
}
/*************************************************************************************** I N G R E S S P R O C E S S I N G ********************************************************************************************/controlMyIngress(inoutheadershdr,
inoutmetadatameta,
inoutstandard_metadata_tstandard_metadata) {
actiondrop() {
mark_to_drop(standard_metadata);
}
actionipv4_forward(macAddr_tdstAddr, egressSpec_tport) {
//set the src mac address as the previous dst, this is not correct right?hdr.ethernet.srcAddr=hdr.ethernet.dstAddr;
//set the destination mac address that we got from the match in the tablehdr.ethernet.dstAddr=dstAddr;
//set the output port that we also get from the tablestandard_metadata.egress_spec=port;
//decrease ttl by 1hdr.ipv4.ttl=hdr.ipv4.ttl-1;
}
tableipv4_lpm {
key= {
hdr.ipv4.dstAddr: exact;
}
actions= {
ipv4_forward;
drop;
NoAction;
}
size=1024;
default_action=NoAction();
}
apply {
//only if IPV4 the rule is applied. Therefore other packets will not be forwarded.if (hdr.ipv4.isValid()){
ipv4_lpm.apply();
}
}
}
/***************************************************************************************** E G R E S S P R O C E S S I N G ********************************************************************************************/controlMyEgress(inoutheadershdr,
inoutmetadatameta,
inoutstandard_metadata_tstandard_metadata) {
apply { }
}
/************************************************************************************** C H E C K S U M C O M P U T A T I O N ***************************************************************************************/controlMyComputeChecksum(inoutheadershdr, inoutmetadatameta) {
apply {
update_checksum(
hdr.ipv4.isValid(),
{ hdr.ipv4.version,
hdr.ipv4.ihl,
hdr.ipv4.diffserv,
hdr.ipv4.totalLen,
hdr.ipv4.identification,
hdr.ipv4.flags,
hdr.ipv4.fragOffset,
hdr.ipv4.ttl,
hdr.ipv4.protocol,
hdr.ipv4.srcAddr,
hdr.ipv4.dstAddr },
hdr.ipv4.hdrChecksum,
HashAlgorithm.csum16);
}
}
/************************************************************************************************ D E P A R S E R ********************************************************************************************************/controlMyDeparser(packet_outpacket, inheadershdr) {
apply {
//parsed headers have to be added again into the packet.packet.emit(hdr.ethernet);
packet.emit(hdr.ipv4);
}
}
/************************************************************************************************ S W I T C H ********************************************************************************************************///switch architectureV1Switch(
MyParser(),
MyVerifyChecksum(),
MyIngress(),
MyEgress(),
MyComputeChecksum(),
MyDeparser()
) main;
Hi, I tried to create a topology using mesh Wi-Fi and P4 AP, but it failed to pass the ping test at all during the test. After opening the Wireshark program, I found that the source MAC address and destination MAC address will become the same in ping test.
The topology and P4 code are as follows:
basic.p4
commands_ap1.txt
commands_ap2.txt
p4.py
The virtual environment uses the virtual machine provided by the official GitHub.
Thanks!!
The text was updated successfully, but these errors were encountered: