Showing posts from December, 2012

[ZeroMQ] The example of ZeroMQ via C#

Recently I found these two articles that give a very good introduction of ZeroMQ and an useful use case for synchronized PUB-SUB pattern. Although it uses C# as its programming language instead of C, but I still think we can learn some important concept from these.And also, these articles provide very good images to illustrate the communication patterns.
There are several communication patterns described
Multi-part messagesSynchronized Pub-Sub pattern using PUB-SUB + REQ-REP

[SWIG] How to add C function in Python by using SWIG

Here is a simple example to use SWIG to automatically wrap C function and generate a wrapper and build a shared library for python./*** File : example.c ***/#include<time.h>doubleMy_variable=3.0;int fact(int n){if(n <=1)return1;elsereturn n*fact(n-1);}int my_mod(int x,int y){return(x%y);}char*get_time(){time_t ltime; time(&ltime);return ctime(&ltime);}/*************************/

/*** example.i ***/%module example %{/* Put header files here or function declarations like below */externdoubleMy_variable;externint fact(int n);externint my_mod(int x,int y);externchar*get_time();%}externdoubleMy_variable;externint fact(int n);externint my_mod(int x,int y

[Trema] The L2 isolation mechanism in sliceable switch

If someone has ever seen the documents about sliceable switch as below, he/she will feel headache or sick because of a lot of contents and description.

Now, I will give a flow control chart of slice function which is summarized from the source code ( slice.c ). That can give you a clear image about L2 isolation mechanism in sliceable switch, specially in Slice function. Check it out as the following chart:

 So, broadly speaking, the slice function will check mac binding first, then port_mac binding, and finally port binding. Meanwhile, some configurations will affect the result, for instance, "restrict hosts on port" enabled will force the slice function to check port_mac binding, otherwise, it won't do that.
Based on this flow chart, you can compare with the test cases in

[MongoDB] Install MongoDB and try a simple example of mongodb_c_driver

MongoDB Installation
For instance in my environment:
  > sudo apt-key adv --keyserver --recv 7F0CEB10
  > sudo echo "deb dist 10gen" | tee -a /etc/apt/sources.list.d/10gen.list
  > sudo apt-get -y update
  > sudo apt-get -y install mongodb-10gen

Try command on MongoDB
MongoDB shell version: 2.2.2
connecting to: test

> show dbs
db    (empty)
local    (empty)
test    0.203125GB

> use test
switched to db test

> show collections

### Insert new data ###
> doc = {
... "name" : "kristina",
... "contact info" : {
... "twitter" : "@kchodorow",
... "email" : ""
... },
... "friends"…

[Memcached] Install memcached and try libmemcached C API

Install from package
> sudo apt-get install memcached

or Install from source code
We need to have :
libevent downloaded from :> ./configure --prefix=/usr> make> sudo make installmemcached downloaded from :> ./configure --prefix=/usr/local> make> sudo make installCheck the status of memcached
 > sudo service memcached status

Install libmemcached C API from source code

libmemcached C API ownloaded from> ./configure --prefix=/usr> make > sudo make install
Give a simple try for libmemcached C API
> gcc -o mem_test2 mem_test2.c -lmemcached -lpthread
> ./mem_test2
Save key:key1 data:"This is c first value" success.
Fetch key:key1 data:This is c first value
Delete Key key1 success.


#include <stdio.h> #include <stdlib.h> #include <string.h> #include <libmemcached/memcached.h> intmain(intargc,char*argv[]){memcached_st*memc;memcached_r…

[Presentation] OpenStack 2012 fall summit observation - Quantum/SDN

Taiwan OpenStack User Group (TWOSUG)3rd Meet Up is hold in Dec 5, 2012. I give a presentation in one of session, which is "OpenStack 2012 fall summit observation - Quantum/SDN". The topic is focused on Quantum and SDN and the slide is shared on shlideshare as follows: