weblog d’un abbe

20090131

This posting may harm your computer

Filed under: Experiences, Fun — Tags: , , — abbe @ 2036

Google goes mad

20081216

Hacking a codegen

Filed under: Experiences, Fun, Hacking, Yippee!! — Tags: , , , , , , — abbe @ 0456

So, finally I’ve hacked a basic AMD64 code generator, after so many tries. This code generator is hacked in Common Lisp, and is currently generating a code for a very simple toy like language. I’ve not written any grammar specification for it. It is a LISP like language. This piece of code generator is dedicated to one of my cool friend Edwin Jose, and is thus named as louzer. Following is an example of the language for which louzer generates code.

(source
	 (let principal rate time amount x)
	 (= principal 1000)
	 (= rate 10)
	 (= time 100)
	 (= x 100)
	 (= amount
		(/ (* principal (* rate time))
		 100))
	 (print "Amount (%d) - %d is %d.\\n"  amount x (- amount x))
	 (print "Hello World, louzer\\n"))

The language code is also embedded along with the source code in the LISP file. Following is how I’m using it with GNU clisp implementation:

% clisp louzer.lisp |tee test.S
.section .text
.extern printf
.type main,@function
.globl main
main:
 pushq %rbp
 movq %rsp, %rbp
 subq $40, %rsp
 movq $1000, %rbx
 movq %rbx, -8(%rbp)
 movq $10, %rbx
 movq %rbx, -16(%rbp)
 movq $100, %rbx
 movq %rbx, -24(%rbp)
 movq $100, %rbx
 movq %rbx, -40(%rbp)
 movq -16(%rbp), %rbx
 imul -24(%rbp), %rbx
 imul -8(%rbp), %rbx
 movq %rbx, %rax
 movq $100, %rbx
 xorq %rdx,%rdx
 idiv %rbx
 movq %rax, -32(%rbp)
 leaq __string_0,%rdi
 movq -32(%rbp), %rsi
 movq -40(%rbp), %rdx
 movq -32(%rbp), %rbx
 subq -40(%rbp), %rbx
 movq %rbx, %rcx
 xorq %rax,%rax
 call printf
 leaq __string_1,%rdi
 xorq %rax,%rax
 call printf
 xorq %rax, %rax
 movq %rbp, %rsp
 popq %rbp
 ret
.section .rodata
__string_1: .string "Hello, louzer World\n"
__string_0: .string "Amount (%d) - %d is %d.\n"
/* Generated by louzer :) */

Above is the piece of AMD64 assembly code emitted by the louzer. So, now time to assemble and link the above assembly code and generate the output of the above code.

% cc -o test test.S
% ./test
Amount (10000) - 100 is 9900.
Hello, louzer World

Voila. Oh, sorry to keep you waiting, now you can download the louzer.lisp and have fun. BtW, code is not perfect and has couple of limitations, which I’ve not fixed due to lack of time, as I’ve an exam day after tomorrow. So, I’ll be able to work on it only after 20081219. Happy hacking codegens…;)

NOTE (for Grammar Nazis): Forgive me for any grammatical mistakes you encounter above, and ofcourse point out the mistake :).

P.S. Forgot to mention, you’ll need an AMD64 architecture CPU, toolchain and POSIX OS to test out above stuff.

20080910

Google IPv6 endpoint in Europe

Filed under: Experiences, Fun — Tags: , — abbe @ 0851
┌─(abbe@chateau:pts/8)───────────────────────────────────────────────────────────────────────(~)─┐
└─(08:41:%)── sudo traceroute -6 -I -n 2001:4860:0:2001::68                        ──(Wed,Sep10)─┘
Password: 
traceroute to 2001:4860:0:2001::68 (2001:4860:0:2001::68), 30 hops max, 40 byte packets
 1  2001:470:1f08:3b7::1  255.608 ms  258.492 ms  261.419 ms
 2  2001:470:0:67::1  263.345 ms  266.538 ms  269.720 ms
 3  2001:470:0:3f::2  282.060 ms  283.483 ms  285.925 ms
 4  * * *
 5  * * *
 6  2001:4860:0:2001::68  556.875 ms  503.697 ms  510.901 ms
