I have created a network topology such as H1 <-> S1 <-> S2 <-> H2 in Mininet. Where H are Hosts and S are Switches. The network has been created as follows
I have set the delay in the network as 1ms. When I run Ping between H1 and H2, I get result such as follows,
We can see that the RTT is approx. similar to topology.
If send a packet using Scapy from H1 to H2 using sendp(), the RTT is increasing. I am sending packet as follows
If I use socket programming on the same network, then I get RTT = 2ms(approx.) I want to know what is going wrong with Scapy.
I don't think there is anything wrong here. You specified 1ms on your link, the RTT is when a packet comes and then comes back. So you have 1ms * 2 = 2ms. If you want to achieve 1ms RTT you have to specify a 0.5ms latency on the link.