29 July 2010

howto create bootable CDROM in linux

Download BusyBox from here.
Download BusyBox config file from here.
Download ISO build script from here.

Make sure Linux has he following configs enabled:
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE=""

CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=16
CONFIG_BLK_DEV_RAM_SIZE=4096
# chmod +x script.sh
# ./script.sh
untarring busybox...OK
making busybox...OK
making initrd...OK
crreating iso image...OK
making ISO image (grub.iso)...OK

Test "grub.iso" in VmWare:
RAMDISK: gzip image found at block 0
EXT4-fs (ram0): mounted filesystem without journal
VFS: Mounted root (ext2 filesystem) readonly on device 1:0
Freeing unused kernel memory: 276k freed

BusyBox v1.17.1 (2010-08-03 19:24:37 IST) built-in shell (ash)
Enter 'help' for a list of build-in commands.

/bin/sh: can't access tty: job control turned off
#

Reference:
http://tldp.org/HOWTO/Bootdisk-HOWTO/cd-roms.html
http://www.yolinux.com/TUTORIALS/LinuxTutorialCDBurn.html

http://linuxtuneup.blogspot.com/2006/01/slipstreaming-windows-cd-under-linux.html
http://odin.himinbi.org/xp_cds/eltorito_extraction.html

http://alinux.tv/Kernel-2.6.34/initrd.txt
http://en.gentoo-wiki.com/wiki/Initramfs

28 July 2010

findout name and ip of machines in the network

Download latest version of WinPcap from here (1.4.2).
Download latest version of namp from here (1.2.9).
C:\>nmap -sP 192.168.10.0/24

Nmap scan report for 192.168.10.1
Host is up (0.041s latency).
MAC Address: 00:24:01:XX:YY:ZZ (D-Link)

Nmap scan report for 192.168.10.100
Host is up (0.047s latency).
MAC Address: 00:1F:3B:XX:YY:ZZ (Intel Corporate)

Nmap scan report for 192.168.10.101
Host is up.
--> ME

Nmap scan report for 192.168.10.102
Host is up (0.078s latency).
MAC Address: 00:1C:DF:XX:YY:ZZ (Belkin International)

Nmap scan report for 192.168.10.104
Host is up (0.00s latency).
MAC Address: 00:19:D2:XX:YY:ZZ (Intel)

Nmap done: 256 IP addresses (5 hosts up) scanned in 4.94 seconds
This command took almost 15-20 min

FOR /L %i IN (1,1,254) DO ping -n 1 192.168.10.%i | FIND /i "Reply">> c:\ipaddr.txt
Reply from 192.168.10.1: bytes=32 time=2ms TTL=64
Reply from 192.168.10.101: bytes=32 time<1ms TTL=128
Reply from 192.168.10.102: bytes=32 time=3ms TTL=128

Reference:
http://nmap.org
http://www.winpcap.org
http://www.petri.co.il/quickly_find_used_ip_addresses.htm

automate switch commands for Nortel Baystack

download the perl script loop.pl
# yum install perl-Net-Telnet

# chmod +x loop.pl
# ./loop.pl <switch IP Address>
loop.pl version 1.0.0; running on linux; perl version 5.008008
Connecting with Telnet to ...........OK
sysUpTime: 31 days, 21:49:32
sysUpTime: 31 days, 21:49:39
sysUpTime: 31 days, 21:49:46
sysUpTime: 31 days, 21:49:53
sysUpTime: 31 days, 21:50:00
sysUpTime: 31 days, 21:50:07
sysUpTime: 31 days, 21:50:14
sysUpTime: 31 days, 21:50:21
sysUpTime: 31 days, 21:50:28
sysUpTime: 31 days, 21:50:35

Reference:
http://cosimo.europe.nortel.com/Scripts/acg.pl/acg.pl

23 July 2010

create a ramfs in VxWorks

In Linux:
# mkdir -p /mnt/tmp
# mount -t tmpfs -o size=20m tmpfs /mnt/tmp
# mount
tmpfs on /mnt/tmp type tmpfs (rw,size=20m)

# df -h
tmpfs 20M 0 20M 0% /mnt/tmp
# dd if=/dev/zero of=/mnt/tmp/file bs=1024 count=1024
# df -h
tmpfs 20M 1.1M 19M 6% /mnt/tmp
# mkfs -t ext3 -L "RamDisk 1" /dev/ram0

# mkdir -p /mnt/rd
# mount /dev/ram0 /mnt/rd -t ext3
# mount
/dev/ram0 on /mnt/rd type ext3 (rw)

# df -h
/dev/ram0 3.9M 1.1M 2.7M 29% /mnt/rd
# dd if=/dev/zero of=/mnt/rd/file bs=1024 count=1024
# df -h
/dev/ram0 3.9M 2.1M 1.7M 56% /mnt/rd

In VxWorks:
I hate VxWorks


Reference:
http://www.thegeekstuff.com/2008/11/overview-of-ramfs-and-tmpfs-on-linux
http://www.vanemery.com/Linux/Ramdisk/ramdisk.html

