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

Is it able to disable the functionality to write the switch logging into a file? #65

Closed
fengkeyleaf opened this issue Nov 3, 2023 · 7 comments

Comments

@fengkeyleaf
Copy link

fengkeyleaf commented Nov 3, 2023

Good day,

I am testing my program with the Bmv2 model but the switch outputs the logging to a local log file, like s1.log, which will grow very large, like 8 ~ 9 GB, which would make the VM crash. So I wonder there is a way to turn off the logging? Or any recommended suggestions?

Thanks,

@jafingerhut
Copy link
Owner

Are you using the p4lang/tutorials Github repo code to run BMv2?

Are you running simple_switch_grpc command yourself, supplying all command line options?

Something else?

@fengkeyleaf
Copy link
Author

Are you using the p4lang/tutorials Github repo code to run BMv2?

Are you running simple_switch_grpc command yourself, supplying all command line options?

Something else?

Oh, sorry about not mentioning this.

I am using the tutorials Github repo code to run BMv2.

@jafingerhut
Copy link
Owner

I do not know how to do this off the top of my head. The tutorials repository has a fair amount of Python code that is executed when you do make run in the tutorials/utils directory, which uses a Python library provided by the Mininet package for creating the simulated networks of multiple switches and hosts. I am not familiar enough with that Mininet Python library and what options it provides to know what should be changed to avoid logging to file, but this line of code looks like it is related: https://github.com/p4lang/tutorials/blob/master/utils/run_exercise.py#L94

I did a quick experiment by locally editing the tutorials/utils/run_exercise.py file as shown in the diff output below, and when I did make run the next time it did not create any log files with names like logs/s1.log:

diff --git a/utils/run_exercise.py b/utils/run_exercise.py
index 44c8ff6..780131d 100755
--- a/utils/run_exercise.py
+++ b/utils/run_exercise.py
@@ -91,7 +91,7 @@ class ExerciseTopo(Topo):
             else:
                 # add default switch
                 switchClass = None
-            self.addSwitch(sw, log_file="%s/%s.log" %(log_dir, sw), cls=switchClass)
+            self.addSwitch(sw, cls=switchClass)
 
         for link in host_links:
             host_name = link['node1']

@fengkeyleaf
Copy link
Author

I do not know how to do this off the top of my head. The tutorials repository has a fair amount of Python code that is executed when you do make run in the tutorials/utils directory, which uses a Python library provided by the Mininet package for creating the simulated networks of multiple switches and hosts. I am not familiar enough with that Mininet Python library and what options it provides to know what should be changed to avoid logging to file, but this line of code looks like it is related: https://github.com/p4lang/tutorials/blob/master/utils/run_exercise.py#L94

I did a quick experiment by locally editing the tutorials/utils/run_exercise.py file as shown in the diff output below, and when I did make run the next time it did not create any log files with names like logs/s1.log:

diff --git a/utils/run_exercise.py b/utils/run_exercise.py
index 44c8ff6..780131d 100755
--- a/utils/run_exercise.py
+++ b/utils/run_exercise.py
@@ -91,7 +91,7 @@ class ExerciseTopo(Topo):
             else:
                 # add default switch
                 switchClass = None
-            self.addSwitch(sw, log_file="%s/%s.log" %(log_dir, sw), cls=switchClass)
+            self.addSwitch(sw, cls=switchClass)
 
         for link in host_links:
             host_name = link['node1']

Thanks , I will give a try to see if it works or not.

@fengkeyleaf
Copy link
Author

I do not know how to do this off the top of my head. The tutorials repository has a fair amount of Python code that is executed when you do make run in the tutorials/utils directory, which uses a Python library provided by the Mininet package for creating the simulated networks of multiple switches and hosts. I am not familiar enough with that Mininet Python library and what options it provides to know what should be changed to avoid logging to file, but this line of code looks like it is related: https://github.com/p4lang/tutorials/blob/master/utils/run_exercise.py#L94

I did a quick experiment by locally editing the tutorials/utils/run_exercise.py file as shown in the diff output below, and when I did make run the next time it did not create any log files with names like logs/s1.log:

diff --git a/utils/run_exercise.py b/utils/run_exercise.py
index 44c8ff6..780131d 100755
--- a/utils/run_exercise.py
+++ b/utils/run_exercise.py
@@ -91,7 +91,7 @@ class ExerciseTopo(Topo):
             else:
                 # add default switch
                 switchClass = None
-            self.addSwitch(sw, log_file="%s/%s.log" %(log_dir, sw), cls=switchClass)
+            self.addSwitch(sw, cls=switchClass)
 
         for link in host_links:
             host_name = link['node1']

It seems that the switch outputs the logging into another file named p4s.s1.log, which is located in /tmp. I think it's very difficult to turn the logging off at this point.

@jafingerhut
Copy link
Owner

If you avoid using mininet, and run simple_switch_grpc directly, you have complete control of the logging on or off, and whether it goes (a) nowhere, (b) to a file, or (c) to the console.

I am less familiar with mininet and all of its options and how to control them. You should consider asking people more familiar with mininet, and/or try asking your question on https://forum.p4.org, to see if someone there knows how to do what you wish.

@fengkeyleaf
Copy link
Author

If you avoid using mininet, and run simple_switch_grpc directly, you have complete control of the logging on or off, and whether it goes (a) nowhere, (b) to a file, or (c) to the console.

I am less familiar with mininet and all of its options and how to control them. You should consider asking people more familiar with mininet, and/or try asking your question on https://forum.p4.org, to see if someone there knows how to do what you wish.

Thanks for your suggestions.

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