Tuesday, December 3, 2013

AT&T U-Verse vs. Comcast Xfinity

Technology used

U-Verse: FTTN (Fiber-to-the Node) and VDSL
Comcast: DOCSIS (DataOver Cable Service Interface Specification) and HFC



Diagram



CMTS = Cable Modem Termination System  (usually at curbside of a neighborhood serving house)
VRAD = Video-Ready Access Device (usually at curbside of a neighborhood serving house)
VDSL = Very-high-bit-rate Digital Subscriber Line
CPE = Customer Premise Equipment (e.g, U-Verse Residential Gateway)
FTTN = Fiber To The Node
HFC = Hybrid Fiber Coax
RG = Residential Gateway

How They Work

The central office above is a simplified of interwork of switches, edge routers (facing customers), and core routers (facing the Internet cloud, where Tier-1 backbone connections are interconnected).

U-Verse


The top network is AT&T network, while the bottom one is Comcast network.  Off course, the diagram above is oversimplified.  There are many other components of the Internet (web servers, mail servers, dhcp servers, dns servers, etc.  They will be discussed some day in separate blog).

AT&T's U-Verse network system consists of CPE sitting inside customer's home.  The upstream connection most of the time use existing coax cable that are usually pre-installed inside most houses for cable tv to minimize cross-talk and noise.  The Layer-1 protocol of this connection to VRAD is VDSL (or VDSL2 for higher speed [24 Mbps], or even VDSL2 bonding for even faster speed up to 45 Mbps.  Using VDSL2 vectoring, theoretically we can achieve even 100 Mbps).  

VRAD is an equipment (a rack equipment) sitting at the curb aggregating traffic from premises (homes).  It acts mostly like a layer-2 switch (with some layer-3 capability, such as DHCP, IGMP, some filtering).  The uplink connection to C.O is FTTN (Fiber To The Node) via optical fiber using GPON technology (or other optical technologies), while downlink connections to premises using existing regular phone's twisted pairs.  VRAD usually is equipped with backup batteries, so even when there is power outage, customers still can make phone call (if the customer uses VOIP, he also needs backup battery for his/her CPE).

The AT&T's CPE usually has multiple downlink ethernet ports and one (or two) POTS for VOIP (optional).  One of the Ethernet port is connected to setop-box (in case the customer subscribes to video as part of dual-play or triple-play).  Internet packets and IPTV packet streams are separated over separate VLAN.  For example, VLAN=100 for the Internet, while VLAN=999 for IPTV.  

When customer wants to watch a TV program by selecting a certain channel via remote, the setop-box sends IGMP join packet to VRAD.  VRAD, with its IGMP snooping capability, then requests C.O's router to send multicast packets containing the program.  This multicast packets are then forwarded to the customer's CPE as unicast packets.When other customers watch the same channel, they just join the multicast group and VRAD then forward the stream to them as unicast packets, so there is single multicast video stream coming from central office to VRAD.

All AT&T's residential gateway /CPE support Wi-Fi.  Wireless connection is treated like other wired connection in a sense it is bridged logically.  Once a CPE is up, as usual it sends DHCP (if it is set for automatic IP assignment).  This DHCP is snooped by VRAD and forwarded to C.O.  Once the client device has been assigned an IP address (public IP address), everything is the same as normal wired connection.  It is up to the CPE/RG to assign a local private IP address to any device connected to it (see previous posting for more detail about how it works).

Cable Network


Front Panel of a cable modem


Back panel of a cable modem


Cost Comparison

Sunday, December 1, 2013

Connecting Cable Modem to Two routers

Sometimes we want to split our home private network to two separate subnets, but want to maintain connectivity to the Internet/outside world. The following article tries to explain the basics and internals of most home WiFi routers in the market.

First, let see what are the basic components of a Wi-Fi router:



The following is an example of topology and connection of typical home network:





Router-1: Linksys WRT-54G running DD-WRT firmware
Router-2: NETGEAR Genie WNDR3400v2

The cable modem (DOCSIS modem) is connected to cable provider thru coax cable and its main function is to modulate/demodulate DOCSIS signal to regular ethernet frames (it might bind multiple channels [channel bonding] to increase bandwidth).  The cable provider assigns a public IP address to us to use.  This single public IP cannot be shared if we don't use router.

Router-1 and Router-2 see packets coming from modem, but they don't know how to route them to our devices at home yet.  Assume router-1 is the router that assigns DHCP IP address (running DHCP server), while DHCP server on router-1 is set to forwarder to router-2.  Router-2 is chosen as the main router because it has more recent hardware, supports 11n Wi-fi and supports IPv6 (PS3 is actually better to be connected to router-2 to lower the latency).

