搜索
Table_bottom

标签云
Table_bottom

分类
Table_bottom

声明
文章若未特別註明,皆採用 知识共享许可协议 請自覺遵守
Table_bottom

鏈。。。
Table_bottom

存档
Table_bottom

匆匆过客
88335
Table_bottom

功能
Table_bottom

Linux下的聲音質量

這主要是一篇翻譯,原帖在 https://www.linuxquestions.org/questions/linux-newbie-8/sound-quality-in-linux-610168/

該帖子比較老(2010年),其中所說的有些狀況現在已有了改變——當然是朝好的方面改變——但道理無誤。


發帖者說他對其朋友的一段話比較疑惑,所以發這麼一個帖子問問大家的意見。朋友的話是這麼回事:

he is not satisfied with the quality of sound in Linux(fedora7).

他對Linux (fedora 7)下的聲音質量不滿意。

All of u try this : play the same song simultaneously on a linux &
windows machine, u will notice difference in sound quality.

你們可以這樣試一下:同時在一臺Linux和一臺Windows機器上放同一首歌,(這樣)你們會注意到音質的不同。


While looking at the sound settings, he found that Fedora uses generic
ALSA sound drivers. He think that the quality is not good because the
drivers are generic, they are not specific.

當查看聲音設置時,他發現fedora使用通用的ALSA音頻驅動。他認爲這樣的質量不夠好,因爲這是通用驅動而非專用驅動。

