Posts

Showing posts from December, 2012

[ZeroMQ] The example of ZeroMQ via C#

Image
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.

http://www.codeproject.com/Articles/488207/ZeroMQ-via-Csharp-Introduction
There are several communication patterns described
http://www.codeproject.com/Articles/514959/ZeroMQ-via-Csharp-Multi-part-messages-JSON-and-Syn
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

Image
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.
https://github.com/trema/apps/wiki/sliceable_switch_tutorial
https://github.com/trema/apps/wiki/sliceable_switch_features

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 https://github.com/trema/apps/wiki/sliceable_switch_features







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

MongoDB Installation
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian-or-ubuntu-linux/
or
https://www.digitalocean.com/community/articles/how-to-install-mongodb-on-ubuntu-12-04
For instance in my environment:
  > sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
  > sudo echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart 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
>mongo
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
foo
system.indexes

### Insert new data ###
> db.foo.save({a:1})
> doc = {
... "name" : "kristina",
... "contact info" : {
... "twitter" : "@kchodorow",
... "email" : "kristina@10gen.com"
... },
... "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 : http://libevent.org/> ./configure --prefix=/usr> make> sudo make installmemcached downloaded from : http://memcached.org/> ./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 http://libmemcached.org/libMemcached.html> ./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.

mem_test2.c

#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:
http://www.slideshare.net/teyenliu/open-stack-2012-fall-summit-observation-with-quantumsdn-15493510