http://www.fys.uio.no/studier/kurs/fys4220/docs/vxworks/guide/index.html
http://www.fys.uio.no/studier/kurs/fys4220/docs/vxworks/guide/c-iosys7.html

encrypt/decrypt with openssl

# echo "hi there" > test
# openssl aes-128-cbc -in test -base64 -k password
U2FsdGVkX18mc7Sq6Q3CqPVbNe3Kp7Pyqr2sDo7rQTE=

# openssl aes-128-cbc -in test -base64 -k password > test.enc
# openssl enc -d -in test.enc -k password
U2FsdGVkX18z0h1BxcQtiQ7Fq7xKnabTC8fZnmw1bOE=

# openssl aes-128-cbc -d -in test.enc -k password -base64
hi there
# echo -n "" | md5sum
d41d8cd98f00b204e9800998ecf8427e
# echo -n "hi there" | md5sum
fd33e2e8ad3cb1bdd3ea8f5633fcf5c7

Reference:
http://www.cs.colorado.edu/~jrblack/class/csci6268/f05/slides/CSCI6268L12.ppt
http://www.mydigitallife.info/2008/12/10/how-to-calculate-and-generate-md5-hash-value-in-linux-and-unix-with-md5sum

20 July 2010

mount baystack binary config file

Download baystack binary config file from here.
# hexdump baystack.bin -C -n 1024
00000000 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 |................|
00000010 00 00 00 00 00 00 41 41 00 30 00 00 01 00 00 0b |......AA.0......|
00000020 00 30 00 0f 00 10 00 04 35 2e 30 2e 32 2e 30 33 |.0......5.0.2.03|
00000030 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |3...............|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000070 00 00 00 00 00 00 00 00 00 00 c3 37 a3 f3 eb 3e |...........7...>|
00000080 90 56 58 44 4f 53 31 32 00 00 02 01 01 00 02 70 |.VXDOS12.......p|
00000090 00 00 08 f9 06 00 11 00 01 00 00 00 00 00 00 00 |................|
000000a0 00 00 00 00 29 ff ff ff ff 00 00 00 00 00 00 00 |....)...........|
000000b0 00 00 00 00 46 41 54 31 32 20 20 20 00 00 00 00 |....FAT12 ....|
000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000270 00 00 00 00 00 00 00 00 00 00 00 00 55 aa
f9 ff |............U...|
00000280 ff ff 9f 09 ff 6f 00 ff ff ff ff ff 04 ff ff ff |.....o..........|
00000290 0d f0 ff ff 0f 01 11 20 01 13 40 01 15 60 01 17 |....... ..@..`..|
000002a0 80 01 19 a0 01 1b c0 01 1d e0 01 1f 00 02 21 20 |..............! |
# dd if=baystack.bin of=msdos.img bs=1 skip=126
# mkdir mnt
# mount msdos.img mnt/ -o loop
# ls mnt/
a_inspct.nvr clfrdata.qpa gblCfg.nvr ipt_ping password.nvr
qctempl.cfg softlic telCfg.nvr apps def_cmd.nvr
ifcmap.qpa l3dhcpr.nvr pdtCfg.nvr quickset.cfg staticrt.cfg
usbcfg.nvr asc_cfg d_snoop.nvr igmp.nvr l3mgr.nvr
plcycomp.qpa qVlan stpcfg2.nvr buttonui.nvr eap_enh.nvr
ipmgrcfg.nvr mltScfgS.nvr pmtCfg.nvr rtccfg.nvr stpcfg.nvr
cfgfile.nvr eap.nvr ipt_cfg neap.nvr polcfg.nvr
snmpv3 syslog

Reference:
http://www.c-jump.com/CIS24/Slides/FAT/lecture.html

10 July 2010

SerDes

Some of the standard interface used to connect MAC-block to a PHY chip are AUI, MII, GMII, and XAUI.

AUI : Attachment Unit Interface (for 10 megabit Ethernet)
MII : Medium Independent Interface, 4bit wide data path (for 100 megabit Ethernet)
GMII : Gigabit MII, 8bit wide data path (25 pin parallel) (for gigabit Ethernet)
-> RGMII : Reduced Gigabit MII (12 pin parrallel)
-> SGMII : Serial Gigabit MII (4 pins per port)
XAUI : A 10G AUI (for 10 gigabit Ethernet).

A SERDES (serializer/deserializer) transceiver converts parallel data to/from serial data, thereby reducing the number of signals needed in a chip to chip interface.

The System Packet Interface Level 4 Phase 2 (SPI4.2) is a high-speed interconnection for 10Gbps aggregate bandwidth applications.

NPI - PCI target Network Packet Interface.

Reference:
http://pinouts.ru/Net/mii_pinout.shtml
http://40gethernet.wordpress.com/2009/05/08/overview-of-the-xaui-xlaui-and-caui-part1/
http://www.commsdesign.com/design_corner/showArticle.jhtml?articleID=16505086
http://www.latticesemi.com/products/intellectualproperty/referencedesigns/xauihigighigigtospi4x2s4b/index.cfm
http://opencores.org/project,smii