Scapy with Mininet - scapy

How can I run a scapy script inside mininet to generate custom packets?
I know I could generate traffic using iperf ,netperf etc.But I need to customize the packets and then use them in mininet.
Thanks,
Regards,
Sushmita

You can generate trafic from hosts. You can run cli commands using xterm. I think that using dpkg-name -v you can see what version is emulated by host. So, you can customize ping or whatever you want from the emulated host!
Here you can see how to run commands in hosts setting a simulation from python script. E.g.
h1 = net.get('h1')
result = h1.cmd('ifconfig')
print result

Scapy needs root authentication to run.It is difficult to use in the mininet environment. But you can use nat in mininet, then build packets in your machine and then send to hosts in miininet.

Currently, the best way to achieve this is to use containernet, an actively developed fork of mininet that allow integration of Docker containers. Just use a container that includes Scapy and you are good to go.

Related

How to connect to an integrated VM without using SSH tunelling

I want to connect to a locked (cannot be modified and I do not have permissions to log into) windows vm which is hosted in a linux machine. Until now these two machines were communicating via port 2277. However for security reasons, the port 2277 is only accessible via localhost (127.0.0.1).
The original proposed solution was to use ssh-tunneling. However since the hosted windows vm will always stay with the linux machine, so I was thinking something simpler.
This Windows virtual machine has ip 192.168.0.1 and the default gateway is 192.168.0.2. The later is the ip address that my linux machine can see.
After searching the internet I tried
socat TCP4:192.168.0.1:2277,reuseaddr,fork TCP4:127.0.0.1:2277
as well as some other random combinations without success.
My understanding is that this failed because for socat to work both sockets must be open.
However the first one is not open by default (checked with ss -ltn) as I need to run the windows service first (which it cannot run as it cannot communicate with iphost:2277)
Any ideas on how to proceed?
Socat provides the retry=N and forever options to handle situations like this. Thus, try something like this:
socat -d -d TCP4:192.168.0.1:2277,reuseaddr,fork,forever TCP4:127.0.0.1:2277
With the interval=<seconds> option you can specify how long Socat waits after each failed attempt.
It turns out that the command that I wanted was the following
socat tcp-listen:2277,bind=192.168.0.1,fork,reuseaddr tcp:127.0.0.1:2277
The retry=N and forever options could be also useful.

how to enable wsl to respond to broadcast ping request

I was using WSL to run ROS commands, and at a point i had to enable system to respond to broadcast icmp requests (for a multi master kind of a setup) i.e. on linux i had to make sure
cat /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
returns 0. but WSL does not contain such a file, so i was thinking of enabling it on windows. All the sources i have gone through suggest me to add a rule to firewall but my system is not responding to broadcast ping even when my system's firewall is turned off(domain, private and public have been turned off same with my buddy who is no the same network). i am using an android phone's mobile hotspot to check this.
it would be great if someone could help me on this.
thanks in advance.
I asked something similar
I don't know how to do it purely on WSL. But on windows you have to start the "TCPSVCS.EXE" process. located on System32

Alternative to `tc` command or any api with `tc` functionality

I want to shape the traffic or control bandwidth in my Linux machine. But I couldn't find any API related to functionality of tc command in Linux. As you would have guessed I am trying to use APIs' instead of commands.
Any suggestion will be helpful.
tc calls netlink to communicate with the kernel, here are some resources:
http://man7.org/linux/man-pages/man7/netlink.7.html
http://www.linuxfoundation.org/collaborate/workgroups/networking/netlink
And there is also a library:
http://www.infradead.org/~tgr/libnl/

Checking Subflows in Multipath TCP Connection

I have installed the multipath TCP connection and have 2 interfaces active in my pc. H want to see the mptcp connection working on my device. How do I check that subflows are actually created ?
I tried to connect with multipath-tcp.org and used iperf to check if infact subflows were created but I could see only a single entry in its result. I have seen the related questions, but they don't answer my question i.e. how exactly could i see the subflows in action.
You must connect to a mptcp enabled server to have subflows created otherwise mptcp just falls back to normal tcp. Also, you have to configure the kernel at runtime (you can select fullmesh option) as mentioned in the official website. And, obviolusly, you must have at least 2 interfaces active.
Then tools like iptraf, ifstat can be used to monitor bandwidth in/out.
I found this to be helpful.
1) Open two CLI at Linux environment;
2) Set Wireshark on for capture your packets:
Use option to filter TCP connections, that's make it easy to understand the TCP behavior.
3) Use first CLI to porform iperf as server (iperf -s) and the second to perform as client (iperf -c 127.0.0.1)
After all, you can check the subflows in the Wireshark. Further, you can explore it deeper :)

how can I create dummy traffic for testing?

I need to create some traffic load on a linux machine in order to test some different packet forwarding schemes. Any easy way to have some dummy traffic?
Thanks.
With a second host, you could use nc to simulate server/client transfer, e.g. send files from a bash for-loop to the other host. See the manpage for examples.

Resources