程序员 网络撷翠


I simplified the TCP/IP/UDP discussion up there a little when I implied that IP (and hence UDP and TCP) would route packets from one device on a network to another device. More accurately, IP routes packets from one IP address to another IP address. The trick with multicasting, or sending the same packets of data at the same time to many devices is that certain IP addresses can be designated as multicast address and assigned to many devices at the same time.

The first thing to know about IP multicasting is that there only exists UDP multicasting. There’s no such thing as TCP multicast. Why not? See, the point of multicast is to be efficient with the network and send the same data packet to as many different, possibly unknown computers. But each TCP connection can potentially require retransmission of different lost packets, or different delays or ordered arrival and assembly of packets. So managing and sending all that for each possible device would be resource-intensive even if it were possible, which would defeat much of the point of using multicast. (And it’s not possible anyway because multicast can’t know where the outbound packets actually wind up.)

Oh, and via back-formation, regular non-multicast UDP (and TCP) messages are called unicast.

The next thing to know is that multicast will often not be sent over a router to another network. There are a few reasons why:


    • A low TTL for most multicast packets: All IP packets have a time-to-live, or TTL. Unlike with DNS records, TTL on IP packets refers to the maximum number of network hops that a packet can make to get to its destination. Unicast packets typically are allowed to cross about 30 networks (i.e., get routed by, or “hop”, 29 routers). Getting across the internet rarely takes more than 15 hops, so the limit is really just to kill packets if they get stuck in loops in badly configured networks. But most applications that send multicast set the TTL to a low number, often zero (where the message doesn’t even leave the originating device),


    • one (so it will go only to computers on the local net), or two (where it will cross a single router). It’s quite rare to have an application that is intended to multicast to unknown machines over an entire campus network, much less the entire Internet.


    • High TTL thresholds set on most routers: Many network routers, particularly WAN routers and internet gateway routers, have a higher TTL threshold set, such that they won’t send out multicast packets whose TTL is below (say) 15. This is intended to prevent accidental leakage of multicast off a local network.


    • Routers are simply not configured to route multicast at all, or only configured for specific addresses, or otherwise blocking multicast packets.

UDP multicast might seem a bit exotic, but it’s actually more common that you think. It’s not used for web video sites like YouTube, since those need to send a video at a time each user demands, rather than at the same time for all users, and it’s not used for VoIP traffic. However, it is used for a lot for discovery and automatic confguration in apps like Skype, iTunes, and uPnP. It’s also used in a few places in the WCI portal.


程序员 网络撷翠

Discuz X2.0:如何限制游客访问主题和回复帖内容?

适用版本: discuz X2
修改 \template\default\forum\viewthread_node_body.htm


What is private bytes, virtual bytes, working set?

Often confusing concepts in performance monitor.


SQL Snippets

It seems I will be using SQL more and more often, so I am keeping some sql snippets here so I can come back here for reference in future.


Examples of using Regular Expression in Visual Studio Editor

The first two examples are to replace a #define statement in header file with const.


Windows Authentication Problems in SQL Server

I had two issues when I tried to enable Windows Authentication for SQL Server.


Converting a bigint into string in SQL Server

Just came across this annoying bug in one stored procedure written by someone else (not ME! :-)):

数码时代 程序员 网络撷翠

Special Escape Characters in HTML

Copied from htmlhelp

Special Entities

The following table gives the character entity reference, decimal character reference, and hexadecimal character reference for markup-significant and internationalization characters, as well as the rendering of each in your browser. Glyphs of the characters are available at the Unicode Consortium.

数码时代 程序员

Migrating to WordPress from PJBlog using RSS import

Due to the various issues with PJBlog, I decided to move this blog site from preivoulsy PJBlog to WordPress system. The main issue with the migration is how to migrate the about 250 existing posts over.
Since there is no ready pjblog2wordpress migration program avaiable, the only viable way seems to be the RSS importing, that is, exporting RSS for each category from PJBlog, then import the exported RSS xml files into WordPress.


DBPROP_COMMANDTIMEOUT does not seem to work?

This is set as a property to a dbcommand,

程序代码 程序代码
propSet.AddProperty(DBPROP_COMMANDTIMEOUT, 30);

But the command does not seem to work after 30 seconds.

This post appears making sense to me:

引用内容 引用内容
o The timeout no longer counts, once the client library have received some
data back from SQL Server. (This is something I have read in a book; I
have not verified it myself.)
o If the timeout elapses when SQL Server has been inserting data into a
table for 30 seconds, or even worse been updating rows row 30 seconds,
it will not yield on the spot. The effect of the currently executing
statement must be rolled back. And rollbacks usually takes longer than
command that started the operation.

In my case, the first one makes sense because the query in my test command does return 696164 rows. That explains why the command took around 175 seconds and did not report any timeout failure. After all, if there is data incoming, why the command can be assumed hanged?

If I put a sleep in a sproc, the timeout will still occur, obviously since no data is returned to the client, the client think the command is stalled.

Further reading:
This MSDN blog explains query timeouts are a client-side concept only.

But this is probably the best explanation about how the timeout is calculated:

引用内容 引用内容
This property is the cumulative time-out for all network reads during command execution or processing of the results. A time-out can still occur after the first row is returned, and does not include user processing time, only network read time.