Monday, June 29, 2009

Measure TCP Throughput using netcat (nc)

netcat (nc) is installed on almost all Linux computers. So when you do not have tools such as iperf available for TCP throughput testing, try the way of doing it with netcat.

On machine A, do :

nc -v -v -l -n -p 2222 >/dev/null

For redhat or Fedora Core do this instead:

nc -v -v -l -n 2222 >/dev/null

On machine B do:
time yes|nc -v -v -n 192.168.0.8 2222 >/dev/null

Now wait 30 seconds, and hit Ctrl-C on machine B, and you shoud get something like this:
sent 87478272, rcvd 0
real 0m9.993s
user 0m2.075s
sys 0m0.939s

Now calculate the throughput
87478272 * 8 / 9.993 (the nubmer above after real)

You can use python as a calculator to do this. :-)

Now that's pretty easy, isn't it?

Wednesday, June 10, 2009

tcpdump "received by filter"

When you use tcpdump on Linux, and do not see all the packets you are expecting, and get something like this:

10 packets captured
100 packets received by filter
0 packets dropped by kernel

Make sure you use "tcpdump -Nn ...". This disables tcpdump name lookup, and makes tcpdump much faster/real-time. It took me some time to find this out. Hope this helps.

Thursday, June 04, 2009

How to change stored Network Printer Credentials

Try running on the problematic PC (XP), from the start/run box:
rundll32.exe keymgr.dll, KRShowKeyMgr
This should open the password management console. If your saved share is present, you should be able to delete it.
The following article outlines in detail
http://www.windowsnetworking.com/kbase/WindowsTips/WindowsXP/AdminTips/Security/RemoveSavedPasswords.html

Thursday, May 07, 2009

Virtualbox, Ubuntu, Change Screen Resolution

After installing the guest package, Ubuntu 9.04 still does not show the right screen resolution.

Then do this:

At the terminal type this

sudo dpkg-reconfigure -phigh xserver-xorg

and log out, and log back in.

Now your screen resolution is the same as your window size. Just maximize your window or go full screen to get the max screen resolution

Tuesday, April 21, 2009

Struct sockaddr and friends

Prototypes



include <netinet/in.h>

// All pointers to socket address structures are often cast to pointers
// to this type before use in various functions and system calls:

struct sockaddr {
unsigned short sa_family; // address family, AF_xxx
char sa_data[14]; // 14 bytes of protocol address
};


// IPv4 AF_INET sockets:

struct sockaddr_in {
short sin_family; // e.g. AF_INET, AF_INET6
unsigned short sin_port; // e.g. htons(3490)
struct in_addr sin_addr; // see struct in_addr, below
char sin_zero[8]; // zero this if you want to
};

struct in_addr {
unsigned long s_addr; // load with inet_pton()
};


Wednesday, April 01, 2009

vim marks

Marks

You can set marks within your documents to jump quickly between different positions of a document or even many documents.

Vim automatically sets various marks like

* {0-9} are the last 10 positions of closed files (0 the last, 1 the last but one)
* <> are the left and right position of marked texts
* ( and ) are the start or end of the current sentence
* { and } are the start or end of the current paragraph
* [ and ] are the first or last character of the last yanked or changed text
* . position of the last change
* ' or ` position before the last jump
* " position before the last exit of the file (local to a file)
* ^ position of the last insert-stop

To set a manual mark, use m{a-zA-Z} (m followed by either a,b..z or A,B,..Z), and to jump to one of the marks (manual or automatic) you can choose between ' and `

* ' ...sets the cursor to the first non-blank character in the marked line
* ` ...sets the cursor to the exact position where the mark was set

There is a little difference between lower-case and upper-case characters:

* {a-z} are local to a file
* {A-Z} are stored and available over sessions (associated with a file)

You can use L for your work-log and T for your time-table for example, and quickly update the information there.

For example you can jump to the last known position of a file before it was closed by typing `" (it’s easy to configure Vim to do it automatically at start).

To get a list of all marks Vim knows about type :marks. To delete marks use :delmarks (:delmarks a b c removes marks a and b and c, to delete all marks use :delmarks!).

More tips at http://blog.interlinked.org/tutorials/vim_tutorial.html

Monday, March 30, 2009

Fix Debian Problem: W: There is no public key available for the following key IDs

When you do an "apt-get" on Debian, you get:

W: There is no public key available for the following key IDs:
.....

To fix this problem, just run this:

sudo apt-get install debian-archive-keyring