Pseudo Code for One-Phase-Pull Diffusion 0.2 -------------------------------------------- 0. Basics In One-Phase-Pull, sinks flood interests every INTEREST_INTERVAL seconds. Each interest that goes out has a distinct flow id. This is used to differentiate multiple sinks, as well as interest coming from the same sink but sent at different times (i.e. t + n * INTEREST_INTERVAL). When a node receives an interest, it matches the interest against known data types, creating a new data type if there's no match. Upon matching, we look at the existing flow-ids (if any), matching them with the flow-id from the just-received interest. If there is a match, we append this interest's last_hop to the matching flow-id list, which is basically a neighbor list ordered by interest arrival time (timestamp, node_id). One list is kept per flow-id. If there no match, we create a new flow-id list and place this interest's information on the list (as the interest is the first to arrive for this flow-id, it will remain at the top of the list). Flow-id lists time out after INTEREST_EXPIRATION_TIMER, which is a multiple of INTEREST_INTERVAL. DATA messages sent by sources are matched against all known data types. Upon match, we go through each flow-id, picking the first neighbor on each list (the one which the smallest timestamp). This replaces positive reinforcements and the assumption is that underlying layers provide symmetric paths. Data is then forwarded to this preferred, ot reinforced neighbor in each flow-id (duplicate suppression prevents a node from sending the same message to any given neighbor more than once). NEGATIVE_REINFORCEMENTS work similarly as in the Two-Phase-Pull algorithm. Upon receiving a NEGATIVE_REINFORCEMENT, a node will remove that neighbor from all flow-id lists. 1. Interest Processing Rules a) Sinks // Upon an application's generation of an interest while (user hasn't unsubscribed){ flow_id = generateRandomFlowId(); sendMessage(interest, flow_id, BROADCAST_ADDR); sleep(INTEREST_INTERVAL); } b) All Nodes // Upon receiving an interest message, find matching data // type or create a new routing entry data_type = findMatchingDataType(all_known_data_types_); // Create new data type if necessary if (!data_type){ data_type = createNewDataType(interest); all_known_data_types_->addDataType(data_type); } // Find a matching flow-id flow_id = data_type->findFlowId(interest->flow_id_); if (!flow_id){ // Create a new flow_id flow_id = data_type->createNewFlowId(interest->flow_id_); } // Add a new gradient to the matching flow-id flow_id->createGradient(interest->last_hop_); // Forward only if this is a new gradient (duplicate suppresion mechanism) if (interest_is_new){ forwardMessage(interest, BROADCAST_ADDR); } 2. Data Processing Rules // Upon receiving a data message // If message is old, we add this neighbor to our list, maybe we will // want to send a negative reinforcement later on if (message_is_old){ negative_reinforcements_list->addType(data_message->attrs_, data_message->last_hop_, BAD); return; } else { negative_reinforcements_list->addType(data_message->attrs_, data_message->last_hop_, GOOD); } // Create empty list of neighbors (duplicate suppresion mechanism) data_forwarded = new NodeList; // Start matching all known data types against this data message routing_entry = match(data, &routing_itr = routing_table->begin()); while (routing_entry){ // Data type matches, check flow-ids for (flow = routing_entry->flows_.begin(); flow != routing_entry->flows_.end(); flow++){ // Forward message to each flow's reinforced gradient data_forwarded->addToList(flow->topGradient()); forwardMessage(data, flow->topGradient()); } routing_entry = match(data, &routing_itr); } data_forwaded->emptyList(); 3. Negative Reinforcement Rules // Upon receiving a negative reinforcement, find matching data type routing_entry = match(negative_reinforcement, &routing_itr = routing_table->begin()); for (flow = routing_entry->flows_.begin(); flow != routing_entry->flows_.end(); flow++){ // Delete gradient to last_hop from all flows if (flow->findGradient(negative_reinforcement->last_hop_)){ flow->deleteGradient(negative_reinforcement->last_hop_); } } 4. Negative Reinforcement Sending Rules // These are the same for the two-phase pull scenario, i.e: if during // a time interval T, a neighbor has just sent us duplicate // non-exploratory data for data type TYPE, we send a negative // reinforcement to that neighbor.