┌─(abbe@chateau:pts/8)───────────────────────────────────────────────────────────────────────(~)─┐
└─(08:41:%)── sudo traceroute -6 -I -n 2001:4860:0:1001::68                        ──(Wed,Sep10)─┘
traceroute to 2001:4860:0:1001::68 (2001:4860:0:1001::68), 30 hops max, 40 byte packets
 1  2001:470:1f08:3b7::1  256.051 ms  258.644 ms  261.619 ms
 2  2001:470:0:67::1  264.279 ms  266.755 ms  269.970 ms
 3  2001:470:0:3f::2  281.020 ms  283.444 ms  286.494 ms
 4  * * *
 5  * * *
 6  2001:4860:0:1001::68  558.181 ms  516.731 ms  511.211 ms

2001:4860:0:1001::68 points to the European cluster (in Amsterdam, as mentioned by berniv6 on #ipv6 in ipv6.chat.freenode.net) of ipv6.google.com, whereas 2001:4860:0:2001::68 (ipv6.google.com) is known to be located in US. My tunnel remote endpoint (2001:470:1f08:3b7::1|216.66.80.26) is located in London, UK. Notice the RTT ;)

20080530

Getting 8139too to work at 100 Mbps Full Duplex

Filed under: Experiences — Tags: , , , , — abbe @ 1210

I recently switched to my RTL-8139 NIC instead of default onboard Intel NIC, after I came to know that e100 uses binary blobs. I’ve a Netgear WGT624 WiFi router (acting as switch, atm). I plug-in my desktop at a 100 Mbps switch port in the switch. So now when I connected my RTL8139 NIC to my wireless enabled wired-switch, it comes online at 10 Mbps (full-duplex)

abbe@chateau ~ $ sudo ethtool rl0
Settings for rl0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Advertised auto-negotiation: No
        Speed: 10Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 32
        Transceiver: internal
        Auto-negotiation: off
        Supports Wake-on: pumbg
        Wake-on: p
        Current message level: 0x00000007 (7)
        Link detected: yes

Now, I tried manually switching it 100 Mbps (full-duplex):

abbe@chateau ~ $ sudo ethtool -s rl0 speed 10
abbe@chateau ~ $ sudo ethtool rl0
Settings for rl0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Advertised auto-negotiation: No
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 32
        Transceiver: internal
        Auto-negotiation: off
        Supports Wake-on: pumbg
        Wake-on: p
        Current message level: 0x00000007 (7)
        Link detected: yes

Now, to automate this, I added following line into /etc/modprobe.d/options and executed update-modules.

abbe@chateau ~ $ cat /etc/modprobe.d/options
options 8139too media=0x231
abbe@chateau ~ $ sudo modprobe -r 8139too
abbe@chateau ~ $ sudo update-modules
 * Updating /etc/modprobe.conf by hand ...                                                                                                                                 [ ok ]
 * Updating modules.dep ...                                                                                                                                                [ ok ]
abbe@chateau ~ $ sudo modprobe 8139too
abbe@chateau /etc/modprobe.d $ sudo /usr/sbin/ethtool rl0
Settings for rl0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Advertised auto-negotiation: No
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 32
        Transceiver: internal
        Auto-negotiation: off
        Supports Wake-on: pumbg
        Wake-on: p
        Current message level: 0x00000007 (7)
        Link detected: yes

How to arrive at the number 0x231, check out modinfo 8139too and drivers/net/8139too.c source code. BtW, I just noticed that rl0 has auto-negotiation off, so I decided to turn it on, and following are the results:

abbe@chateau ~ $ sudo ethtool -s rl0 autoneg on
abbe@chateau ~ $ sudo ethtool rl0 
Settings for rl0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Advertised auto-negotiation: Yes
        Speed: 10Mb/s
        Duplex: Half
        Port: MII
        PHYAD: 32
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pumbg
        Wake-on: p
        Current message level: 0x00000007 (7)
        Link detected: no
abbe@chateau ~ $ sudo ethtool -s rl0 speed 100 duplex full
abbe@chateau ~ $ sudo ethtool rl0 
Settings for rl0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 32
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pumbg
        Wake-on: p
        Current message level: 0x00000007 (7)
        Link detected: yes

After this I tried testing network speed using iperf, and got speeds of ~ 67 Mbps. With e100, I used to get ~ 97 Mbps. Anyways this is an 3-4 year old NIC, plugged (and unused) into my desktop unused since 2-3 years. So will try testing speeds with a new NIC soon.

20080507

Spoofing on Internet

Filed under: Experiences — Tags: , , — abbe @ 0123

Although it seems like dream to be able to successfully spoof on Internet in 21st century, but I realized this dream, yesterday. Thanks to the cheapest cyber café operator Tata Communications pretending to be an ISP. :)

I’ve a GNU/Linux box connected to the internet, via 2 ADSL internet connections from 2 cyber café operators, namely Airtel Broadband (not cheap), and Tata Communications (cheapest). Airtel Broadband connection is connected to my GNU/Linux box at eth1 interface, and Tata Communications connection is connected to eth2 interface. eth1 is assigned a RFC1918 IPv4 address, whereas eth2 is assigned a static and globally routable IPv4 address. Using eth2‘s address, I’ve setup a 6to4 tunnel, with interface name sit0 for my IPv6 internet addiction.

Now, yesterday I wasn’t able to ping google.com via eth2, though I recieved no ICMP errors from gateway. So I switched my default gateway to eth1. And after this, I’m able to ping google.com :). I thought I should also try ping6 ipv6.google.com though I’m sure that it won’t work, since sit0‘s source address is based on eth2‘s address, which is different from the current default gateway interface’s address, eth1. But to my surprise, it worked. I’m getting ICMP echo replies from ipv6.google.com :).

To confirm further, I tried curl http://ipv6.whatismyipv6.net/ |fgrep 'Your IP is' and I received sit0‘s IPv6 address as output. :). Now, this is confusing. Even though I’m able to send spoofed packets, but how I’m receiving replies of those spoofed packets, if internet connection on eth2 is not working, hmm…? So, I connected to #ipv6@ipv6.chat.freenode.net (being able to IRC over IPv6) to figure out what is happening, and at the same time I started sudo tcpdump -i eth2 proto 41 on another terminal to confirm whether I’m really receiving any IPv6-in-IPv4 packets on eth2 interface. And as expected, I’m getting IPv6 traffic over eth2. I thought maybe Tata Communications‘s connectivity has restored, but no success with sudo ping -I eth2 google.com :(. So I asked p1mrx on #ipv6@ipv6.chat.freenode.net to ping IPv4 address of eth2 and I started sudo tcpdump -i eth2 proto icmp in another terminal. I captured ICMP echo requests sent by h{is,er} box and also captured ICMP echo replies sent from my box. {S,}he confirmed that ping is successful.

CONCLUSION. The cheapest cyber café operator Tata Communications, pretending to be an ISP, is dropping my outbound traffic (TCP, UDP, ICMP echo request) but idiot operator’s dumb clueless retarted (and some more words you can think of…..) cyber café incharges, who never studied IPv4 networks, or don’t know that there is a protocol field (size: 1 byte) in the IPv4 header, which identifies what kind of payload that IPv4 packet is carrying, and has forgot to block all other protocols, ROFL. But why’re they doing this. /me is confused why they’ve blocked. Anyways I’ll call them today. Another reason why they’re retarded….

/me is confused how Indian cyber café operators will become an ISP and transition to IPv6 :(

20071025

/me traced again

Filed under: Experiences, Fun — abbe @ 0051

/me traced again
After this, I traced again my photo, but this time a current one :). Following is the link to the SVG source for vector graphics fans, scale me as much as you can :)

http://wahjava.googlepages.com/face3-final-plain.svg

20071009

dd if=/dev/hda of=/dev/sdb bs=64M

Filed under: Experiences — abbe @ 0253

Just finished, dding my ST3160812AV (160 GB/PATA/Seagate) onto ST3160812AS (160 GB/SATA/Seagate):

chatteau ~ # dd if=/dev/hda of=/dev/sdb bs=64M
9+0 records in
8+0 records out
536870912 bytes (537 MB) copied, 10.5324 s, 51.0 MB/s
26+0 records in
26+0 records out
1744830464 bytes (1.7 GB) copied, 29.3277 s, 59.5 MB/s
35+0 records in
34+0 records out
2281701376 bytes (2.3 GB) copied, 38.9617 s, 58.6 MB/s
77+0 records in
76+0 records out
5100273664 bytes (5.1 GB) copied, 84.8692 s, 60.1 MB/s
104+0 records in
103+0 records out
6912212992 bytes (6.9 GB) copied, 114.29 s, 60.5 MB/s
197+0 records in
196+0 records out
13153337344 bytes (13 GB) copied, 216.665 s, 60.7 MB/s
267+0 records in
267+0 records out
17918066688 bytes (18 GB) copied, 294.418 s, 60.9 MB/s
796+0 records in
796+0 records out
53418655744 bytes (53 GB) copied, 895.93 s, 59.6 MB/s
1783+0 records in
1782+0 records out
119587995648 bytes (120 GB) copied, 2173.03 s, 55.0 MB/s
2333+0 records in
2332+0 records out
156497870848 bytes (156 GB) copied, 3087.42 s, 50.7 MB/s
2380+0 records in
2379+0 records out
159651987456 bytes (160 GB) copied, 3185.21 s, 50.1 MB/s
2384+1 records in
2384+1 records out
160041885696 bytes (160 GB) copied, 3198.33 s, 50.0 MB/s

