Happy Semester

0

It is really a happy happy semester!
Today I just took a look at class Operating System.  The lecturer is so good.  I really like the way he teaches, energetic.  Now everybody just said another class I take “Computer Architecture” has a good lecturer too.  What’s more, I think Computer Vision could be fun…So all three classes I take this semester would be a great of fun!~

Kinect new SDK would be released on Feb 1st, it seems that everything fun come all together.  Let me try to build muscle and survive!

A Fast Minimum Vertex Cover Approximation

0

Although I think the discovery has a coincidence, I still love this algorithm.  So I copied part of our final report and posted it here.

 

Optimal Solution by clique method
We came up with a method based on the observation that the minimum vertex cover of a clique is v-1, assuming the clique has v vertices, since the vertices in the clique are fully linked. Thus we call it clique method.

We use a greedy algorithm to separate the graph into cliques:
First of all, sort the vertices by their degrees in descending order. Start o ff with picking the fi rst vertex in the sorted list of vertices, as a clique, then go along the list. If the union of a vertex in the list, besides the rst one being picked, with the clique remains clique, then this vertex is part of the clique. When coming to the end of the list, we obtain a clique of minimum size 1. Then
remove the vertices in the clique and all edges incident to the vertices from the graph G, we get a new graph G’ and a new sorted list of vertices by their degrees. Iterate this procedure until G is represented by a set of cliques. There could be some vertices of degree 0 left in G’, which should be treated as cliques one by one.

As we all know, after the graph is separated into several cliques (although single point clique may happen), whenever we remove vertices from the graph and check whether it still form a vertex cover, we can at most delete 1 vertex from each clique. In this phase, we try all the possible answers by brute force. Assign status to all the cliques: vi is deleted, or no vertex is deleted. So
for every clique that has n vertices, there are n+1 status.

We optimized the procedure of processing the cliques. Try to assign status from the fi rst clique to the last one(choose which to delete or not delete). If in such an status that two deleted vertices from two distinct cliques share an edge, reject the status and change the status a little bit and try again. This helps avoid unnecessary iterations.

After the procedure is finished, all the possible vertex covers are compared, we can conclude with the minimum vertex cover. The complexity depends on how well we can separate the graph into cliques. Roughly speaking, if we can separate a graph with n points into m cliques, the complexity is O(( n/m)^m).

Essentially the procedure of translating the cliques into minimum vertex cover is numerating all vertex cover, no matter how we optimized it, it is time consuming, though it guarantees an optimal solution.

The reason it’s time costing is the input graph is too large, if it’s a small graph, the running time is acceptable. Thus we decide to preprocess the original graph to make it smaller, which can improve the effciency. This is how the following method comes from.

Approximation Solution by Preprocessing before Clique method

Sort the vertices by their degree in descending order.

Pick greedy 2-approximation from the sorted vertices list above, from the vertex who has most neighbours to the least.

Pick “boundary” vertices from the 2-approximation above. Evaluate the vertices in the 2-approximation, if there is an edge in the graph that one end point is in the 2-approximation, the other is not, we label the vertex in the 2-approximation as “boundary” vertex.

Remove all the boundary vertices from the graph along with the edges they can cover. Sort the vertices in the new graph and pick a greedy 2-approximation, nd the boundary vertices again and again, until there is a time that none of the vertices in the 2-approximation is a boundary vertex. Now we name the graph left as “core”. Usually core is very small.

Apply the clique method to the core of small size, fi nd the minimum vertex cover of the core, union the boundary vertices we’ve already deleted, it is the minimum vertex cover this method can achieve. The complexity of the algorithm can be O(n^2).

The motive behind this method is that clique algorithm works better when there are more edges (in this case the graph can be translated to fewer cliques), and the greedy 2-approximation algorithm works better when the graph has fewer edges, which would lead to a faster approximation. Combining these two can achieve maximum performance on general graphs. It’s intuitive to find out that this method off ers an approximation of the optimal solution, due to the preprocess. However, generally speaking, we confront a tradeo between optimal solution and efficiency. Since this method gives impressive approximation of the optimal solution, it gains more on efficiency than loss on solution.

The code and testing set:

After compiled the cpp file, you can use like that:

./greedy_appro < 450-420.g

Here 450 Means the number of vertices in the graph, 420 means the minimum vertex cover size.  Our algorithm gives a approximation of size 427.  If you want to see the 427 cover, you can use:

./greedy_appro -c <450-420.g

Link:

vc

 

Road to Tofu

0

I was always missing the tofu, especially the super super soft tofu in China.  Now I can make by my own!  Next time I’ll try to make a super soft one for breakfast.

IPV6 Ready Home Network

0

