Simple SDN/NFV example

[Description]

Network function virtualization (NFV) is a network architecture concept that uses the technologies of IT virtualization to virtualize entire classes of network node functions into building blocks that may connect, or chain together, to create communication services. (refer to https://en.wikipedia.org/wiki/Network_function_virtualization)

 

SDN can be handling the routing.

 

 

[A simple example]

H1—S1----H2

        |

        H3

 

In this example, H1 will send "Hello, World!" to H2. If the link between S1 and H2 is lossy. The message may be lost duration transmission. If we can add the NFV at the node 3 and route the packet from H1 to H3 first, duplicate the packets and send back to H2, the message has a higher probability of reaching H2. (Note that we don’t modify the source code of sender program.)

 

udp_send.py

import socket

 

UDP_IP = "10.0.0.2"

UDP_PORT = 5005

MESSAGE = "Hello, World!"

 

print "UDP target IP:", UDP_IP

print "UDP target port:", UDP_PORT

print "message:", MESSAGE

 

sock = socket.socket(socket.AF_INET, # Internet

                     socket.SOCK_DGRAM) # UDP

sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))

 

udp_receive.py

import socket

 

UDP_IP = "10.0.0.2"

UDP_PORT = 5005

 

sock = socket.socket(socket.AF_INET, # Internet

                     socket.SOCK_DGRAM) # UDP

sock.bind((UDP_IP, UDP_PORT))

 

while True:

    data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes

    print "received message:", data

 

Case 1: H1 is sending traffic to H2 directly.

 

 

Directly set the rules so that the h1 can talk to h2.

 

Case 2: set the rules so that the packet sent by H1 can be routed to H3 first. Then H3 will duplicate the received packets and send back to H2.

 

udp_forward.py

import socket

 

UDP_IP = "10.0.0.3"

UDP_PORT = 5005

 

UDP_IP2 = "10.0.0.2"

UDP_PORT2 = 5005

 

sock = socket.socket(socket.AF_INET, # Internet

                     socket.SOCK_DGRAM) # UDP

sock.bind((UDP_IP, UDP_PORT))

 

sock2 = socket.socket(socket.AF_INET, # Internet

                     socket.SOCK_DGRAM) # UDP

 

while True:

    data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes

    print "received message:", data

    sock2.sendto(data, (UDP_IP2, UDP_PORT2))  #duplicate the received packets and send the packets to H2

    sock2.sendto(data, (UDP_IP2, UDP_PORT2))

 

With the following rules, H1 send one packet and H2 can receive two packets. (No need to do anything at the sender side and receiver side.)

 

Dr. Chih-Heng Ke (smallko@gmail.com)

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan.