Code Monkey home page Code Monkey logo

isolate-socket's Introduction

Isolate UDP Socket Demo

This is a UDP echo server demo program. Unlike conventional UDP programs, the server and the client in this program are located in different network namespace. Two different network namespaces are connected by a bridge br0 created by OpenvSwitch.

arch

The program works very simple: the client (C) sends a Hello from client message, and the server (S) replies with a Hello from server message.


这是一个 UDP Hello World 示例代码,其效果十分简单:客户端(C)发送 Hello from client 消息,服务器(S)收到后回复 Hello from server 消息。

但与常规 UDP socket 不同,客户端 C 和服务端 S 均处于隔离的 Network namespace 中,两个隔离的网络空间通过 OpenvSwitch 交换机连接。如上图所示

Usage

Here we use ovs instead of linux bridge, and you can still use linux bridge just with some small modifications of the source code if you really want.

$ git clone [email protected]:yanjiulab/isolate-socket.git

# create br0
$ sudo apt install openvswitch-switch  # suppose you are a ubuntu user
$ sudo ./config  

# compile
$ make

# run
$ sudo ./isolate_server  # in one terminal
Server start at 10.0.0.2:8080... 
Client[10.0.0.1:60859] : Hello from client
Hello message sent.
 
$ sudo ./isolate_client  # in another terminal
Hello message sent.
Server[10.0.0.2:8080] : Hello from server

Refs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.