Friday, October 19, 2012

NETWORKING:packet addressing


network packets must be properly addressed in order to reach their destinations. Several addressing schemes are used in combination:
• MAC (media access control) addresses for use by hardware
• IPv4 and IPv6 network addresses for use by software
• Hostnames for use by people


Hardware (MAC) addressing
Each of a host’s network interfaces usually has one link-layer MAC address that distinguishes it from other machines on the physical network, plus one or more IP addresses that identify the interface on the global Internet. This last part bears repeating: IP addresses identify network interfaces, not machines.

IP addressing

The mapping from IP addresses to hardware addresses is implemented at the link layer of the TCP/IP model

Hostname “addressing”


Ports
IP addresses identify a machine’s network interfaces, but they are not specific enough to address individual processes or services, many of which may be actively using the network at once. TCP and UDP extend IP addresses with a concept known as a port



NETWORKING: TCP/IP components


TCP/IP is a protocol “suite,” a set of network protocols designed to work smoothly together. It includes several components:

• IP, the Internet Protocol, which routes data packets from one machine to another (RFC791)
• ICMP, the Internet Control Message Protocol, which provides several kinds of low-level support for IP, including error messages, routing assistance, and debugging help (RFC792)
• ARP, the Address Resolution Protocol, which translates IP addresses to hardware addresses (RFC826)2
• UDP, the User Datagram Protocol, which provides unverified, one-way data delivery (RFC768)
• TCP, the Transmission Control Protocol, which implements reliable, full duplex, flow-controlled, error-corrected conversations (RFC793)

These protocols are arranged in a hierarchy or “stack”, with the higher-level protocols making use of the protocols beneath them.



Saturday, March 3, 2012

PHP5.4 short array syntax

We used to define an array using the array() language construct:
array(
 key => value,
 key2 => value2,
 key3 => value3,
)

As of PHP 5.4 you can also use the short array syntax, which replaces array() with [].
$array = [
 "foo" => "bar",
 "bar" => "foo"
];
Good to see that we have another flexibility and can be lazier. But, to developers who highly agree with Python's philosophy 'There should be one-- and preferably only one --obvious way to do it', this may not be necessarily good. Another rule must be added in their development teams to specify which style should be used in projects.