前幾天花了點時間把server整理了一下。一開始是想讓server開機時可以自動傳送email告知開機成功,以及休眠時可以回傳IP位址以達成wake on lan避免休眠時臨時需要連線之窘境。於是著手研究,傳送email本來打算用工作排程器內建功能,後來發現常常失敗,搜尋後得知內建為非常陽春的功能,甚至照網頁所說outlook須先設定電子郵件帳號我卻沒有,所以能夠傳成功很詭異。後來改用sendemail.exe小程式,有很冗長的參數,不過也一一解決了。最後是自動回傳ip部分,參考網路寫了個vbs小程式,然後配合sendemail.exe傳送附件。
至此算是告一個段落,沒想到後來wake on lan的設定才是噩夢的開始。因為我是用虛擬router,所以並沒有另外接一個路由器而是直接接到中華電信小烏龜,並且也是用固定ip,與小烏龜的浮動ip不同。這是因為當初小烏龜內無法設定固定ip撥接,設定的話wifi會無法使用。於是我繞了路使用虛擬路由器monowall,也就是說網路線雖是接到server,但是實際上是透過虛擬路由才能夠連線,否則會是斷線狀態,算是增加安全性,這是前話。
不過這次搜尋了一下找到了中華電信小烏龜的密碼,登入後可以更改設定,發現要達成wake on internet因為小烏龜功能陽春必須每次重開後寫入arp table,加上如果照原本設想休眠後透過wol啟動也太過狹隘,如果是跳電等路由取得新浮動ip就沒用了。因此就整個大改,把小烏龜改成固定ip連線,arp table則透過遠端控制連入更改。至此以為問題結束,卻發現回到家無法遠端控制且原本設定無誤的splashtop也無法使用。因此又開始了debug之路。
最後結論是,McAfee不知為何把連接埠封鎖,把連接埠打開即可(記得6783,6784,6785皆要開啟,我本來只開啟6783,後來一團混亂)。另外關於回到家無法遠端連入小烏龜問題則在於Access Control下還有一個ip Addresses,必須輸入可以通過的ip才行。至此終於結束。
後來想一想直接買一台有支援wol的router好像最省事,算了,就當學習吧。
另外如果要達成wake on lan(internet)因為大部分路由器會檔broadcast封包,所以除非路由器有相關設定,否則需要設定NAT之後,使用參考資料最下方網址發送mask為255.255.255.255之magic packet,不然會啟動失敗。
sendemail格式
SENDEMAIL -s mail-server -t 收件人 -f 寄件人 -u "主旨" -o message-file="本文檔" -a "附加檔" -o message-charset=big5 -o message-header="Disposition-Notification-To:<回信收件人>"
參考資料
http://alycesrestaurant.com/sendemailexe.htm
http://zonble.net/archives/2006_07/867.php
http://ithelp.ithome.com.tw/question/10046673
http://www.pczone.com.tw/thread-155562.html
http://www.depicus.com/wake-on-lan/woli.aspx
http://tw.knowledge.yahoo.com/question/question?qid=1008100609144
http://www.dotblogs.com.tw/rachen/archive/2010/03/31/14328.aspx
2013年10月15日 星期二
2013年7月13日 星期六
有關Kmplayer利用VPN播放遠端電腦內媒體檔案LAG問題
經過交叉測試,確認是BUFFER不夠的問題,並且kmplayer似乎對讀取檔案時的流量要求有問題,會有遇到頂的情形。後來改用potplayer問題解決,讀取遇到高禎率時會提高讀取流量,並且BUFFER緩衝可以自己設定,後來設成300MB後問題圓滿解決。
後記:後來發現緩衝最大只能設到1024KB,不過還是一樣撥放順暢,所以推論應該是potplayer比kmplayer對於網路播放處理得比較好,可以對資料來源抓取速率無上限。
後記2:時間過久真的會忘記,緩衝設定的地方在參數選項-濾鏡-來源濾鏡/分離器-(你要撥放的檔案類型)...-緩存大小。並且設定完成後要退出程式重啟才會生效。
有關FTP及Apache上傳速度卡住問題
Apache部分
regedit裡新增兩個十進位DWORD
[HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Services \AFD \Parameters]
DefaultReceiveWindow = 327680
DefaultSendWindow = 327680
資料來源http://smallvoid.com/article/winnt-winsock-buffer.html
Configure the winsock default send- and receive-buffer size
12 October 2002 by Snakefoot | Comment » | Trackback OffUsually when reading about TCPIP there is only mentioned one Receive Window for a connection, which is used to control congestion created by network latency.
In the WinNT network architecture a layer is placed on top of the TCPIP layer called AFD(Ancillary Function Driver for Winsock). The AFD provides the winsock interface, which is used by most network applications in Windows and is also supporting things like DNS and DHCP.
The AFD uses two windows which acts as a flowcontrol for the application creating the socket:
To set the default size of the AFD-Windows use the following DWORD registry keys :
Related : Recommended settings for the TCP/IP stack
More Info MSDN - Write Scalable Winsock Apps Using Completion Ports
More info MS KB Q214397
More info MS KB Q246984
More info MS KB Q311084
In the WinNT network architecture a layer is placed on top of the TCPIP layer called AFD(Ancillary Function Driver for Winsock). The AFD provides the winsock interface, which is used by most network applications in Windows and is also supporting things like DNS and DHCP.
The AFD uses two windows which acts as a flowcontrol for the application creating the socket:
- Send Window: Used when the application is sending data over a connection, if more data is sent than the receiver is able to acknowledge then the AFD-Send-Window will block the transfer for the application, when it reaches the limit of the AFD-Send-Window. The application creating the socket can use setsockopt to adjust SO_SNDBUF.
- Receive Window: Acts just like the TCPIP-Receive Window, and when creating a Winsocket over TCPIP, then AFD will use the TCPIP Receive Window as AFD-Receive Window. The application creating the socket can use setsockopt to adjust SO_RCVBUF.
- 4096 bytes if less than 19 MByte RAM
- 8192 bytes if more than 19 MByte RAM
To set the default size of the AFD-Windows use the following DWORD registry keys :
Note that the AFD-Windows should be rounded to a multiple of memory page size (Usually 4096 Bytes). Not a multiple of the Maximum Segment Size(MSS) which is recommended for the TCPIP-Window.[HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Services \Afd \Parameters]
DefaultReceiveWindow = 16384
DefaultSendWindow = 16384
Related : Recommended settings for the TCP/IP stack
More Info MSDN - Write Scalable Winsock Apps Using Completion Ports
More info MS KB Q214397
More info MS KB Q246984
More info MS KB Q311084
FTP部分
簡單來說就是transfer buffer size需要加大。之前我的設定32768結果卡在2MB/s(我的上限是4MB/s),改成3276800後現在正常了,寫在這邊供需要的人參考。
資料來源:http://trac.filezilla-project.org/ticket/820
Ticket #820 (closed Bug report)
FileZilla Server incredibly slow
| Reported by: | prezla | Owned by: | ci-dev |
|---|---|---|---|
| Priority: | normal | Component: | FileZilla Server |
| Keywords: | Cc: | prezla, ci-dev, codesquid | |
| Operating system type: | Operating system version: |
Description
FileZilla Server 0.9.5 is incredibly slow. I was
running it for and FTP server, but have since swapped
it out for WARFTPd 1.82.0.10 because of the following
performance numbers (notice that FileZilla is almost 3
times slower than WARFTPd, and Microsoft FTP is only
about 1 sec slower than WARFTPd):
FileZilla Server 0.9.5:
ftp> get catalog.pdf
200 Port command successful
150 Opening data channel for file transfer.
226 Transfer OK
ftp: 42509572 bytes received in 18.24Seconds
2330.95Kbytes/sec.
Microsoft FTP Server 5.1 (XP):
ftp> get catalog.pdf
200 PORT command successful.
150 Opening BINARY mode data connection for
catalog.pdf(42509572 bytes).
226 Transfer complete.
ftp: 42509572 bytes received in 8.14Seconds
5221.02Kbytes/sec.
WARFTPd 1.82.00-RC10:
ftp> get catalog.pdf
200 PORT command successful.
150 Opening BINARY mode data connection for catalog.pdf
(42509572 bytes).
226 Transfer complete. 42509572 bytes in 7.00 sec.
(5930.465 Kb/s)
ftp: 42509572 bytes received in 6.99Seconds
6080.61Kbytes/sec.
My platform is:
Intel Pentium III 933
512 MB RAM
Microsoft Windows XP SP2
running it for and FTP server, but have since swapped
it out for WARFTPd 1.82.0.10 because of the following
performance numbers (notice that FileZilla is almost 3
times slower than WARFTPd, and Microsoft FTP is only
about 1 sec slower than WARFTPd):
FileZilla Server 0.9.5:
ftp> get catalog.pdf
200 Port command successful
150 Opening data channel for file transfer.
226 Transfer OK
ftp: 42509572 bytes received in 18.24Seconds
2330.95Kbytes/sec.
Microsoft FTP Server 5.1 (XP):
ftp> get catalog.pdf
200 PORT command successful.
150 Opening BINARY mode data connection for
catalog.pdf(42509572 bytes).
226 Transfer complete.
ftp: 42509572 bytes received in 8.14Seconds
5221.02Kbytes/sec.
WARFTPd 1.82.00-RC10:
ftp> get catalog.pdf
200 PORT command successful.
150 Opening BINARY mode data connection for catalog.pdf
(42509572 bytes).
226 Transfer complete. 42509572 bytes in 7.00 sec.
(5930.465 Kb/s)
ftp: 42509572 bytes received in 6.99Seconds
6080.61Kbytes/sec.
My platform is:
Intel Pentium III 933
512 MB RAM
Microsoft Windows XP SP2
Change History
2013年7月2日 星期二
android系統間藉由藍芽共用網路
轉錄http://www.scaine.net/site/2013/01/android-to-android-tethering-over-bluetooth/



