# Deploying the working code on mininet on Fabric Testbed

**URL:** https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792
**Category:** Uncategorized
**Created:** [May 26, 2023, 11:36pm UTC](https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792 "2023-05-26T23:36:11Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![nagmat](https://avatars.discourse-cdn.com/v4/letter/n/e68b1a/32.png) [@nagmat](https://forum.p4.org/u/nagmat)
#### Post date: [May 26, 2023, 11:36pm UTC](https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792/1 "2023-05-26T23:36:12Z")

</div>

Dear Community,

I changed the basic.p4 ([tutorials/basic.p4 at master · p4lang/tutorials · GitHub](https://github.com/p4lang/tutorials/blob/master/exercises/basic/basic.p4)) file and patched (As an example I hardcoded consecutive numbers)

```auto
enq_timestamp 10
enq_depth 11
deq_timedelta 12
deq_depth 13

```

values onto the header.  
As you see in the picture the code works on mininet and I can get the INT data on the host2.

 ![pl_basic_output](https://us1.discourse-cdn.com/flex019/uploads/p4/original/1X/a8852457bb8b2381c7104953fd00b68381b78338.png).

Now I am deployin the same code on Fabric testbed using the same architecture, but after deployment, I am getting this error on switch 1 and 2:

```auto
Could not connect to any of [('127.0.0.1', 9090), ('127.0.0.1', 9090)]
Could not connect to thrift client on port 9090
Make sure the switch is running and that you have the right port

```

and getting :

```auto
OCI runtime exec failed: exec failed: unable to start container process: chdir to cwd ("/root/p4_tutorials/pl_basic") set in config.json failed: no such file or directory: unknown

```

on switch3.  
See below for the error messages on Fabric\_testbed deployment.

 ![fabric_testbed_deployment](https://us1.discourse-cdn.com/flex019/uploads/p4/original/1X/262c30cb899fe4d6a1a87aedd5aaa7801715f411.png)

Any advice is welcome. What may be the issue?

Kind regards,  
Nagmat

---

<div class="post-metadata">

### Author: ![DavideS](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/davides/32/120_2.png) [@DavideS](https://forum.p4.org/u/DavideS)
#### Post date: [May 28, 2023, 10:35am UTC](https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792/2 "2023-05-28T10:35:26Z")

</div>

Hi @nagmat,

Could you share with us the github link to the Fabric testbed ?  
Are you sure that you are running simple\_switch bmv2? maybe you are running simple\_switch\_grpc and I think that by default it does not have thrift server. I said that because from your mininet seems that you are running “grpc switches”.

---

<div class="post-metadata">

### Author: ![nagmat](https://avatars.discourse-cdn.com/v4/letter/n/e68b1a/32.png) [@nagmat](https://forum.p4.org/u/nagmat)
#### Post date: [May 29, 2023, 5:06pm UTC](https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792/3 "2023-05-29T17:06:14Z")

</div>

Dear Davide,

Thanks for the response.

Github link to Fabric testbed complex recipes : [jupyter-examples/fabric\_examples/complex\_recipes at master · fabric-testbed/jupyter-examples · GitHub](https://github.com/fabric-testbed/jupyter-examples/tree/master/fabric_examples/complex_recipes)

I am running bmv2 simple\_switch. The code I execute as follows :

```auto
docker exec -w /root/p4_tutorials/pl_basic fabric_p4 sh -c 'p4c --p4runtime-files basic.txt --target bmv2 --arch v1model basic.p4'

```

Kind regards,  
Nagmat

---

<div class="post-metadata">

### Author: ![DavideS](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/davides/32/120_2.png) [@DavideS](https://forum.p4.org/u/DavideS)
#### Post date: [May 29, 2023, 6:22pm UTC](https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792/4 "2023-05-29T18:22:24Z")

</div>

Hi but the command that you are running` -c 'p4c --p4runtime-files basic.txt --target bmv2 --arch v1model basic.p4'` is used by the p4 compile to compile the p4 code.  
This hsould be the code for running the switch `docker exec -d -it fabric_p4 sh -c 'simple_switch --interface 1@'${port1_iface}' --interface 2@'${port2_iface}' --interface 3@'${port3_iface}' /root/tutorials/exercises/basic_tunnel/basic_tunnel.json'`

---

<div class="post-metadata">

### Author: ![nagmat](https://avatars.discourse-cdn.com/v4/letter/n/e68b1a/32.png) [@nagmat](https://forum.p4.org/u/nagmat)
#### Post date: [May 29, 2023, 6:30pm UTC](https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792/5 "2023-05-29T18:30:41Z")

</div>

Hi,

Yeah, I am running that command too.

```auto
#!/bin/bash

#{
#port1_iface=$1
#port2_iface=$2
#port3_iface=$3
#ip_type=$4

ip_type=$1
#args="${@:2:2}"
ifaces="${@:2}"

# export http_proxy=socks5h://localhost:4567
# export https_proxy=socks5h://localhost:4567

echo Hello, FABRIC. From node `hostname -s`
sudo apt-get update
sudo apt-get install -y docker.io

if [$ip_type = 'IPv4']
then
  docker run -d -v /home/ubuntu/p4_tutorials:/root/p4_tutorials -it --cap-add=NET_ADMIN --privileged --name fabric_p4 registry.ipv4.docker.com/pruth/fabric-images:0.0.2j
else
  docker run -d -v /home/ubuntu/p4_tutorials:/root/p4_tutorials -it --cap-add=NET_ADMIN --privileged --name fabric_p4 registry.ipv6.docker.com/pruth/fabric-images:0.0.2j
  sed -i '/nameserver/d' /etc/resolv.conf
  echo nameserver 2a00:1098:2c::1 >> /etc/resolv.conf
  echo nameserver 2a01:4f8:c2c:123f::1 >> /etc/resolv.conf
  echo nameserver 2a00:1098:2b::1 >> /etc/resolv.conf
fi

sleep 10
NSPID=$(docker inspect --format='{{ .State.Pid }}' fabric_p4)
echo NSPID $NSPID

switch_interface_args=""
swtich_port=0
for iface in $ifaces; do
  ip link set dev $iface promisc on
  ip link set $iface netns $NSPID
  docker exec fabric_p4 ip link set dev $iface up
  docker exec fabric_p4 ip link set dev $iface promisc on
  docker exec fabric_p4 sysctl net.ipv6.conf.${iface}.disable_ipv6=1

  switch_interface_args="${switch_interface_args} --interface ${swtich_port}@${iface}"
  swtich_port=$((swtich_port+1))
done

echo Starting switch

docker exec -w /root/p4_tutorials/pl_basic fabric_p4 sh -c 'p4c --p4runtime-files basic.txt --target bmv2 --arch v1model basic.p4'
docker exec -d -it fabric_p4 sh -c 'simple_switch --interface 1@'${port1_iface}' --interface 2@'${port2_iface}' --interface 3@'${port3_iface}' /root/p4_tutorials/pl_basic/pod-topo/topology.json'

echo done!

```

I included the script here.

---

<div class="post-metadata">

### Author: ![DavideS](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/davides/32/120_2.png) [@DavideS](https://forum.p4.org/u/DavideS)
#### Post date: [May 29, 2023, 6:52pm UTC](https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792/6 "2023-05-29T18:52:15Z")

</div>

You can try to run the switch with this flag` --thrift-port portnumber` and then  
`./runtime_CLI.py --thrift-port portnumber`

---

<div class="post-metadata">

### Author: ![nagmat](https://avatars.discourse-cdn.com/v4/letter/n/e68b1a/32.png) [@nagmat](https://forum.p4.org/u/nagmat)
#### Post date: [May 29, 2023, 7:15pm UTC](https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792/7 "2023-05-29T19:15:07Z")

</div>

> [@DavideS](#):
>
> ch with t

I have tried but no luck. I am getting the same error :

```auto
root@9d3ec55cdce2:~# ./tools/behavioral-model/tools/runtime_CLI.py --thrift-port 9090
Could not connect to any of [('127.0.0.1', 9090), ('127.0.0.1', 9090)]
Could not connect to thrift client on port 9090
Make sure the switch is running and that you have the right port

```

---

<div class="post-metadata">

### Author: ![DavideS](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/davides/32/120_2.png) [@DavideS](https://forum.p4.org/u/DavideS)
#### Post date: [May 29, 2023, 7:18pm UTC](https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792/8 "2023-05-29T19:18:13Z")

</div>

whta you get if you do `ps -aux | grep simple_switch` ?

---

<div class="post-metadata">

### Author: ![nagmat](https://avatars.discourse-cdn.com/v4/letter/n/e68b1a/32.png) [@nagmat](https://forum.p4.org/u/nagmat)
#### Post date: [May 29, 2023, 7:21pm UTC](https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792/9 "2023-05-29T19:21:40Z")

</div>

I am getting :

```auto
root 116 0.0 0.0 3304 660 pts/1 S+ 15:21 0:00 grep --color=auto simple_switch

```

---

<div class="post-metadata">

### Author: ![DavideS](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/davides/32/120_2.png) [@DavideS](https://forum.p4.org/u/DavideS)
#### Post date: [May 29, 2023, 7:26pm UTC](https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792/10 "2023-05-29T19:26:46Z")

</div>

ok so this means that you are not running any process` simple_switch`, so in other word your are not running any switch.

---

<div class="post-metadata">

### Author: ![nagmat](https://avatars.discourse-cdn.com/v4/letter/n/e68b1a/32.png) [@nagmat](https://forum.p4.org/u/nagmat)
#### Post date: [May 29, 2023, 8:15pm UTC](https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792/11 "2023-05-29T20:15:02Z")

</div>

> [@DavideS](#):
>
> g any process` `

The one where basic\_tunnel is running I can see that simple\_switch is running.

```auto
root 99 0.0 0.0 2608 596 pts/1 Ss+ 15:39 0:00 sh -c simple_switch --interface 1@ --interface 2@ --interface 3@ /root/tutorials/exercises/basic_tunnel/basic_tunnel.json
root 105 0.0 0.1 722712 25428 pts/1 Sl+ 15:39 0:00 simple_switch --interface 1@ --interface 2@ --interface 3@ /root/tutorials/exercises/basic_tunnel/basic_tunnel.json
root 201 0.0 0.0 3304 660 pts/5 S+ 16:13 0:00 grep --color=auto simple_switch

```

What may be triggering simple\_switch not to run on my example?

---

<div class="post-metadata">

### Author: ![nagmat](https://avatars.discourse-cdn.com/v4/letter/n/e68b1a/32.png) [@nagmat](https://forum.p4.org/u/nagmat)
#### Post date: [June 20, 2023, 10:43pm UTC](https://forum.p4.org/t/deploying-the-working-code-on-mininet-on-fabric-testbed/792/12 "2023-06-20T22:43:17Z")

</div>

I resolved the issue :

It can be found here : [P4\_experiment\_Fabric/mri.MD at main · nagmat1/P4\_experiment\_Fabric · GitHub](https://github.com/nagmat1/P4_experiment_Fabric/blob/main/mri.MD)

I killed existing processes on the p4 switch, recompiled the program again and reloaded the switch.

Kind regards,  
Nagmat