The ipv6 era has come.  Now it seems that Facebook and all the services in Google have implemented IPV6 connectivity.  I know China Tel always trying to block users from IPV6.  Microsoft Teredo server seems down here.  To integrate my home network with IPV6, A tunnel broker is a good choice.

 

First, make sure all the devices you own are IPV6 capable.  An openwrt Router is preferred.  Linux desktops is recommended (Only Linux can update the DNS record from radvd RDNSS).  Windows 7/Vista is acceptable.(They only accept DHCPv6 for DNS update).  Windows XP or earlier version is unacceptable.  Mac OS X 10.6.8 or higher is recommended.

 

The whole article aims to provide IPV6 through Router using tunnel broker.

 

1. As a Hurricane Electric Certified Sage, I recommend tunnel broker provided by HE.  Register your account and create a regular tunnel here.

2.Install the essential modules on Openwrt Router.  I installed: ip, kmod-ipv6, kmod-sit, radvd, dibbler, curl.  Here I use radvd for Router Advertisement and dibbler for DHCPv6.  dibbler is somewhat big.  If you prefer ISC DHCPv6 or wide DHCPv6, that is OK.  curl is for update my tunnel Endpoint IP address cuz my Router is under Dynamic Address Allocation over PPPoE.

3.Bring the router to the IPV6 network.

This is a shell script for me to add my router to IPV6 Network.

username=xxxxxx

password=xxxxxx

tunnelid=xxxxxx

curl --insecure https://$username:$password@ipv4.tunnelbroker.net/ipv4_end.php?tid=$tunnelID

# Here I use --insecure for not verifying the server certification.  or you can use --cacert to specify the CA file

myip=$(ifconfig|grep -A2 'pppoe-wan'|grep 'inet addr:'|cut -d: -f2 |awk '{ print $1}')

myv6ip=2001:470:c:1376::2/64

server=66.220.18.42

ip tunnel add he-ipv6 mode sit remote $server local $myip ttl 255

ip link set he-ipv6 up

ip addr add $myv6ip dev he-ipv6

ip route add ::/0 dev he-ipv6

If everything is fine you can ping ipv6.google.com on your router now.

 

4.Because my Allocated Routed /64 is 2001:470:d:1376::/64 (be aware, the prefix is different from the address your router get, here is a d, not a c).  This /64 block is for my home network, so I route it to the lan.

ip -6 route add 2001:470:d:1376::/64 dev br-lan

5.Configure /etc/config/radvd and /etc/dibbler/server.conf for Router Advertisement and DHCPv6.  The configuration I am using is:

/etc/config/radvd:

config interface
option interface        'lan'
option AdvSendAdvert    1
option AdvManagedFlag   1
option AdvOtherConfigFlag 0
option ignore           0

config prefix
option interface        'lan'
# If not specified, a non-link-local prefix of the interface is used
option prefix           '2001:470:d:1376::/64'
option AdvOnLink        1
option AdvAutonomous    1
option AdvRouterAddr    0
option ignore           1

config rdnss
option interface        'lan'
# If not specified, the link-local address of the interface is used
option addr             '2001:470:20::2'
option ignore           1

/etc/dibbler/server.conf:

log-level 8
log-mode short
preference 0
iface "br-lan" {
// also ranges can be defines, instead of exact values  t1 1800-2000  t2 2700-3000
prefered-lifetime 86400
valid-lifetime 172800
class {
pool 2001:470:d:1376::/64
}
option dns-server 2001:470:20::2
}

6.Enable ipv6 forwarding in /etc/sysctl.conf

net.ipv6.conf.all.forwarding=1

7.After everything finished, just enjoy the IPV6 in your home network.

P.S.  If  you disable IPV4 on your laptop, it will lead your laptop to IPV6 only network.  At least in IPV6 only network Facebook and all services Google providing are accessible.

Salt Lake City

1

Although it is not exactly as expected, I will go to Salt Lake City and start another 2 years there.

Finally I got into computer science, the field I like.  Although I don’t know what is coming, I want to state:

I want to learn almost everything…

Hope it would be a great place for learning… Don’t be like Fudan again…

P.S. W.Pitcock is my idol in computer science…now.  May one day I would know what he knows.

Run Debian inside Alpine

0

It seems good that Alpine really saves plenty of RAM.  After my server boot, only 50+ MB is used.  At last the shortage of RAM does never belong to my server.

 

Everything has pros and cons.  Alpine is a distribution to make every package as small and light as possible.  It uses uClibc, not glibc used by other linux server distros, which leads incompatible with binary packages compiled with glibc(most binary packages are not compiled as static release).  Here raises a question, how can I run these closed-source binaries in alpine?

 

“debootstarp” is a package running Debian inside Alpine.  It can solve all the problems with chroot.  By default, the kernel is compiled with grsec, which forbids chroot.  The config of grsec should be changed before running debootstrap.

 

#apk add debootstrap

