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 get the tc command that tcconfig is creating? #59

Closed
ghost opened this issue Mar 15, 2017 · 4 comments
Closed

how to get the tc command that tcconfig is creating? #59

ghost opened this issue Mar 15, 2017 · 4 comments

Comments

@ghost
Copy link

ghost commented Mar 15, 2017

I checked in documentation and I did not see it, probably is not possible (would be nice): a command that shows you what is the tc script is generating tcconfig. I find this useful in two cases: as a way to learn tc, and to debug this program

@thombashi
Copy link
Owner

Thank you for your feedback.

You can see tc commands executing by tcset with --debug option.
Example is as follows:

# tcset --device eth0 --delay 10 --debug
[DEBUG] subprocrunner: lsmod
[DEBUG] tcconfig: |---- start: make_qdisc -----
[DEBUG] subprocrunner: tc qdisc add dev eth0 root handle 1a1a: htb default 1
[DEBUG] subprocrunner: tc class add dev eth0 parent 1a1a: classid 1a1a:1 htb rate 1000000kbit
[DEBUG] tcconfig: ----- complete: make_qdisc ----|
[DEBUG] tcconfig: |---- start: add_rate -----
[DEBUG] subprocrunner: tc class show dev eth0
[DEBUG] tcconfig: existing class list with dev eth0: [u'class htb 1a1a:1']
[DEBUG] tcconfig: existing minor classid list with dev eth0: [1]
[DEBUG] subprocrunner: tc class add dev eth0 parent 1a1a: classid 1a1a:2 htb rate 1000000.000000Kbit ceil 1000000.000000Kbit
[DEBUG] tcconfig: ----- complete: add_rate ----|
[DEBUG] tcconfig: |---- start: set_netem -----
[DEBUG] subprocrunner: tc qdisc show dev eth0
[DEBUG] tcconfig: existing netem list with dev eth0: [u'qdisc htb 1a1a']
[DEBUG] tcconfig: existing netem major id list with dev eth0: [6682]
[DEBUG] subprocrunner: tc qdisc add dev eth0 parent 1a1a:2 handle 1a9a: netem delay 10.000000ms
[DEBUG] tcconfig: ----- complete: set_netem ----|
[DEBUG] tcconfig: |---- start: add_filter -----
[DEBUG] subprocrunner: tc filter add dev eth0 protocol ip parent 1a1a: prio 1 u32 match ip dst 0.0.0.0/0 flowid 1a1a:2
[DEBUG] tcconfig: ----- complete: add_filter ----|

This option is for debugging the program as you described.

Is this what you expected?
Or are you imagine an option that only showing tc commands (not actually executed) and exit?

@ghost
Copy link
Author

ghost commented Mar 16, 2017

Hi @thombashi ,

thanks for your reply!

I didn't notice that debug option, nice!

But yes, it would be nicer to have an option to show what tc commands are executed by tcconfig. Another useful case I found is when you are not allowed to install tcconfig in the required host to operate, but tc is available. This way, you could execute the commands through a tc script, generated by tcconfig.

@thombashi
Copy link
Owner

@pedro-nonfree
Thank you for sharing good use cases.

when you are not allowed to install tcconfig in the required host to operate, but tc is available. This way, you could execute the commands through a tc script, generated by tcconfig.

Certainly, that is a likely use case.

I've added two options at tcconfig 0.8.0:

  • Add --tc-command option: display tc commands to be executed by tcconfig commands
  • Add --tc-script option: create a tc command script which include commands to be executed by tcconfig

Examples:

# tcset --device eth0 --delay 10 --tc-command
tc qdisc add dev eth0 root handle 1f87: htb default 1
tc class add dev eth0 parent 1f87: classid 1f87:1 htb rate 1000000kbit
tc class add dev eth0 parent 1f87: classid 1f87:2 htb rate 1000000Kbit ceil 1000000Kbit
tc qdisc add dev eth0 parent 1f87:2 handle 2007: netem delay 10.0ms
tc filter add dev eth0 protocol ip parent 1f87: prio 1 u32 match ip dst 0.0.0.0/0 flowid 1f87:2
# tcset --device eth0 --delay 10 --tc-script
[INFO] tcconfig: written a tc script to 'tcset_eth0.sh'
# cat tcset_eth0.sh
#!/bin/bash

# tc script file, created by tcset on 2017-03-18T17:21:47.

tc qdisc add dev eth0 root handle 1f87: htb default 1
tc class add dev eth0 parent 1f87: classid 1f87:1 htb rate 1000000kbit
tc class add dev eth0 parent 1f87: classid 1f87:2 htb rate 1000000Kbit ceil 1000000Kbit
tc qdisc add dev eth0 parent 1f87:2 handle 2007: netem delay 10.0ms
tc filter add dev eth0 protocol ip parent 1f87: prio 1 u32 match ip dst 0.0.0.0/0 flowid 1f87:2

Updated the document as well: http:https://tcconfig.readthedocs.io/en/latest/pages/usage/tcset/index.html#advanced-usage

Any comments or feedback would be appreciated.

@ghost
Copy link
Author

ghost commented Mar 18, 2017

That's great.
I'm very happy you did it!!!
Thanks!

Note: for reference seems this is the code you merged -> #60

@ghost ghost closed this as completed Mar 18, 2017
This issue was closed.
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

1 participant