Other clients such as as Ooma, Roku and PS3 don't support IPv6 yet, so it's Ok to connect them to Router-2.

On Router-1:  
  • Set DHCP to DHCP forwarder (forward DHCP requests) to router-2 IP address
  • Set router IP address to 192.168.0.1/24
  • Set DNS to either public DNS (such as Google: 8.8.8.8, opendns's IPs or our own local DNS server)
  • Operation mode: router
  • Set wireless to bridged mode (so router-1's wifi is like another L2 ethernet device in our private LAN)
  • WAN type: Static IP.  If it is set to DHCP and the WAN port of router-1 is connected to the ethernet bridge, DHCP server at the ISP site may deny the request or even worse, shutdown the connection completely (thus require modem reboot to fix the problem).
  • Set WAN static IP to router-2 ip address.  This way, we assume router-2 is the gateway and delegates NAT work to router-2 (that's why we set the operation mode of router-1 to "router")


Router-2:
  • Enable AP mode
  • Set router IP address to 192.168.1.1/24
  • Internet IP: Get dynamically from ISP
  • Set DMZ to Router-1

How it works:

A tablet is trying to connect to the Internet via router-2.  All Wi-fi transactions have been done and now it sends DHCP request to router-2.  If this is an initial request made to router-2, router-2 doesn't learn any IP yet so it first learns for the tablet's MAC. Because router-2 runs local dhcp server, it snoops any DHCP request and serves it.  In this case, router-2 then assigns an address in the subnet 192.168.1.0/24 along with DNS addresses and gateway IP (in this case, an ISP-assigned IP address) back to the tablet as DHCP RESP packet.

Now the tablet has a valid private address, now it can connect to the Internet via router-2.  All requests from the tablet is network-translated to public address and vice-versa.  So, if the public IP is a.b.c.d, tablet' IP address is 192.168.1.5 and it is requesting access to www.google.com (http www.google.com:80) from a local tcp port xxxx, the actual packet in the public wire is "a.b.c.d:yyyy", where xxxx is a the original tcp port and yyyy is the translated tcp port by NAT (router-2 maps local to public IP via port) [ Click this for more info about NAT/PAT mechanism].

OK, everything seems to work.  Wait...what about all other devices connected to router-1? What happens if we want to watch Netflix on Roku?

When Roku device is turned on, it sends DHCP REQ similar to tablet above.  The sequence is the same, but the difference is, because router-1 doesn't run DHCP server, all DHCP packets are forwarded to router-2.  So, it is assigned an IP address in the same subnet (sorry, the diagram above is wrong, the subnet should be the same).  When the Roku starts sending tcp packets, the packets not-intended to the private subnet and coming to router-1 are assumed to be forwarded to its gateway (router-2).  Router-1 sees these packets coming from its DMZ and do the same translation to public IP.

An alternative is to subtend router-1 to router-2 directly, not via ethernet switch.  The rest is the same.



Sunday, November 10, 2013

AT&T U-Verse with external wifi router running DD-WRT software



I don't like the way wi-fi connection is handled by CPE (Customer Premise Equipment, such as the provider's home gateway/router), so I want to use the Wi-Fi capability of Linksys.  DD-WRT gives features in handling L2 connections (MAC filtering etc.),  but I still want the CPE to handle DHCP and NAT services.  Basically, I just want to make the Linksys router acts like a Wi-Fi and Wired switch, as an extender of the existing CPE.

 The objects in yellow box represents component in the Wi-Fi router (in this case, a Linksys WRT54G running DD-WRT firmware).

DHCP server on U-Verse CPE is configured to give IPs in 192.168.0.x subnet.  The CPE address is set manually to 192.168.0.1

Here's what I want:
CPE internal IP address = 192.168.0.1
Linksys Internal IP address = 192.168.0.2
IP range for Clients = 192.168.0.3 - 192.168.0.254

CPE setting:
  • Wireless  disabled
  • Configure DHCP to assign IP range: 192.168.0.3 - 192.168.254

DD-WRT settings:
  • WAN connection type = disable
  • Local IP = 192.168.0.2/24
  • DHCP server = forwarding to 19.168.0.1 (CPE)
  • Check option box to assign WAN port to switch (NAT is thus disabled; it is now acting like a pass-thru to switch)
  • Wiress network configuration = bridged (so all Wi-Fi clients are seen by CPE as they're directly connected)
  • Wiress Tx Power = 250 mW
  • Advanced routing = router (doesn't matter actually)
  • Disable CPI firewall
  • Routing = disable
This way, all Wi-Fi is handled by Linksys router/switch, but only its L1-L2 layers.  Everything else is handled by the CPE.  We can also relocate the Linksys somewhere else, no need to be close to CPE as long as we have long ethernet cable or by using Powerline extender.

Monday, October 21, 2013

Which PC/gadget has the highest pixel resolution?

Here I have collected and calculated PPI (Pixels per Inch) for some laptops and tablets.



Screen Diameter (inch)Screen Ratio (Width/Height)Angle (rad)Screen widthScreen HeightNumber Of Pixels (Horizontal)Number Of Pixels (Vertical)PPI
15.61.780.5113.607.65128072094.14HP Pavilion 2000T
15.61.780.5113.607.651366768100.44
17.31.780.5115.088.481600900106.11HP Pavilion 17z Laptop
141.780.5112.206.861366768111.92HP Pavilion 14 Chromebook
15.61.780.5113.607.651600900117.68
18.41.780.5116.049.0219201080119.72Alienware 18
15.61.600.5613.238.2716801050127.00
17.31.780.5115.088.4819201080127.34HP ENVY 17t 1080p
15.61.780.5113.607.6519201080141.21HP ENVY 15t Quad 1080p
15.61.780.5113.607.6519201080141.21Dell XPS 15
8.91.600.567.554.721280800169.60Amazon Kindle HD
17.31.780.5115.088.4825601440169.78
15.41.600.5613.068.1628801800220.53Apple Macbook 15.4 with Retina Display
13.31.780.5111.596.5225601440220.84Toshiba KIRAbook™ 13 Ultrabook
13.31.600.5611.287.0525601600226.98Apple Macbook 15.4 with Retina Display
141.780.5112.206.8632001800262.25HP TouchSmart 14 Ultrabook
8.91.330.647.125.3420481536287.64iPad 8.9" with Retina Display
71.600.565.943.7119201200323.45Amazon Kindle HDX 7"
8.91.780.517.764.3625601440330.02Amazon Kindle HDX 8.9"


So far, nothing can beat Amazon Kindle HDX, not HP not even Apple iPad with Retina display.  Because the price of a laptop is significantly higher with higher PPI, the affordable price of Kindle plus its highest PPI makes it the best gadget for eyes and pocket!

Saturday, October 12, 2013

Distance Measurement

Last week my order of ultrasonic ranging device arrived.  With excitement I connected it to my Pic18 protoboard.  With my existing code framework I added driver to access this thing and display it to LCD (as well as logging it via rs232 to laptop pc).

I took a short video of  the board with my new iPhone5s and edited it using iMovie which is now available for free on iTunes store.

Here is the link:




Sunday, September 1, 2013

XML-RPC Client/Server in Python

This demo shows how to have RPC connection in python.  The server collects CPU information (Linux).

Server-side:

 #!/usr/bin/python
import re
import os
import sys
import xmlrpclib

from SimpleXMLRPCServer import SimpleXMLRPCServer

def is_even(n):
    return n%2 == 0

def get_mhz():
    try:
        #return 0
        f = open("/proc/cpuinfo", 'r')
    except IOError:
        print "Unable to access /proc/cpuinfo"
        exit
    except:
        print "Other unhandled error (why?)"
      
    else:
        f.seek(0)
        line = f.readline()
        while line:
            line = line.strip()
            print "line = %s" % line
            m = re.match("cpu MHz[\t ]+: (.*)", line)
            if m:
                print m.group(1)
                f.close()
                return m.group(1)
            line = f.readline()
      
#    finally:
#        print "Sorry, still fails"


def xmlsrv_exit():
    print "trying to exit now..."
    try:
        print "try sys.exit(0)"
        #sys.exit(0)
    except:
        print "Unable to exit"
  
server = SimpleXMLRPCServer(("localhost", 8000))
print "Listening on port 8000..."
server.register_function(is_even, "xmlsrv_is_even")
server.register_function(get_mhz, "xmlsrv_get_mhz")
server.register_function(xmlsrv_exit, "xmlsrv_exit")
server.serve_forever()





Client side:

#!/usr/bin/python

import xmlrpclib

try:
    proxy = xmlrpclib.ServerProxy("http://localhost:8000/")
    #print proxy.system.listMethods()
    print "3 is even: %s" % str(proxy.xmlsrv_is_even(3))
    print "100 is even: %s" % str(proxy.xmlsrv_is_even(100))

    print "CPU Clock: %s" % str(proxy.xmlsrv_get_mhz())

except xmlrpclib.Fault, err:
    print "A fault occurred"
    print "Fault code: %d" % err.faultCode
    print "Fault string: %s" % err.faultString
   
#proxy.xmlsrv_exit()