Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a topology #44

Open
sksdk opened this issue Jul 4, 2023 · 1 comment
Open

How to create a topology #44

sksdk opened this issue Jul 4, 2023 · 1 comment

Comments

@sksdk
Copy link

sksdk commented Jul 4, 2023

Hello, I'm sorry to bother you. I used the following program to build the topology, but I don't know what the error message means. Can you help me with it?

import json
import argparse
import networkx

topo_base = {
"p4_src": "collect_flow.p4",
"cli": True,
"pcap_dump": True,
"enable_log": True,
"exec_scripts": [
{
"cmd": "python routing-controller.py",
"reboot_run": True
}
],
"topology": {
"assignment_strategy": "l3",
"default":
{
"bw": 10,
"queue_length": 30000
},
}
}

def create_clos_topo(num_hosts=32,num_switches=4):
topo_base["topology"]["links"] = []

# connect hosts with switches
for i in range(1, num_hosts-15):
    topo_base["topology"]["links"].append(["h{}".format(i),"s{}".format(1)])

for i in range(num_hosts-15,num_hosts+1):
    topo_base["topology"]["links"].append(["h{}".format(i), "s{}".format(2)])

# connect switches
topo_base["topology"]["links"].append(["s{}".format(1), "s{}".format(3)])
topo_base["topology"]["links"].append(["s{}".format(1), "s{}".format(3)])
topo_base["topology"]["links"].append(["s{}".format(2), "s{}".format(3)])
topo_base["topology"]["links"].append(["s{}".format(2), "s{}".format(3)])
topo_base["topology"]["links"].append(["s{}".format(2), "s{}".format(4)])
topo_base["topology"]["links"].append(["s{}".format(2), "s{}".format(4)])

topo_base["topology"]["hosts"] = {"h{0}".format(i): {} for i in range(1, num_hosts+1)}
topo_base["topology"]["switches"] = {"s{0}".format(i): {} for i in range(1, num_switches+1)}

def main():
pass

if name == 'main':
parser = argparse.ArgumentParser()
parser.add_argument('--output_name', type=str, required=False, default="clos_four_switches_4.json")
# parser.add_argument('-n', type=str, required=False, default=4)
# parser.add_argument('-d', type=str, required=False, default=2)
args = parser.parse_args()
# create_clos_topo(int(args.d), int(args.n))
create_clos_topo(32,4)
json.dump(topo_base, open(args.output_name, "w"), sort_keys=True, indent=2)

image
Reading JSON configuration file...
"l3" assignment strategy selected.
Traceback (most recent call last):
File "/usr/local/bin/p4run", line 11, in
load_entry_point('p4utils', 'console_scripts', 'p4run')()
File "/home/p4/p4-tools/p4-utils/p4utils/p4run.py", line 739, in main
verbosity=args.verbosity)
File "/home/p4/p4-tools/p4-utils/p4utils/p4run.py", line 341, in init
self.l3()
File "/home/p4/p4-tools/p4-utils/p4utils/mininetlib/network_API.py", line 2650, in l3
assert not self.is_multigraph()
AssertionError

@edgar-costa
Copy link
Contributor

Hi @sksdk

I can have a look, but can you please format all the json and python code together and tell me what is what. Or show me the final version of your jsnon topology. Like this is a bit hard to parse.

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

No branches or pull requests

2 participants