The legal ramifications of scanning networks are complex and controversial (like with many other laws pertaining to computer security). When using tools like Scapy/Nmap the line between doing something benign and malignant is thin. Always have written permission before scanning a network that you don’t own, know what you are doing, know your jurisdictions and speak to a lawyer.
The general rule for this class is:
"You don’t own it; You don’t scan it!"
More about this topic - https://nmap.org/book/legal-issues.html