diff --git a/wsproxy/wsproxy-udp.js b/wsproxy/wsproxy-udp.js
new file mode 100644
index 0000000..bec9421
--- /dev/null
+++ b/wsproxy/wsproxy-udp.js
@@ -0,0 +1,110 @@
+var WebSocketServer = require('ws').Server;
+var dgram = require('dgram');
+
+var ccndhost = 'localhost';
+
+var wss = new WebSocketServer({port:9696, host:ccndhost});
+
+var MaxNumOfClients = 2;
+
+wss.on('connection', function(ws) {
+	console.log('wss.onconnection: WebSocket client connection received.');
+	console.log('wss.onconnection: Number of clients now is ' + wss.clients.length);
+	
+	if (wss.clients.length > MaxNumOfClients) {
+		console.log('wss.onconnection: Max num of clients exceeded. Close WS connection now.');
+		ws.terminate();
+		return;
+	}
+	
+	var udp = dgram.createSocket("udp4");
+	
+	/*
+	 * According to the email discussion with Michael, when we use
+	 * UDP to connect to ccnd, we MUST first send a 'heartbeat' 
+	 * UDP packet with 1-byte payload (content of this byte can 
+	 * be random). The purpose of this packet is to let ccnd 
+	 * mark the incoming FACE as 'friendly' (with CCN_FACE_GG 
+	 * flag set). We also need to periodically send this 'heartbeat' 
+	 * packet every few seconds to keep ccnd from recycling the UDP 
+	 * face. Michael recomended 8 seconds interval. 
+	 *      --Wentao
+	 */
+	// Send 'heartbeat' packet now
+	var heartbeat = new Buffer(1);
+	heartbeat[0] = 0x21;
+	udp.send(heartbeat, 0, 1, 9695, ccndhost, null);
+	
+	// Schedule a timer to send 'heartbeat' periodically
+	var timerID = setInterval(function() {
+		if (udp == null || udp == undefined)
+			return;
+		
+		var hb = new Buffer(1);
+		hb[0] = 0x21;
+		udp.send(hb, 0, 1, 9695, ccndhost, null);
+		//console.log('UDP heartbeat fired at ccnd.');
+	}, 
+	8000 // 8000 ms delay
+	);
+	
+	ws.on('message', function(message) {
+		if (typeof message == 'string')
+			console.log("ws.onmessage: Message from clinet: " + message);
+		else if (typeof message == 'object') {
+			// From JS array to Buffer
+			var buffer = new Buffer(message);
+
+			var logMsg = 'ws.onmessage: Byte array from client: ';
+			for (var i = 0; i < buffer.length; i++)
+				logMsg += String.fromCharCode(buffer[i]);
+			console.log(logMsg);
+			
+			udp.send(buffer, 0, buffer.length, 9695, ccndhost, null);
+			console.log('ws.onmessage: udp.send() returned.');
+		}
+	});
+	
+	ws.on('close', function() {
+		console.log('ws.onclose: WebSocket connection closed. Close UDP connection to ccnd and stop "heartbeat" timer.');
+		clearInterval(timerID);
+		udp.close();
+		udp = null;
+	});
+	
+	udp.on('message', function(msg, rinfo) {
+		if (typeof msg == 'object') {
+			// From Buffer to ArrayBuffer
+			var bytesView = new Uint8Array(msg);
+			
+			console.log('udp.onmessage: Byte array from server: ');
+			console.log('udp.onmessage: bytesView.length ' + bytesView.length);
+			var logMsg = "";
+			for (var i = 0; i < bytesView.length; i++)
+				logMsg += String.fromCharCode(bytesView[i]);
+			console.log(logMsg);
+			
+			ws.send(bytesView.buffer, {binary: true, mask: false});
+			console.log('udp.onmessage: ws.send() returned.');
+		}
+	});
+	
+	// Actually the socket close by ccnd will not cause the 'close' event to raise.
+	// So this event handle is only called when the client browser shuts down the WS
+	// connection, causing ws 'close' event to raise. In that event handle, we explicitly 
+	// call udp.close(). So in this function we can do nothing. Anyway, here we clear the 
+	// timer and terminate ws for a second time since that will not throw exception. 'ws'
+	// will check the 'readyState' before closing, therefore avoids 'close' event loop.
+	//     --Wentao
+	udp.on('close', function() {
+		console.log('udp.onclose: UDP connection to ccnd terminated. Shut down WS connection to client and stop "heartbeat" timer.');
+		clearInterval(timerID);
+		ws.terminate();
+	});
+	
+	udp.on('error', function() {
+		console.log('udp.onerror: Error on UDP connection to ccnd. Shut down WS connection to client and stop "heartbeat" timer.');
+		clearInterval(timerID);
+		ws.terminate();
+	});
+});
