One PC Two Interfaces: one send and one receive



Note. With this setting, we don’t need to care about the time synchronization. We can use this topology to test the routing performance of H2.



#!/usr/bin/env python

from mininet.cli import CLI

from import Mininet

from import Link,TCLink,Intf


if '__main__' == __name__:

  net = Mininet(link=TCLink)

  h1 = net.addHost('h1')

  h2 = net.addHost('h2')

  Link(h1, h2)

  Link(h1, h2)

  h2.cmd('ifconfig h2-eth0 netmask')

  h2.cmd('ifconfig h2-eth1 netmask')

  h2.cmd('ifconfig h2-eth0 hw ether 00:00:00:00:02:00')

  h2.cmd('ifconfig h2-eth1 hw ether 00:00:00:00:02:01')    

  h2.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward")

  h1.cmd("ifconfig h1-eth0 0")

  h1.cmd("ifconfig h1-eth1 0")

  h1.cmd("ifconfig h1-eth0 netmask")

  h1.cmd("ifconfig h1-eth1 netmask")     

  h1.cmd('ifconfig h1-eth0 hw ether 00:00:00:00:01:00')

  h1.cmd('ifconfig h1-eth1 hw ether 00:00:00:00:01:01')

  h1.cmd("route add -host  gw h1-eth0")

  h1.cmd("route add -host  gw h1-eth1")





#!/usr/bin/env python

import argparse

import sys

import socket

import random

import struct

import datetime


from scapy.all import sendp, send, get_if_list, get_if_hwaddr

from scapy.all import Packet

from scapy.all import Ether, IP, UDP, TCP


def main():


    if len(sys.argv)<3:

        print 'pass 2 arguments: <destination> "<message>"'



    addr = socket.gethostbyname(sys.argv[1])

    iface = "h1-eth0"


    print "sending on interface %s to %s" % (iface, str(addr))

    pkt =  Ether(src=get_if_hwaddr(iface))

    pkt = pkt /IP(dst=addr) / TCP(dport=1234, sport=random.randint(49152,65535)) / sys.argv[2]



    sendp(pkt, iface=iface, verbose=False)



if __name__ == '__main__':




#!/usr/bin/env python

import sys

import struct

import os

import datetime


from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr, bind_layers

from scapy.all import Packet, IPOption, Ether

from scapy.all import ShortField, IntField, LongField, BitField, FieldListField, FieldLenField

from scapy.all import IP, UDP, TCP, Raw, ls

from scapy.layers.inet import _IPOption_HDR


def handle_pkt(pkt):

    print "Controller got a packet"

    if TCP in pkt:


      print pkt.summary()


def main():

    if len(sys.argv) < 2:

        iface = 'h1-eth1'


        iface = sys.argv[1]


    print "sniffing on %s" % iface


    sniff(iface = iface,

          prn = lambda x: handle_pkt(x))


if __name__ == '__main__':





Open two terminals. One for send and the other for receive.


We got the sending and receiving time. Then we can obtain the time difference for transmission delays and the packet processing delay in h2.


Dr. Chih-Heng Ke (

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan.