Is it possible to interact from the BMv2 mininet host to Ganache (Ethereum) server?

Hi, this topic/problem is part of my Master’s degree project, which I am currently facing. The project is about doing different types of pre-processing in the P4 switch to compress IoT Data and then store them in the Blockchain as also being sent to the IoT Cloud simultaneously.

The problem relies on being unable to connect/send data from my Mininet hosts to the Blockchain Ethereum (Ganache), which runs outside the Mininet environment.

I will describe what I am doing and the outcomes to make it easier to understand. English is not my native language, so feel free to ask if anything is not understandable.

Consider Ethereum (Ganache) is already up and running outside Mininet on the address: HTTP://

After deploying my BMv2 mininet network, I open h1;
Inside the h1, I run my Python script containing (It is working fine outside Mininet):

from web3 import Web3 (I’ve installed web3 locally)

##For connecting to ganache##
w3 = Web3(Web3.HTTPProvider(“”))
chain_id = 1337

The rest of the script interacts with Smart Contract

The Ganache has the following configuration and possible options:

I get the following response after executing the script:

This is the s1.log after executing the script:

It may be possible to make the h1 somehow interact with the Ethereum (Ganache) by changing its interface or IP (I don’t know how). However, this problem I am facing is just the first step to see if I can talk to the Ethereum (Ganache), my second move is going to put this script inside a, and for every received packet, I would take some headers, as strings and send them to Ethereum (Ganache) as transactions. This last observation is necessary to be said as If somehow h1 can communicate outside Mininet with Ethereum (Ganache), I would still need also to be able to receive packets from other hosts inside the Mininet.

I solved this problem by using sudo on the so that I could sniff on the Mininet host interface I wanted while being outside of it via the scapy library. Now I am configuring the Ethereum (Ganache) to accept all the packets as transactions per second.

1 Like

This is definitely an interesting way to use the behavioral model. Is this a particular project you are working on that is publicly available?

Keep in mind that the behavioral model simple switch is not written to be fast. This might influence your measurements.

Is this a particular project you are working on that is publicly available?

No, it was created solely as my thesis/project for my Master’s degree at Universidade Federal do Rio Grande do Sul (UFRGS) based on some papers about leveraging P4 to optimize IoT Data transmission and + the Blockchain scalability issue of not accepting/handling well lot of incoming data without deep planning.

I will be submitting it to a conference by the end of the year, so by that date, I will certainly publicly publish it on Git Hub. Is this forum also a good place to share once it’s ready?

I am aware of the behavioral model’s simple switch limitations. One of the last steps of this project is to test it against microbenchmarks about switch memory, usage, ALUs, etc., in an actual Tofino switch at my University.

Until now, I’ve only implemented some aggregation and filtration pre-processing and will most likely need help from this forum users with future issues/questions.

1 Like

Sure! Also the mailing list Join « P4 – Language Consortium.