#echo 0 > /proc/sys/kernel/grsecurity/chroot_deny_mount

#echo 0 > /proc/sys/kernel/grsecurity/chroot_deny_chmod

#mkdir /mnt/debian

#debootstrap –arch=amd64 stable /mnt/debian

#chroot /mnt/debian /bin/bash

 

 

Wow, Debian inside Alpine!

Setup PPP with Freeradius

6

This article shows how to setup VPNs with freeradius and daloradius web UI.

Step 1:  setup connection between daloradius and mysql

Daloradius is an open source web UI for radius.  Its project webpage is:

http://sourceforge.net/projects/daloradius/

The INSTALL guide could be found in the root folder of daloradius.  In a brief, you should setup a new database uses the schema in contrib/db/ and provides database information to library/daloradius.conf.php.  If you uses freeradius 2.X versions, make sure you set the radius version as ’2′ in daloradius.conf.php.  The usergroup table name was misconfigured as “usergroup”.  Make sure you change it to “radusergroup” in daloradius.conf.php.

After setup, you can login daloradius as administrator.

Notice:

The latest version in SVN is highly recommend.  The stable version 0.9.8 is not compatible with Freeradius 2.X versions.

Now the 0.9.9 is highly recommended.  It is compatible with Freeradius 2.X versions.

The daloradius needs php pear db module.  Make sure the module is installed in your php environment and the path to the module is included in the php.ini configuration file.

 

Step 2: setup connect between freeradius and mysql

Almost all the configuration file now is provided in daloradius SVN contrib/configs/.  Replace the configuration file in freeradius with ones in daloradius, counter.conf, sql.conf, radiusd.conf and the default site configuration in site-enabled folder.

Then setup the database access in sql.conf.

 

Step 3: Setup first user and test

If you uses the configuration file provided by daloradius, the NAS information is set to find in database, not file.

Therefore first, add a new NAS in daloradius NAS section, the IP address could be 127.0.0.1  Then add a new user in daloradius.

Start freeradius, it could be “freeradius -X”

Test the user connectivity in daloradius.  If everything is OK, it should return “Accepted”.

Notice:

If you want to use simultaneous session count only by database, by the default site file in daloradius config schema, the session is counted both in radutmp and database.  In the session section of the site file, I commented radutmp.  In the sql.conf, I enabled the simultaneous count.  This would make the radius only count the simultaneous session in database, without file written.

 

 

Step 4: Setup PPP radius plugin

Usually ppp radius plugin is not included in Debian, or other distributions.  To get ppp radius plugin, you can download pppd source and run “./configure” and “make”. radattr.so and radius.so are the two plugin I use, which can be found in /pppd/plugins/radius/.  On my server, the IP pool is handled by file, not database.

Copy radiusclient folder out from pppd source, to someplace, such as /etc/, and configure the server and shared secrets in radiusclient/servers, if the radius server is the same server where PPP runs, the IP should be 127.0.0.1

 

Step 5: Setup PPTP/L2TP with radius authorization

setup PPTP/L2TP as normal, add plugin and radiusclient path in the pptpd options file.  On my server, it is

plugin /etc/radiusclient/radius.so
plugin /etc/radiusclient/radattr.so
radius-config-file /etc/radiusclient/radiusclient.conf

 

Till now, everything is fine.

 

I am not very good at writing instructions, if you have any questions, feel free to contact me.

Waiting Outside the Lines

0

“You never enjoy your life. Living inside a box. You are soon afraid of taking chances. How you gonna to reach the top?”

I am touched by the video. I spent too much time staying in my “comfort zone”.  Life is not always like it is meant to be.  If I do not polish myself, the life will, the world will.  I should consider the my future carefully these days.

Where Is My Math

0

These days I tried to be “busy reviewing” my lessons, function analysis.  I found that it is a pleasure to watch magic among math symbols, even after my college life.  However I cannot find the feeling I was doing math in 2007 or before.  Math is great, for me, till now.  However I treat math as a tool more than a life now.  I can still do math for hours, analyze the difference between equations.  But even Xbox is more attracting.  Where Is My Math?

I don’t want to blame all these interest-fading, life-changing things to education of Fudan.  At least I survived, as a whole person, with morality and pursuit.  Every place has its own limit.  These limits are not in a vain metric space, which can be measure easily.  I hope, my choice towards computer science was, is, and will be pleasing.  May a great college/university would accept me as a student, the education of which was not the same as the one of Fudan.  I want to remain interested, and hungry.

It says Zhiyu failed to go abroad cuz he was not hungry anymore, at least not for what we are chasing.  I hope I could be crazy for more.

Post written for my leaving mathematics.

Mission 1500

0

Our Mission 1500…  Happy time through life is limited in any given complete spaces.  Be precious!

Go to Top