Presentation is loading. Please wait.

Presentation is loading. Please wait.

CAN Implementation– Proxy Module Qun Cao October 14, 2002.

Similar presentations


Presentation on theme: "CAN Implementation– Proxy Module Qun Cao October 14, 2002."— Presentation transcript:

1 CAN Implementation– Proxy Module Qun Cao October 14, 2002

2 CAN Infrastructure Content Manager Content Manager Routing Manager Routing Manager PROXY Communication Engine Communication Engine Message Lookup result Message PROXY Next Node Node Manager Node Manager Replicate Manager Replicate Manager Message Dispatcher Message Dispatcher DB

3 Proxy Module The Role of Proxy - Proxy plays as the bridge between CAN nodes to client. The CAN internal structure is transparent to client. Proxy serves as a web service to the client. - Proxy collects information from client and make a CAN message package for the usage of other CAN modules.

4 Proxy API namespace MyCAN { public class Proxy { public Proxy() { } public bool AddContent (string Key, byte[] value) { …} public byte[] GetContent(string key) { …} public bool DeleteContent(string key) {… } } }

5 CAN Internal Message Works as the standard message flowing between CAN modules, carries all the information of client request, generated by Proxy Module. Structure: * a.l : arbitrary length. If an item is a.l, we use the first 4 bytes to store its length and followed by its content. MsgType OP P Key SrcIP SrcMsgChannel Value 4bytes 4 20 a.l 4 20 a.l

6 Message Format MsgType (4 bytes): The message dispatcher dispatches this message to the appropriate module in term of MsgType. All content-related messages have MsgType=1. OP (4 bytes): Content manager uses this type to perform add, delete, and lookup operations. We define OP Operations 1 Add a piece of content 2 Delete a piece of content 3 Lookup a piece of content

7 Message Format P (20 bytes): P= SHA(key). Key (a.l): a string with arbitrary length. It’s used in add, delete and lookup a piece of content. SrcIP (4 bytes): the IP address of the proxy instance who issues the message. SrcMsgChannel (20 bytes): The message channel where this proxy instance receives messages. Other CAN nodes who receive this message may use the SrcIP and SrcMsgChannel to send messages back to this particular proxy instance. SrcMsgChannel is generated by some UUID generation algorithm. Value (a.l): a byte array containing the value of a piece of content.

8 Pseudo Code - AddContent { byte[20] UUID=UUIDgen(); byte[20] p = SHA(key); packing message; SendMsg(buf, IP, 1); bool reply = RecvMsg(UUID); return reply(T/F); }

9 Pseudo Code - GetContent { byte[20] UUID=UUIDgen(); byte[20] p = SHA(key); packing message; SendMsg(buf, IP, 1); bool reply = RecvMsg(UUID); return reply(T/F); }

10 Pseudo Code - DeleteContent { byte[20] UUID=UUIDgen(); byte[20] p = SHA(key); packing message; SendMsg(buf, IP, 1); byte[] buf = RecvMsg(UUID); parse buf; return content; }

11 Return Message Format The operation result message issued from CAN nodes to Proxy Structure: OP ResultCode Description value OP (4 bytes): It has the same meaning as the above OP. ResultCode (1 byte): 1 indicates the operation succeeds. 0 indicates it fails. Description (a.l): A description string to the result code. For example, if ResultCode is 0, this string describes the error in detail. Value (a.l.): The value for the key, if OP is 3.


Download ppt "CAN Implementation– Proxy Module Qun Cao October 14, 2002."

Similar presentations


Ads by Google