The whole process took less than an hour as compared to 1 hr. 25 min. when I dded my SATA disk to PATA disk.

20070917

/me traces my face

Filed under: Experiences, Fun — abbe @ 0155

/me traced
Using Inkscape and with the help of Nicu‘s tutorial, I’m able to trace my photo. The output is not excellent, but I enjoyed the process :-) . Inkscape rocks. Following is the link to SVG of the picture:

http://wahjava.googlepages.com/my-face-shaded2.svg

In order to render above SVG, make sure SVG renderer is capable of rendering <feGaussianBlur> SVG filter. Inkscape and Apache Batik are able to render SVG properly.

20070803

GNOME Online Desktop rocks :)

Filed under: Experiences, Yippee!! — abbe @ 0118

GNOME Online Desktop
One of the coolest things I’ve seen in my life :-D

20070720

dd if=/dev/sdb of=/dev/sda bs=64943040

Filed under: Experiences — abbe @ 0300

Just finished, dding my ST3160812AS (160 GB/SATA/Seagate) onto ST3160812AV (160 GB/PATA/Seagate):

sh-3.2# dd if=/dev/sdb of=/dev/sda bs=64943040
8+0 records in
8+0 records out
519544320 bytes (520 MB) copied, 9.68668 s, 53.6 MB/s
13+0 records in
13+0 records out
844259520 bytes (844 MB) copied, 17.9687 s, 47.0 MB/s
19+0 records in
19+0 records out
1233917760 bytes (1.2 GB) copied, 27.9116 s, 44.2 MB/s
217+0 records in
217+0 records out
14092639680 bytes (14 GB) copied, 400.011 s, 35.2 MB/s
454+0 records in
453+0 records out
29419197120 bytes (29 GB) copied, 847.458 s, 34.7 MB/s
529+0 records in
528+0 records out
34289925120 bytes (34 GB) copied, 991.407 s, 34.6 MB/s
670+0 records in
669+0 records out
43446893760 bytes (43 GB) copied, 1260.98 s, 34.5 MB/s
673+0 records in
672+0 records out
43641722880 bytes (44 GB) copied, 1266.12 s, 34.5 MB/s
763+0 records in
763+0 records out
49551539520 bytes (50 GB) copied, 1443.54 s, 34.3 MB/s
820+0 records in
819+0 records out
53188349760 bytes (53 GB) copied, 1552.44 s, 34.3 MB/s
1099+0 records in
1099+0 records out
71372400960 bytes (71 GB) copied, 2103.98 s, 33.9 MB/s
1144+0 records in
1144+0 records out
74294837760 bytes (74 GB) copied, 2194.04 s, 33.9 MB/s
1329+0 records in
1328+0 records out
86244357120 bytes (86 GB) copied, 2568.23 s, 33.6 MB/s
1356+0 records in
1356+0 records out
88062762240 bytes (88 GB) copied, 2623.02 s, 33.6 MB/s
1440+0 records in
1440+0 records out
93517977600 bytes (94 GB) copied, 2795 s, 33.5 MB/s
1638+0 records in
1637+0 records out
106311756480 bytes (106 GB) copied, 3211.79 s, 33.1 MB/s
1782+0 records in
1781+0 records out
115663554240 bytes (116 GB) copied, 3521.31 s, 32.8 MB/s
2033+0 records in
2033+0 records out
132029200320 bytes (132 GB) copied, 4085.72 s, 32.3 MB/s
2144+0 records in
2143+0 records out
139172934720 bytes (139 GB) copied, 4344.01 s, 32.0 MB/s
2300+0 records in
2299+0 records out
149304048960 bytes (149 GB) copied, 4724.12 s, 31.6 MB/s
2388+0 records in
2388+0 records out
155083979520 bytes (155 GB) copied, 4950.18 s, 31.3 MB/s
2447+0 records in
2446+0 records out
158850675840 bytes (159 GB) copied, 5106.49 s, 31.1 MB/s
2464+1 records in
2464+1 records out
160041885696 bytes (160 GB) copied, 5171.74 s, 30.9 MB/s
Older Posts »

Create a free website or blog at WordPress.com.