Wednesday, October 28, 2009

using openssl to calculate sha1 hash in linux

http://buttom-meal.blogspot.com/2009/04/linux-c-openssl-sha1.html
http://www.ibm.com/developerworks/linux/library/l-openssl.html

On centos 5
yum install openssl, openssl-devel

/*
Code snippet to calculate SHA1sum using openssl libs.
Copyright 2005 Junichi Uekawa, given to public domain.

$ gcc openssltest.c -lssl
$ ./a.out < ./a.out
eae8189278303caaa78f2d89e6a6ebeb7d37b554
$ sha1sum ./a.out
eae8189278303caaa78f2d89e6a6ebeb7d37b554 ./a.out
*/

#include "openssl/ssl.h"

main ()
{
SHA_CTX s;
int i, size;
char c[512];
unsigned char hash[20];

SHA1_Init(&s);
while ((size=read (0, c, 512)) > 0)
SHA1_Update(&s, c, size);
SHA1_Final(hash, &s);

for (i=0; i < 20; i++)
printf ("%.2x", (int)hash[i]);
printf ("\n");
}

Intel e1000 NIC driver analyses

http://www.google.com/url?sa=t&source=web&ct=res&cd=36&ved=0CBwQFjAFOB4&url=http%3A%2F%2Flinux.chinaunix.net%2Fbbs%2Fviewthread.php%3Ftid%3D1094725&ei=R6LoSoKDH9WelAeprtyACA&usg=AFQjCNGKr5LSLwVivm-CShmPfDL04sWj-g

Tuesday, October 20, 2009

netperf and tc usage

http://www.ibm.com/developerworks/cn/linux/l-netperf/

http://wolfbeing.blog.51cto.com/435511/190470

In short:
first, start the server on a machine by running: netserv.
second, run "netperf -H $server-ip$ " on the client machine.

Wednesday, October 14, 2009

Meanings of wa, hi, si in "top" command output

The summary area fields describing CPU statistics are abbreviated. They provide information about times spent in:
us = user mode
sy = system mode
ni = low priority user mode (nice)
id = idle task
wa = I/O waiting
hi = servicing IRQs
si = servicing soft IRQs
st = steal (time given to other DomU instances)