“ATOMIC BAND” - ITune Server - V2

28/04/2008 20:14

I wrote a post on install ITune Server on FC6 (http://www.elian.co.uk/2007/04/12/atomic-band-itune-server/)

Due to recent upgrade our internal server to FreeBSD 7, I am looking for a similar solution for ITune Server on FB7.  When FB7 first released, the default C compile is gcc v4.2 and mt-daap was “known-not-compatible” with gcc 4. However, recently I find the new version or new port of mt-daap is fixed the problem with gcc v4.

To install mt-daap, compare with installing it on FC, it is so easy!
1. Make sure your ports are up-to-date. My prefer tool for manaing FreeBSD ports is portsnap, so simply run “portsnap fetch update”
2.Go to mt-daap folder(/usr/ports/audio/mt-daapd)
3. make install clean
4. OK, you got iTune server now!
5. TO configure it up, go to /usr/local/etc/.  Copy mt-daapd.conf.sample to mt-daapd.conf and change admin_pw and mp3_dir. Everything is done

If you got troubles to create playlist, try to use this only tool http://migrantcoder.com/daapd/ or for advanced users, read wiki on its offical website http://wiki.fireflymediaserver.org/Smart_playlists

Does FreeBSD 7 solve its MySQL problem?

22/12/2007 19:19

A very famous article by Jeremy pointed out the reason mysql database had lower performance on BSD system which is my most preferred OS (http://jeremy.zawodny.com/blog/archives/000203.html). Although, there is a work-around by using LinuxThread (http://pauillac.inria.fr/~xleroy/linuxthreads/), it cannot satisfy all the pure BSDers.

Since the annoucement of V7, many people are exciting for its new features. Especially, the improvement of scheduler, both 4BSD and ULE. But the question is does V7 really solve the MySQL problem? what is the performance of MySQL on FreeBSD 7. I read Kris’ “7.0 Preview” today, it really makes believe so.

http://people.freebsd.org/~kris/scaling/7.0%20Preview.pdf

bsd7.jpg

SPAM Collecting

15/08/2007 20:59

I decided, TODAY, to collect the most anonnying SPAM sending into my inbox. If you are a Network admin, please feel free to comment.

http://www.elian.co.uk/category/my-spam/

C2611XM upgrades to IOS AdvEnterprise 12.4.9T

26/06/2007 12:18

CISCO suggested AdvEnterprise 12.4.9T  running on the routers that have 48M Flash, and 256M DRAM. But the office router only gets 32M Flash and 128M DRAM(OLD AND DUSTY). I really doubt my boss will agree to spend £300 to upgrade it and at the same time I need to get IPX and VPN working on it. I took the risk to upgrade it to c2600-adventerprisek9-mz.124-9.t.bin.

It took a lot longer to copy the ios to flash and veeeeery long to load it during booting, well, at least, I felt it taking very long time. Luckily, it works :)

sysctl.conf optimization

02/06/2007 02:11

# Controls source route verification
# Default should work for all interfaces
net.ipv4.conf.default.rp_filter = 1
# net.ipv4.conf.all.rp_filter = 1
# net.ipv4.conf.lo.rp_filter = 1
# net.ipv4.conf.eth0.rp_filter = 1

# Disables IP source routing
# Default should work for all interfaces
net.ipv4.conf.default.accept_source_route = 0
# net.ipv4.conf.all.accept_source_route = 0
# net.ipv4.conf.lo.accept_source_route = 0
# net.ipv4.conf.eth0.accept_source_route = 0

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

# Increase maximum amount of memory allocated to shm
# Only uncomment if needed!
# kernel.shmmax = 67108864

# Disable ICMP Redirect Acceptance
# Default should work for all interfaces
net.ipv4.conf.default.accept_redirects = 0
# net.ipv4.conf.all.accept_redirects = 0
# net.ipv4.conf.lo.accept_redirects = 0
# net.ipv4.conf.eth0.accept_redirects = 0

# Enable Log Spoofed Packets, Source Routed Packets, Redirect Packets
# Default should work for all interfaces
net.ipv4.conf.default.log_martians = 1
# net.ipv4.conf.all.log_martians = 1
# net.ipv4.conf.lo.log_martians = 1
# net.ipv4.conf.eth0.log_martians = 1

# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 25

# Decrease the time default value for tcp_keepalive_time connection
net.ipv4.tcp_keepalive_time = 1200

# Turn on the tcp_window_scaling
net.ipv4.tcp_window_scaling = 1

# Turn on the tcp_sack
net.ipv4.tcp_sack = 1

# tcp_fack should be on because of sack
net.ipv4.tcp_fack = 1

# Turn on the tcp_timestamps
net.ipv4.tcp_timestamps = 1

# Enable TCP SYN Cookie Protection
net.ipv4.tcp_syncookies = 1

# Enable ignoring broadcasts request
net.ipv4.icmp_echo_ignore_broadcasts = 1

# Enable bad error message Protection
net.ipv4.icmp_ignore_bogus_error_responses = 1

# Make more local ports available
# net.ipv4.ip_local_port_range = 1024 65000

# Set TCP Re-Ordering value in kernel to ‘5′
net.ipv4.tcp_reordering = 5

# Lower syn retry rates
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 3

# Set Max SYN Backlog to ‘2048′
net.ipv4.tcp_max_syn_backlog = 2048

# Various Settings
net.core.netdev_max_backlog = 1024

# Increase the maximum number of skb-heads to be cached
net.core.hot_list_length = 256

# Increase the tcp-time-wait buckets pool size
net.ipv4.tcp_max_tw_buckets = 360000

# This will increase the amount of memory available for socket input/output queues
net.core.rmem_default = 65535
net.core.rmem_max = 8388608
net.ipv4.tcp_rmem = 4096 87380 8388608
net.core.wmem_default = 65535
net.core.wmem_max = 8388608
net.ipv4.tcp_wmem = 4096 65535 8388608
net.ipv4.tcp_mem = 8388608 8388608 8388608
net.core.optmem_max = 40960

# Disable ping requests

net.ipv4.icmp_echo_ignore_all = 1

Run following command to make it effect

/sbin/sysctl -p
/sbin/sysctl -w net.ipv4.route.flush=1

Fine tune GCC parameters to boost APACHE 2.2

19/05/2007 14:10

First get CPU infomation from /prco/cpuinfo
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Pentium(R) 4 CPU 3.00GHz
stepping : 1
cpu MHz : 3000.000
cache size : 1024 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 3
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe constant_tsc pni monitor ds_cpl cid xtpr
bogomips : 6029.46

Change CFLAGS to
-O3: The higher value, the smaller binnary file. But in practical, I did not feel and speed boost. I prefer 3 rather than 6 now, as it can save much time on compiling
-msse2 : enable SSE2 CPU instrcution
-mmmx : enable MMX CPU instrcution
-mfpmath=sse : Generate floating point arithmetics for SSE unit
-mtune=pentium4 : Special optimized for P4
-fomit-frame-pointer” : Removes the frame pointer for all functions, as it is a production server

After changing those parameters, my apache server boost around 10%

Block msn traffic using CISCO policy-map

05/05/2007 22:10

1. Using ACL block relavent port to msn, such tcp/udp 1836, etc.
2. But, as we all know, msn 7.5 can use http(tcp 80 port) go through firewall. There are some sample of msn http header
Here is the first request and response in a notification server session:

POST http://gateway.messenger.hotmail.com/gateway/gateway.dll?Action=open&Server=NS&IP=messenger.hotmail.com HTTP/1.1\r\n
Accept: */*\r\n
Accept-Language: en-us\r\n
Accept-Encoding: gzip, deflate\r\n
User-Agent: MSMSGS\r\n
Host: gateway.messenger.hotmail.com\r\n
Proxy-Connection: Keep-Alive\r\n
Connection: Keep-Alive\r\n
Pragma: no-cache\r\n
Content-Type: application/x-msn-messenger\r\n
Content-Length: 18\r\n
\r\n
VER 5 MSNP8 CVR0\r\n

HTTP/1.0 200 OK\r\n
Server: Microsoft-IIS/5.0\r\n
Date: Tue, 18 Mar 2003 07:39:53 GMT\r\n
X-MSN-Messenger: SessionID=954547325.13160; GW-IP=207.46.110.18\r\n
Content-Length: 18\r\n
Content-Type: application/x-msn-messenger\r\n
Age: 0\r\n
Via: HTTP/1.1 ntl_site (Traffic-Server/5.2.0-R [c sSf ])\r\n
X-Cache: MISS from nautilus.localdomain\r\n
X-Cache-Lookup: MISS from nautilus.localdomain:80\r\n
Proxy-Connection: keep-alive\r\n
\r\n
VER 5 MSNP8 CVR0\r\n

Here is the first request in a switchboard server session:

POST http://gateway.messenger.hotmail.com/gateway/gateway.dll?Action=open&Server=SB&IP=207.46.108.13 HTTP/1.1\r\n
Accept: */*\r\n
Accept-Language: en-us\r\n
Accept-Encoding: gzip, deflate\r\n
User-Agent: MSMSGS\r\n
Host: gateway.messenger.hotmail.com\r\n
Proxy-Connection: Keep-Alive\r\n
Connection: Keep-Alive\r\n
Pragma: no-cache\r\n
Content-Type: application/x-msn-messenger\r\n
Content-Length: 55\r\n
\r\n
USR 3 phil_sayers@hotmail.com 214963.1047973248.28908\r\n

Here is a message polling the server for queued messages, and finding none:

POST http://207.46.110.18/gateway/gateway.dll?Action=poll&SessionID=954547325.32498 HTTP/1.1\r\n
Accept: */*\r\n
Accept-Language: en-us\r\n
Accept-Encoding: gzip, deflate\r\n
User-Agent: MSMSGS\r\n
Host: 207.46.110.18\r\n
Proxy-Connection: Keep-Alive\r\n
Connection: Keep-Alive\r\n
Pragma: no-cache\r\n
Content-Type: application/x-msn-messenger\r\n
Content-Length: 0\r\n
\r\n

HTTP/1.0 200 OK\r\n
Server: Microsoft-IIS/5.0\r\n
Date: Tue, 18 Mar 2003 07:39:56 GMT\r\n
X-MSN-Messenger: SessionID=954547325.6942; GW-IP=207.46.110.18\r\n
Content-Length: 0\r\n
Content-Type: application/x-msn-messenger\r\n
Age: 1\r\n
Via: HTTP/1.1 ntl_site (Traffic-Server/5.2.0-R [c sSf ])\r\n
X-Cache: MISS from nautilus.localdomain\r\n
X-Cache-Lookup: MISS from nautilus.localdomain:80\r\n
Proxy-Connection: keep-alive\r\n
\r\n

Here is a message closing the session from the client side:

POST http://207.46.110.18/gateway/gateway.dll?SessionID=954547325.3500 HTTP/1.1\r\n
Accept: */*\r\n
Accept-Language: en-us\r\n
Accept-Encoding: gzip, deflate\r\n
User-Agent: MSMSGS\r\n
Host: 207.46.110.18\r\n
Proxy-Connection: Keep-Alive\r\n
Connection: Keep-Alive\r\n
Pragma: no-cache\r\n
Content-Type: application/x-msn-messenger\r\n
Content-Length: 5\r\n
\r\n
OUT\r\n
HTTP/1.0 200 OK\r\n
Server: Microsoft-IIS/5.0\r\n
Date: Tue, 18 Mar 2003 07:41:39 GMT\r\n
X-MSN-Messenger: SessionID=954547325.1484; GW-IP=207.46.110.18; Session=close\r\n
Content-Length: 0\r\n
Content-Type: application/x-msn-messenger\r\n
Age: 0\r\n
Via: HTTP/1.1 ntl_site (Traffic-Server/5.2.0-R [c sSf ])\r\n
X-Cache: MISS from nautilus.localdomain\r\n
X-Cache-Lookup: MISS from nautilus.localdomain:80\r\n
Proxy-Connection: keep-alive\r\n
\r\n

3. define class-map
class-map match-any im
match protocol http s-header-field “MSMSGS”
match protocol http c-header-field “MSMSGS”
match protocol http url “*gateway.messenger.hotmail.com*”
match protocol http url “*messenger.hotmail.com*”
match protocol http url “*messenger.msn.com*”

this class-map trys to find the package with “MSMSGS” in the header and the packages contains gateway.messenger.hotmail.com, messenger.hotmail.com, messenger.msn.com

4. create policy-map to drop the package with above attributes
policy-map block-p2p
class im
drop

5. then apply it on either in or out, or both
interface FastEthernet0/1
service-policy input block-p2p
service-policy output block-p2p

THIS IS ONLY AN EXPERIENTAL, THERE IS NO ANY KIND OF GURANTEE ON IT

“ATOMIC BAND” - ITune Server

12/04/2007 23:26

Network: Most of machines are running Mac OS X, some are running Windows XP

Server: Running latest Fedore Core 6. Two hard disks, one for operating system and file/web server(160G), another one stores hourly backup(200G)

Requirement: rpm-build, gcc, libid3tag, libid3tag-devel, gdbm-devel, howl-devel, zlib-devel, and of course mt-daap(SRPM)

A good article to start with can be found on sblog. However, to install/rebuild mt-daap is not that straight forward. I build mt-daap from SRPM file using rpmbuild, and it depends on libid3tag, libid3tag-devel, gdbm-devel, howl-devel packages. You can simply install libid3tag, libid3tag-devel, gdbm-devel from YUM repository, but FC abandoned howl-devel since version 5. :( Looking arround in google, I found following package from rpmfind

-rw-r–r– 1 root root 107131 Apr 12 11:27 howl-0.9.8-3.i386.rpm
-rw-r–r– 1 root root 121394 Apr 12 11:26 howl-devel-0.9.8-3.i386.rpm
-rw-r–r– 1 root root 86547 Apr 12 11:27 howl-libs-0.9.8-3.i386.rpm

they are coming from FC4 repository, but you are safe to use them for your FC6 box. Apart from this, you can follow the detailed instruction on sblog. It wouldnt take more than 30 minutes, and you will have a fantastic ITune server in your network