Android to Android Tethering over Bluetooth
Posted on
I have a Galaxy Nexus (GNex hereafter) phone and a Nexus 7 (N7 hereafter) tablet. Since the N7 is WIFI only, it’s not much use on the bus unless I use some kind of tether back to my phone. Until recently, I’d simply created a WIFI hotspot on my GNex and the N7 would happily pick that up. However, this method of tethering has several drawbacks :
- It’s not battery friendly – both devices need to run their WIFI full time.
- It’s a broadcast – the hotspot’s SSID can be hidden of course, but anyone sniffing the airwaves will still see my hotspot and may attempt to hack it. Unlikely that they’d succeed, given that it’s WPA2, but still.
- I have to manually turn on the hotspot on my GNex and wait 20 seconds for my N7 to see the connection and get an IP address.
- I have to manually turn off the hotspot on my GNex.
- I also have to remember to turn back on WIFI on the GNex, or it’ll just use 3G all day thereafter, because turning on a hotspot automatically turns off your WIFI.
Lately, I wondered if there was a better way to do things. Could I use Bluetooth and just leave the service running full time?
Well, since both my devices run Android’s latest “Jelly Bean” release, I thought it would be a doddle to set up. I was wrong, sadly, because there’s a fairly obscure setting you have to set up before hand. However, once you know about that, it’s very simple. In the hope it helps you, here’s the full step by step :
First, and most obviously, turn on the both device’s “Bluetooth” setting.
You’ll need to do that on both devices.
Then, pair them up by clicking “Search for devices” on one of the devices and clicking on the name of other device. You’ll be asked to verify a PIN number. It doesn’t matter what the PIN number is, as long as it’s the same PIN number on both devices.
Now, on the GNex, here’s the bit that caused me a headache. Go to Settings, choose More… then choose Tethering & Portable Hotspot. In there, you have tick Bluetooth tethering. If you don’t, the tether will (silently!) fail and you’ll be left, like me, scratching your head.
Okay, now you’re ready to use the GNex’s internet via Bluetooth. All you have to do is tell the N7 to actually use it.
On the N7, go to Settings, then click on the word Bluetooth (not the toggle – the word). Finally, click on the name of your GNex you paired earlier. To get it all working, choose Internet Access.
That’s it. Assuming that your GNex has some kind of internet access, then so now will your N7 tablet, via Bluetooth.
I’ve only just completed this myself and initial impressions are that the browsing on my N7 is significantly slower than over WIFI (despite my GNex using WIFI). Obviously, there’s a bandwidth limitation when using Bluetooth – but at around 2Mbits, that shouldn’t hinder web page rendering. Both devices are Bluetooth 3 capable, although the GNex apparently has hardware capable of Bluetooth 4. However, from what I could find, all Bluetooth devices communicate at around 2Mbits unless they use other technology to create high-speed channels, such as Bluetooth 3′s HS capability, which simply creates a WIFI 802.11 channel – which would kind of defeat the purpose of this anyway!
Here’s the advantages of this set up, assuming the speed issue is all in my head :
- Low power Bluetooth will preserve battery on the N7.
- The devices will pair up when they see each other, so no manual steps to get internet access on the bus. (I need to confirm this – I have a sneaky suspicion that I still need to tell the N7 to use the GNex internet each time they reconnect – which would devalue this for me quite a bit)
- I can keep WIFI enabled on the GNex and this tether will simply use that faster connection if it’s available.
- I’m not advertising an available WIFI hotspot to everyone on the bus!
Time will tell. I’ll use it for a few days and see how it goes.
2013年3月4日 星期一
伺服器存放空間不足
關於此點找到三個方法,第一個比較容易找到,二三只有一項說明:
說明與方法︰
1. 啟動 [登錄編輯程式] (Regedt32.exe)。
2. 在登錄中找出並按一下下列機碼:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Memory Management
3. 在 [編輯] 功能表上,按一下 [新增值],然後新增下列登錄值:
數值名稱:PoolUsageMaximum
資料類型:REG_DWORD
底數:十進位
數值資料: 60
將值設定為 60,即會在達到 PagedPoolMax 的 60% (而不是預設設定的 80%) 時,通知「記憶體管理員」開始進行調整程序。如果 60% 的閾值不足以處理活動中突然增加的使用量,請將此設定降低至 50% 或 40%。
數值名稱:PagedPoolSize
資料類型:REG_DWORD
底數:十六進位
數值資料:0xFFFFFFFF
將 PagedPoolSize 設定為 0xFFFFFFFF,即會為電腦配置最大分頁集區來代替其他資源。
4. 結束 [登錄編輯程式]。
5. 請重新啟動伺服器,使變更生效。
參考知識文件:
KB312362 "Server is unable to allocate memory from the system paged pool" http://support.microsoft.com/kb/312362
KB304101 "Backup program is unsuccessful when you back up a large system volume" http://support.microsoft.com/kb/304101
請依下列步驟找到目前的 IRPStackSize 後更改為建議值 25.
a. 按一下 [開始],按一下 [執行]。
b. 輸入:regedit,然後按一下 [確定]。
c. 找到下列機碼: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanServer\Parameters d. 在右邊的視窗, 雙擊 IRPStackSize 的值。 提示: 如果 IRPStackSize 並不存在,請依下列方式建立:
(1). 在 Parameters 資料夾上按右鍵。
(2). 指向新增, 並選取 DWord 值。
(3). 輸入 IRPStackSize 重要: 請注意大小寫。
e. 更改底數為十進制。
f. 在值的資料欄輸入25然後按確定。
g. 結束登錄編輯程式。
說明與方法︰
1. 啟動 [登錄編輯程式] (Regedt32.exe)。
2. 在登錄中找出並按一下下列機碼:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Memory Management
3. 在 [編輯] 功能表上,按一下 [新增值],然後新增下列登錄值:
數值名稱:PoolUsageMaximum
資料類型:REG_DWORD
底數:十進位
數值資料: 60
將值設定為 60,即會在達到 PagedPoolMax 的 60% (而不是預設設定的 80%) 時,通知「記憶體管理員」開始進行調整程序。如果 60% 的閾值不足以處理活動中突然增加的使用量,請將此設定降低至 50% 或 40%。
數值名稱:PagedPoolSize
資料類型:REG_DWORD
底數:十六進位
數值資料:0xFFFFFFFF
將 PagedPoolSize 設定為 0xFFFFFFFF,即會為電腦配置最大分頁集區來代替其他資源。
4. 結束 [登錄編輯程式]。
5. 請重新啟動伺服器,使變更生效。
參考知識文件:
KB312362 "Server is unable to allocate memory from the system paged pool" http://support.microsoft.com/kb/312362
KB304101 "Backup program is unsuccessful when you back up a large system volume" http://support.microsoft.com/kb/304101
ftp behind firewall
經過一天的研究,總算知道為何之前有時候會連不上自己架的FTP了。原來是PASV和PORT模式的問題。如果FTP SERVER是在防火牆後面,那只開啟FTP PORT NAT是不足的,因為PASV模式SERVER會跟CLIENT說:「我把檔案藏在XXXX PORT,有本事就來拿吧。」所以防火牆也必須把SERVER另外開啟的PORT NAT才行,我自己的測試是大概從1140開始分配,可能會有所出入。
另外順帶一提,PASV模式是為了因應PORT模式SERVER要將資料傳送到CLIENT端,但CLIENT端卻位於防火牆後所以無法連接到而產生,所以使用PASV模式可以由SERVER端這邊主控而不會受制於CLIENT端之設定無法更改。
另外順帶一提,PASV模式是為了因應PORT模式SERVER要將資料傳送到CLIENT端,但CLIENT端卻位於防火牆後所以無法連接到而產生,所以使用PASV模式可以由SERVER端這邊主控而不會受制於CLIENT端之設定無法更改。
VitualBox m0n0wall
最近在玩這個東西,因為網路上找到的資料不是很詳細。自己試了之後節錄幾個重點:
- 一張網卡即可,不需用到兩張
- VirtualBox內之虛擬兩張網路卡,皆使用橋接網路卡,記得要選擇橋接到最後接到網路的那張網卡(如接有線是Ethernet,無線則選無線網卡)
- 接下來是重點,也是網路上都沒有提到的,雖然可能是太基本所以都沒被提到,不過設定好後記得到m0n0wall的web介面內修改firewall設定,不然再怎麼測試都是無法連接的(預設是block all)。
- 最後是如果有安裝virtualbox host虛擬網卡,則VPN會與192.168.56.1(虛擬網卡預設IP)相衝。這邊是指VPN client端與server端之subnet如果一致的話會造成無法開啟網路芳鄰,需注意(所以架設VPN server端最好使用較不常見之subnet,就是不要用192.168.1.1或者192.168.0.1這兩個以免從外部連回來時衝到)。
訂閱:
文章 (Atom)