下面數個樓層(1#到15#)主要話題是這麼幾個:“根據我的經驗來說並沒有什麼不同”;“在兩臺不一樣的機子上比較的結論並沒有什麼意義”;“認爲不同的請去做無偏見測試(blind test)然後再來說”;“‘聲音質量’是個很模糊的術語,請詳細描述”。

其中技術性較強的是:“ALSA上沒有什麼‘通用’(generic)驅動”;“有可能是設置的問題,你可以如何如何做一下試試”。

10-12#是兩個人在爭,其中10#的內容我沒看懂,期望哪位(如果有)幫忙解釋一下他在說什麼。

重頭戲在於14#及其在16#、18#回覆的內容:其中16#給出了這個問題最直白的答案,14#和18#也都很有意義。

16#是對15#的回覆;15#是對14#的回覆;18#是對17#的回覆。

這裏先翻譯一下16#以饗衆人,14#、15#、18#的翻譯隨後附上:

I totally agree with you on what you've said. There is no difference.

我完全同意你說的。它們之間沒有區別。

To make clear once and for all, people should keep in mind we're talking about **digital signals** here, processed in a lossless (PCM) manner. If there are no resamplings or any other effects applied to the PCM stream, any OS is pretty much the same!

爲了一勞永逸地說清楚這個問題,人們需要在腦中時刻牢記我們在討論數字信號——已處理成無損的(PCM)形式。如果沒有重採樣(resampling)或任何其他附加在PCM流中的特效的話,任何操作系統都是一樣好的!

It works just like this:

這個過程大概是這麼回事:

*You open the application that will play your songs.

你打開一個要播放你歌曲的程序。

*The application uses the appropriate demuxer (to deal with .mp3, .wma, .ogg, .m4a... extensions) to get the encoded stream (wma, mp3, aac, flac, ogg...).

這個程序使用合適的分離器(demuxer)(爲了處理.mp3、.wma、.ogg、.m4a等擴展)以得到編碼後的音頻流(wma、mp3、aac、flac、ogg等)。

*Then there is a decoder that will convert back the encoded stream into a PCM stream [the application could, then, make use of some DSPs to resample or up / downmix by itself].

然後這裏有個解碼器,它會將編碼好的流轉換回PCM流[應用程序可以——在此之後——使用一些數字信號處理技術(DSP)來自己進行重採樣或是up / downmix]。

*The PCM stream, most likely to be untouched by the application, is sent to your sound system.

該PCM流——一般情況下未被應用程序碰觸——被送到你的聲音系統。

Now, when it comes to the PCM stream and the sound system, things are just like this:

現在,輪到PCM流和聲音系統時,事情是這麼回事:

*If you have a sound server, like Pulse Audio, the PCM stream is sent to the Pulse server. Pulse up / downsamples the PCM stream if it is different of its own settings (you can change Pulse default sampling rate by editing the "/etc/pulse/daemon.conf" file, it also up / downmixes the PCM file if its told to,

如果你有一個音頻服務器(sound server)——如Pulse Audio——該PCM流會被送到Pulse服務器。Pulse會對該PCM流進行向上/向下採樣(up  /downsample)——如果它和Pulse自己的設置不同的話(你可以通過編輯/etc/pulse/daemon.conf文件來修改Pulse的默認採樣率,它也可以在被告知如此做時up / downmix該PCM文件)。

*and, at last, the processed (or maybe untouched) PCM stream is sent to ALSA system.

以及,最後一步,被處理過的(也可能是沒被碰觸的)PCM流被送到ALSA系統。

I'm not going to get into deeper details on how things work under Windows or OS X, for example, because things are almost the same with all of them. The point is: the **true** maximum audio quality is achieved but getting the PCM stream untouched to the sound card. That ANY operating system can do, including Linux.

我不打算深入如Windows或OS X中事情如何工作的細節,因爲事情在它們中幾乎是一樣的。重點在於:真正的最大聲音質量由(原文中是but,疑似by之訛誤)傳輸未碰觸的PCM流至聲卡中來達成。這是任何操作系統都可以做到的,包括Linux。

ALSA is able to do the resampling stuff on its own, but it's not as configurable as Pulse Audio. I myself like to set Pulse to 44,1 KHz sampling and S32_LE resolution all the time, except when I have to deal with 48 KHz audio samplings. I know for sure my sound card works only at 48, 96 or 192 KHz on Linux, but its audio processor (X-Fi) has an excellent resampler using advanced techniques. So, I prefer to always let the sound card to the processing.

ALSA可以自己進行重採樣工作,但沒有Pulse Audio那麼好的可配置性。我個人喜歡始終設置Pulse爲44.1KHz採樣率以及S32_LE分辨率(resolution)——除非當我需要處理48KHz音頻採樣時。我很確定我的聲卡在Linux下僅可以工作於48、96或192KHz,但它的音頻處理器(X-Fi)有極好的使用高級技術的重採樣器。所以,我傾向於始終讓聲卡自己來處理。

If you don't have such hardware capabilities, I guess you'd really want to consider taking a look at this website.

如果你沒有這樣的硬件條件,我猜你會想要看一下這個站點

Up and downmixing on Linux, anyway, is flat and 2 dimensional as I've said. I've already tried ALSA "vdownmix" plugin, it works but it's not yet as well implemented as Creative's own HRTF technology.

在Linux中,Up 及 downmixing始終是平(flat)的以及2維的——就像我說過的那樣{參見14#}。我已經試過ALSA “vdownmix”插件——它可以工作,但是尚未有創新自己的HRTF技術那樣實現完備。

Amarok has a built in equalizer that does its job, specially when set to "Rock" if I'm not wrong. aTunes also has its own equalizer but it sounds horrible and is not worth a try.

Amarok有它自己的均衡器來做這件事,尤其是當設置成“搖滾(Rock)”時——如果我沒記錯。aTunes也有它自己的均衡器,但聽起來極其可怕並且不值得一試。

So, quality is the same on every OS if you know how to set them up. Here I've left the tips of mine to help anyone who would occasionally be interested.

所以,在任何操作系統中,只要你知道如何設置,聲音質量都是一樣的。這裏我留下一些我自己的建議,以幫助任何可能有興趣的人。

> Preferably, don't do any resamplings.

> 最好不要做任何重採樣。
> Tell Pulse and / or ALSA to always use the highest definition for your sound card (mine is 24 bit, so I use the S32_LE instruction both under Pulse and ALSA).

> 告訴Pulse和/或ALSA總是使用你聲卡的最高精確度(我的是24位,所以我在Pulse和ALSA下均使用S32_LE指令)。
> Avoid multichannel if all you have is a pair of speakers or headphones, or try the not so well implemented "vdownmix" plugin for ALSA.

> 如果你僅有一對揚聲器(speaker)或者耳機(headphone),避免多聲道,或者使用ALSA中尚未完善的vdownmix插件。
> Try Amarok equalizer (probabily set to "Rock") to help improve a bit the perceived sound quality.

> 嘗試Amarok均衡器(很可能是設置爲“搖滾(Rock)”)以幫助增強一點感知到的聲音質量。

Best wishes to everyone here and to Linux in the hope that it continues to improve and to be a more and more appealing alternative to MS Windows or Apple OS X.

致祝願於這裏所有人,以及給Linux——期望它可以繼續改進並且成爲一個愈來愈吸引人的MS Windows或Apple OS X替代選擇。

14#:

I don't know precisely what problem you guys are talking about, anyway, I want to leave here the comment of mine on this subject.

我並不確切你們在討論什麼問題,不過不管怎麼說,我想在這留下我對這個主題的看法。

I own a Creative SoundBlaster X-Fi XtremeMusic. On Windows, Creative's drivers offer you technologies fully implemented in hardware like Crystalizer and CMSS-3D.

我有一個創新的聲霸卡X-Fi XtremeMusic。在Windows上,創新的驅動提供了全部由硬件完成的技術,如Crystalizer和CMSS-3D。


Crystalizer stands for a really dynamic equalizer which adjusts itself according to the quality of the sound the card is fed with. For example: if I'm playing a 96kbps MP3 file, with considerable loss of high frequencies, the card is able to play with its own equalizer, the one specifically called Crystalizer, so you can kind of restore the lost frequencies (that's the illusion you have).

Crystalizer代表一個真正動態的均衡器的,它可以根據卡片收到的音頻的質量進行自我調整。舉例子:如果我在播放一個96kbps的MP3文件——其中顯然會有高頻中的大量丟失——這個卡片可以用它自己的均衡器——那個叫Crystalizer的東西——來播放,所以可以在某種程度上恢復那些丟失的頻率(這是你會感受到的幻覺)。

CMSS-3D stands for a multi purpose surround sound mixer. For example: if you have a 5.1 home theater speakers setup and want to play a stereo sound, the CMSS-3D technology is able to identify instruments on the sound the card is fed with and dynamically distribute it through all the available speakers. It's a totally active design, that's why I say "dynamically". If on the other hand, all you have is a pair of speakers or headphones, the card is able to mix into stereo channels up to 8 surround sound channels with Creative's proprietary HRTF technology. It immerses you into your DVD / BD movies or 3D games.

CMSS-3D代表一個多用途的環繞聲混音器。舉個例子:如果你有一個5.1聲道的家庭劇場設備,並且你想放一個立體聲音頻,CMSS-3D技術可以分辨出卡片收到的音頻中的樂器並且(然後)由所有可用的音箱中動態地分發它。這是一個完全主動的設計——這就是我爲什麼說”動態“。如果說是另一種情況——你只有一對音箱或者耳機(headphone)——該卡可以利用創新的專有HRTF技術在立體聲的聲道中插入最多8個環繞聲聲道。它可以讓你沉浸入你的DVD/BD影片或者3D遊戲中。

That could all be implemented on Linux for sure IF there was any sort of interest from Creative's Linux driver people. Anyone knows for sure it'll never happen anymore, thus, we're left with a complete 2D and raw sound experience with Linux or any other OS except Windows with Creative's sound cards.

這些當然可以在Linux上實現——只要創新那寫Linux驅動的人有那麼幾分興趣。(然而)任何人都很確定這並不會發生,因此我們在Linux或任何其他非Windows的系統上使用創新的聲卡時,均被離棄在一個純2D和裸的聲音體驗中。

I often test new Linux distributions but can never stay with anyone of them because of the lack of such important technologies. I have 3 headsets, high fidelity ones (12 to 28 KHz frequency range and near 20 bit sound quality), and I very frequently watch 5.1 CH videos and play 5.1 CH games. I just couldn't live without CMSS-3D. Besides that, X-Fi Crystalizer is just so amazing I have no pleasure on listening to anything without it.

我經常測試新的Linux發行版,然而無法在其中任一上停留——因爲缺乏如此重要的技術。我有3個耳機(headset)——高保真的(12到28KHz的頻域以及接近20位的聲音質量)——並且我時常看5.1聲道影片和玩5.1聲道遊戲。我簡直無法離開CMSS-3D。另外,X-Fi Crystalizer也是那麼的令人驚奇以至於我在離開它聽任何東西時都覺得索然無味。

Linux, OS X and Windows do have almost no difference in sound quality. Up to XP, with such a good card as the X-Fi, Windows was the best out of the three. Having them all properly set up not to make any sort of resamplings, they're all the same. Each, of course, deal with latency a different way. I'm not quite familiar with other OS'es but at least Windows has WASAPI and works admirably with ASIO 2.0 and OpenAL (hardware accelerated, opposed to software rendered on Linux and OS X). These APIs are quite good on latency, specially ASIO. Anyway, without resampling and not taking into consideration latency, any OS should be the same.

Linux、OS X和Windows在聲音質量上真的幾乎沒有什麼區別。直到XP,在使用如此好的X-Fi卡片時,Windows是它們三個中表現最好的。把它們都設置好且不使用任何重採樣(resampling)之後,它們(的表現)都是完全一樣的。當然了,它們使用不同的方法對待延遲(latency)。我並不特別熟悉其他的操作系統,但是至少Windows有WASAPI並且在使用ASIO 2.0和OpenAL(硬件加速,和Linux及OS X上的軟件渲染相反)時表現極好。這些API在延遲上表現良好,尤其是ASIO。(當然)無論怎麼說,在不使用重採樣並且不考慮延遲時,任何操作系統的表現都應當是一樣的。

Now, when it comes to improvements implemented in hardware / driver, no doubt Windows wins (on Creative's side, specifically).

現在,當考慮到硬件或是驅動上實現的增強時,Windows贏得毫無疑問(僅限創新)。

I'll just keep using Linux once in a while with its 100% software rendered, mixed, resampled audio, quite flat and 2 dimensional.

我仍舊會時不時地使用Linux——100%軟件渲染、混音、重採樣音頻,特別平(flat)的以及2維的(聲音)。

For the best quality and user experience and full use of my hardware capabilities, I'll unfortunately have to stay with Windows.

爲了追求最好的質量以及用戶體驗,並且完全使用我的硬件規格,我很不幸地不得不留在Windows上。

By the way, have any of you ever realized that Linux just doesn't grow on the "hardware accelerated" industry? The most it gets is OpenGL. There are no solutions to fully decode in hardware video streams, like MPEG2 or H.264, or to mix audio streams from different sources, or to process MIDI, or EAX effects, or audio resempling, downmixing, or TCP offload, or whatever. Everything, except OpenGL is software implemented. I shame indeed!

順便說一下,你們是否意識到Linux並不長在”硬件加速“的產業上?它得到得最多是OpenGL。沒有任何的硬件解碼視頻流——例如MPEG2或者H.264——,或者合併不同源頭的音頻流,或者處理MIDI,或者EAX效果,或者音頻重採樣、downmixing,或者TCP offload,或者其他東西的方案。任何東西——除了OpenGL——都是軟件實現的。我實在感到恥辱。

15#:

Well, that is of course the whole issue. Most hardware manufacturers put all their efforts into developing drivers for Windows. Linux, if it is even considered at all, is an afterthought at best. The companies that fully support linux and open source their drivers (for example Ralink wireless cards) have hardware that works just as well in linux as it does in Windows.

說起來,這當然就是所有問題所在。大多數硬件製造商將它們的精力全都放在開發Windows驅動上。至於Linux——如果它被考慮了的話——最好的情況也是一個靠後之事。那些有完善Linux支持並且願意公開驅動源代碼的廠商(例如Ralink無線網卡)所產硬件在Linux和Windows上的表現一樣好。

For those who swear that sound is "better" in Windows, perhaps try a blind comparison. Install Windows and linux on the same computer. Have a friend boot either Windows or linux randomly and play some music. See if you can consistently tell whether Windows or linux is playing the music. You may be surprised at what you find. Even the (supposedly golden eared) high end audio reviewers at Stereophile magazine dare not do blind comparisons of audio hardware.

對於那些信誓旦旦說在Windows中聲音“更好”的人,你們應當嘗試一下無偏見比較(blind comparison)。在同一臺電腦上安裝Windows和Linux。讓一個朋友隨意啓動Windows或Linux並且播放同一首音樂。看看你能否始終如一地分辨出播放音樂的到底是Windows還是Linux。你或許會對你自己的發現感到驚訝。即使是那些Stereophile雜誌中(號稱金耳的)高端音頻評測者也不敢對音頻硬件做無偏見比較。

17#提出了這麼一個問題:“在播放音樂文件時候Windows上和Linux上效果一樣,但是在放DVD影片時候Windows中音量比Linux下大,不知道爲什麼。”

18#:

The "problem" you talk about exists on Windows too. We're actually talking about a Dolby Digital issue. It's not exactly a problem though, nothing that has got to be fixed. Dolby Digital has a lower audio range, output, volume, whatever they call it, meaning it sounds lower than other formats, like DTS (which happens to be better concerning audio quality).

你所說的這個“問題”在Windows上其實也有。我們在討論的其實是Dolby Digital的事情。它其實並不是個問題,所以也沒什麼可修復的。Dolby Digital有一個更小的聲音範圍/輸出/音量——不管怎麼叫它吧——,意味着在和其他格式——例如DTS(考慮到聲音品質時它恰好更好)——比較時它聽起來聲音更低。

Windows 7, for example, has a built-in Dolby Digital decoder. If you right-click the video screen (on Media Player) and go to "Enhancements" (I'm not sure that's what it's like on the English version of the software since I use the Br-Portuguese version) you can click "Dolby Digital settings" and it will give you three options for you to choose: "Normal", "Night" and "Cinema". If you choose "Normal" you're going to have a boost on low volumes and a decrease on the excessively high ones. If you choose "Night", you'll have the same softened output but a slight increase on the dialogs (I guess this one sounds better for onboard sound solutions). Now, if you choose "Cinema" mode, then you'll have the same exact output that the DVD was intended to have, called full dynamic. At times the sound will be low, and at times high, it'll vary dynamically. Most people won't like it if they don't have a good sound card, capable of high dynamics in audio, and a good speaker system or headphones too.

Windows 7——例子而已——有一個內建的Dolby Digital解碼器。如果你在視頻界面上右鍵(在Media Player中{即Windows Media Player,Windows自帶的播放器})並且轉到“增強(Enhancements)”(我不確定在英文版中它到底叫什麼,因爲我用的是巴西葡萄牙文(Br-Portuguese)版),這樣你可以點擊“Dolby Digital設置(Dolby Digital settings)”,然後它會給你三個可選項:“正常(Normal)”、“夜間(Night)”、“影院(Cinema)”。如果你選擇“正常”,你會在低音量時得到增強且在高音量時減弱;如果你選擇“夜間”,你會得到相同的柔化了的(softened)輸出但在對話中得到輕微增強(我猜這會在板載(onboard)聲音解決方案{集成聲卡?}中聽起來更好一些);現在,如果你選擇“影院”模式,你會得到同該DVD被預期得到的效果完全一樣的輸出——這被稱爲全動態(full dynamics)。有時聲音會低,有時會高——它會動態變化。多數人並不喜歡它,因爲(if)他們沒有一塊好聲卡——適用於音頻中的高動態——以及好的揚聲器(speaker)系統或耳機(headphone)。

I don't know which Dolby Digital decoder you've chosen under Windows XP, since it doesn't have a built-in one, I'd recommend, by the way, AC3Filter, it's one of the bests out there. Anyway, it seems your decoder under Windows is set to something like the "Night" mode, giving you pretty much the same (high enough) volume experience throughout the whole video.

我不知道你在Windows XP中選的是哪個Dolby Digital解碼器,因爲它沒有內建的——順便一提,我建議AC3Filter,它是上佳之選中的一個。不管怎麼說吧,看起來你在Windows所用的解碼器被設置爲類似於“夜間”模式——給你在看整個視頻時以還原很好(pretty much the same)(足夠高)的聲音體驗。

Linux, on the other hand, doesn't have the same configurability of Windows 7 and other decoders like AC3Filter, and instead of choosing the "Night" mode equivalent as does your Windows XP decoder, it chooses the "Cinema" mode for quality purposes. As I've said, preferably, the encoded, compressed sound should be decoded and sent to your audio system **untouched**. If you have your system sound output set to stereo there is surely some processing done with the decoded DVD audio in order to fit it to 2CH outputs. Anyway, the Linux decoder tries to convert the compressed audio stream to PCM **as it is**, with the same output volume as is in the DVD. As said, too, Dolby Digital has lower volume if compared to other compression formats, like DTS, MP3, etc.. Thus, you have the impression that Linux sounds worse, which isn't true. Actually, it sounds better since it doesn't play with audio volume.

然而另一方面,Linux沒有如同Windows 7或者其他解碼器如AC3Filter之列的配置能力,並且它沒有像你的Windows XP解碼器那樣選擇“夜間”模式的等價物,而是出於質量考慮選擇“影院”模式。像我說過的那樣,較好情況下,該編碼、壓縮了的聲音應當被解碼並且原封不動地送往聲音系統。如果你將你系統的聲音輸出設置爲立體聲,其中顯然會有一些處理過程施加在解碼後的DVD音頻上——爲了使其適用於雙聲道(2CH)輸出。不管怎麼說吧,Linux解碼器會試着將壓縮過的聲音無差別地(as it is)轉換到PCM——同DVD中一模一樣的輸出音量。依然如前所述,Dolby Digital和其他格式——如DTS、MP3等——比起來音量更低。因此,你產生Linux聲音更差的感覺——其實並不正確。實際上,它聽起來更好,因爲它沒有調戲(play with)音量。

I don't know any solution to this but trying to increase both the PCM and Master volumes under ALSA Mixer (type on terminal "alsamix").

我並不知道該事情的解決方案——除了在ALSA Mixer(在終端中輸入“alsamix”{至少現在arch上應當爲alsamixer})中嘗試調高PCM和Master的音量。

I myself can't stand watching DVD's or any multichannel audio under Linux. Firstly because it has no advanced audio downmixing with well implemented HRTF techniques, as Creative's CMSS-3D. Secondly, it has no hardware accelerated MPEG-2 decoding. There are good [paid] choices for Windows out there, but for Linux the best you're gonna have is VLC which has plenty of choices for deinterlacing. Anyway, none of them have come even near to the quality of my hardware dedicated decoding under Windows. My ATI Radeon HD 3850 deinterlaces using vector adaptive algorithm with "pulldown" detection, that makes my DVD's look gorgeous! Let alone if I had a better card, like the 4000 series, with upscaling techniques!!! I like most Linux Mint and Ubuntu. I have made extensive tests with Mint 10 RC and Ubuntu 10.10. I can say that Totem DVD player, or Gnome Mplayer look just like Apple's DVD player on Mac OS X. Sound for me is not an issue on DVD's because of my better sound card.

我自己無法忍受在Linux下播放任何DVD或是多聲道音頻。首先,因爲它沒有任何使用實現良好的HRTF技術——例如創新的CMSS-3D——的高級音頻downmixing。其次,它沒有硬件加速的MPEG-2解碼。Windows上有許多良好的[付費]選擇,但是在Linux上你能得到的最好一種應當是VLC——它擁有大量的deinterlacing選擇。不管怎麼說,它們中沒有任何一個表現得哪怕是接近我在Windows下的硬件專用解碼。我的ATI Radeon HD 3850 deinterlaces使用帶有“pulldown”檢測的vector adaptive算法,它能讓我的DVD看起來絢爛奪目!更不用說假如我有一個更好的卡片——例如4000系列——擁有upscaling技術會如何了!我最喜歡Linux Mint和Ubuntu。我對Mint 10 RC和Ubuntu 10.10進行了多方面的測試。我可以說Totem DVD播放器或者Gnome Mplayer看起來就像Mac OS X上蘋果的DVD播放器一樣。歸功於我良好的聲卡,DVD的聲音對我來說並不是個問題。

 

逸事:死鎖之銳捷與AP

本文早就想寫了,但是直到寫這篇文章時纔決定要寫下來。

 

這件事發生時,我所用的操作系統是Windows 7 64bit Home Premium。

 

我們學校的上網方案採用的是銳捷。

銳捷上網撥號要用它的客戶端,而用電腦共享有線網絡當AP這事也是完全正常的。

本來銳捷客戶端是它的客戶端,使用完全正常。我嫌每次共享網絡都要自己敲一大串命令費事,也爲了給別人設置方便,就寫了個批處理文件來解決。

問題就出在這裏:一旦在開啓銳捷客戶端的同時運行那個批處理,就會發生死鎖。(從彈出UAC提示到客戶端窗口打開,中間需要一段時間,就在那段時間/UAC提示之前運行批處理)

具體表現是:銳捷認證成功;批處理的執行窗口沒有內容,但不會自動關閉;關機永遠無法完成,除非手動斷電。

這個現象經反復測試,每次都會重現。

我猜想原因是銳捷要使用網絡設備,於是進行某種程度的加鎖;而做AP的那個腳本使用Windows(Windows Vista起)自帶的一個叫Microsoft Virtual WiFi Adapter的東西,事先也要加鎖。這兩個動作導致調度出現問題,最後鎖上釋放不掉了……

 

有更清楚者望告知,謝過。

逸事:winsock導致網絡連接異常

(本文實寫於20140701)

昨天艾寧拎着電腦說上不去網,我就順手一查,結果發現這個事。

幾個基本情況:

操作系統是Windows7 64bit Home Basic,360之類的東西在我的勸說下卸載了,殺毒/反間諜軟件用的是微軟的MSE和Windows Defender。

之所以說是異事,因爲本身它有網絡連接,甚至共享網絡(通過自帶的Microsoft Virtual Wifi Adapter)給手機當AP時,手機都可以正常上網。

在確保有網絡連接的情況下(月底了,流量還有不少,就用我的手機當熱點),測試了一些命令,可以訪問因特網:

  • ping
  • tracert
  • nslookup
  • ftp

上面幾個命令發送了ICMP、UDP、TCP數據包,均可以訪問,說明並沒有哪個地方對特定類型包進行過濾。

本來還打算試試SSH,但是沒有合適的工具。抱着碰運氣的心態裝32bit的cygwin(沒有64位的包),嘗試ssh說無法解析,百思不得其解,於是又給刪掉了。

這裏有一個好玩的事:在*nix下,traceroute/tracepath使用的是UDP,而windows的tracert命令發送的是ICMP包。

但是當使用網絡瀏覽器時,不論是HTTP還是FTP都會出問題。

 

最後上網搜查一番,查到了一條命令:

netsh winsock reset

本來衹是抱着試試看的心態,結果還真就有用……

再細查,這條命令的作用是重置winsock。所以我就奇怪:winsock是何方神聖,會引起這麼大的問題?繼續翻閱資料,發現這貨其實就是windows的套接口API,原來叫Windows Sockets API,後來嫌長就給縮短了……

修復了這個問題之後,我仔細問她究竟做了些什麼。結果發現:她什麼都沒做……且網上搜到的那些文章也都說是莫名其妙就出了問題。

所以……原因完全找不到,也不知道這個問題下次什麼時候會發作……

再加上windows經常出現的奇怪死鎖現象(見這篇文章)……

 

三分慶幸:幸好不用windows多年了……

七分憂慮:windows上究竟有多少預料外的事會發生……

 

參考資料:

http://en.wikipedia.org/wiki/Winsock

http://my.oschina.net/u/246088/blog/71531

http://biaobiaoqi.me/blog/2013/04/23/winsock-kills-internet/

 

 

另,如有哪位知道原因,煩請賜教,在此謝過。

各操作系統典型用戶心態

這裏試圖用一些典型狀況加上簡短的語句來描述心態。

  • Windows用戶:
    • 嗯,我需要安一個軟件。怎麼辦呢?上網搜索軟件,滿世界求安裝包。終於找到了,下載,安裝。誒?這是什麼東西?我要的是AAA怎麼變成BBB了!?好吧是點到廣告了……找到真正的了,一路下一步。嗯?桌面上怎麼多了點奇怪的東西?算了不管了……
    • 啊,電腦慢了。用XXX優化軟件掃描一下。發現XX項目亟待優化!嗯?有個一鍵優化?點之。嗯?報告優化X項目需要安裝XX軟件。啊,原來安裝XX還有X、X、X等好處,怎麼不早點告訴我?安裝……
    • 誒,電腦出問題了。去網上提問好了……“標題:我的電腦有問題了;內容:誰能告訴我是怎麼回事啊!”……
    • 聽人說XX軟件不錯。啊?這軟件怎麼還要錢啊?找破解版的去。什麼?破解版的是盜版犯法,那我用綠色免安裝版可以了吧……
    • 我把系統/軟件升級了。A功能去哪了?B功能呢?我X!你們這羣人有毛病啊非得要換界面!舊版本的呢,我裝回去……
  • OS X用戶:
    • 嗯,我需要裝XX軟件。哦,99元,這麼貴啊。咦?XX和A、B、C軟件搭配一塊買只要125元?雖然A、B、C我現在都用不到,不過還是買了吧,說不定以後用得上呢。
    • 嘿,我新買了臺Machintosh。嘿嘿,很多東西都改了,和別人的不一樣了,又有了炫耀的資本了。咦,怎麼沒有XX?嗯,肯定是不需要。
  • GNU/Linux用戶:
    • 嗯,我需要XX功能。來條命令搜索一下源裏是不是已有軟件可以完成該功能。嗯?沒有啊,好吧去google一下。咦?真的沒有啊……好吧自己用腳本語言寫一個……
    • 啊,更新一下出問題了。嘗試一個個回滾看是誰出了問題。嗯,原來是X的緣故啊。搜索一下看還有沒有其他人和我有一樣的問題。嗯?沒有?好吧我去看看源代碼去。啊,源代碼是A語言的但是我不會,好吧有空的時候去學習一下。(一段時間後)終於解決了,學到好多東西啊,記錄一下吧。(順手跑一下更新)啥?軟件有新版本已經修復這個問題了?……

(註:隨着 windows小白級用戶 的涌入,這裏有向windows狀況發展的趨勢)

 

p.s. 顯然,不可能所有的用戶都是這樣的,但是個人認爲統計上的置信度至少有90%。

p.p.s. 因爲目前爲止沒有在外國待過,對外國的用戶的瞭解僅限於網絡上,故而可能有失偏頗(尤其是Windows)。但是個人覺得大體上不會差太多,因爲用戶都是人,本身就差不多。