500 likes | 609 Views
H ybrid R outing P rotocol. HRP source code. by Jeong - Ganghee. Hybrid Routing Protocol AODV Route Discovery Route Error Hrp.cpp and it’s methods. Agenda. Main features: The routing is proactive for short distances and reactive for long distances. Advantages:
E N D
HybridRoutingProtocol HRP source code by Jeong - Ganghee Advanced Operating System – Spring 2012
Advanced Operating System – Spring 2012 • Hybrid Routing Protocol • AODV • Route Discovery • Route Error • Hrp.cpp and it’s methods Agenda
Advanced Operating System – Spring 2012 • Main features: • The routing is proactive for short distances and reactive for long distances. • Advantages: • Reduces impact of disadvantages of proactive and reactive routing protocols. • No route setup latency for short distance connections. • Lower routing overhead due to reactive routing for further away destinations. • Disadvantages: • More complex • Protocol examples: • Zone Routing Protocol (ZRP) Hybrid Routing Protocols
Advanced Operating System – Spring 2012 G F H J A C E B D I K AODV: Route Discovery
Advanced Operating System – Spring 2012 A - Source J - Destination G F H J A C E B D I K AODV: Route Discovery
Advanced Operating System – Spring 2012 ‘A’ broadcast a route request (RREQ) packet with Initial TTL = 1 G F H J A C E B D I K Broadcast RREQ AODV: Route Discovery
Advanced Operating System – Spring 2012 Nodes receiving the RREQ sets up Reverse Routes to the source G F H J A C E B D I K Broadcast RREQ Reverse Route AODV: Route Discovery
Advanced Operating System – Spring 2012 ‘A’ times out and re-broadcast a Route Request(RREQ) packet with TTL = 2 G F H J A C E B D I K Broadcast RREQ Reverse Route AODV: Route Discovery
Advanced Operating System – Spring 2012 Other nodes Rebroadcasts the Route Request (RREQ) packet G F H J A C E Note: Nodes B, C and F receives RREQ Multiple times but forward it only once B D I K Broadcast RREQ Reverse Route AODV: Route Discovery
Advanced Operating System – Spring 2012 ‘A’ times out and re-broadcast a Route Request(RREQ) packet with TTL = 4 G F H J A C E B D I K Broadcast RREQ Reverse Route AODV: Route Discovery
Advanced Operating System – Spring 2012 Route Request Eventually Reaches the Destination J G F H J A C E B D I K Broadcast RREQ Reverse Route AODV: Route Discovery
Advanced Operating System – Spring 2012 Destination send route Reply (RREP) back to source using the reverse route G F H RREP J A C E B D I K AODV: Route Discovery
Advanced Operating System – Spring 2012 Node receiving the RREP sets up a Forward path to the Destination G F H J A C E B D I K Route Reply Forward Path AODV: Route Discovery
Advanced Operating System – Spring 2012 Node receiving the RREP sets up a Forward path to the Destination G F H J A C E B D I K Route Reply Forward Path AODV: Route Discovery
Advanced Operating System – Spring 2012 Node receiving the RREP sets up a Forward path to the Destination G F H ‘A’ now has a route to ‘J’ J A C E B D I K Route Reply Forward Path AODV: Route Discovery
Advanced Operating System – Spring 2012 A can now use The forward route created G F H J A C E B D I K AODV: Route Discovery
Advanced Operating System – Spring 2012 B - Source J - Destination G F H J A C E B D I K AODV: Route Discovery
Advanced Operating System – Spring 2012 ‘B’ broadcast a route request (RREQ) packet G F H J A C E B D I K AODV: Route Discovery
Advanced Operating System – Spring 2012 ‘A’ and ‘C’ replies G F H J A C E RREP RREP B D I K AODV: Route Discovery
Advanced Operating System – Spring 2012 ‘B’ picks the minimum hop route (which is through C) G F H J A C E B D I K AODV: Route Discovery
Advanced Operating System – Spring 2012 A - Source J - Destination G F H J A C E B D I K AODV: Route Error
Advanced Operating System – Spring 2012 Data is flowing between A and J G F H J A C E B D I K AODV: Route Error
Advanced Operating System – Spring 2012 Link between E and J breaks due to any reason. G F H J A Link Break C E B D I K AODV: Route Error
Advanced Operating System – Spring 2012 All nodes maintain a precursor list of nodes who might use a link G F H J A Link Break C E B D I K AODV: Route Error
Advanced Operating System – Spring 2012 Route Error message is sent to the source G F H J A Link Break C E B D I K AODV: Route Error
Advanced Operating System – Spring 2012 Routeto J is removed and Route Discovery is reinitiated G F H J A Link Break C E B D I K AODV: Route Error
Advanced Operating System – Spring 2012 • HrpInit • HrpHandleProtocolPacket • HrpHandleProtocolEvent • HrpFinalize • HrpRouterFunction • HrpHandleRequest • HrpHandleReply • HrpHandleRouteError • HrpBroadcastHelloMessage • HrpTransmitData • HrpInitializeConfigurableParameters Hrp.cpp and its methods
Advanced Operating System – Spring 2012 • Prototype: • voidHrpInit (Node*, HrpData**, constNodeInput*,int, NetowrkRoutingProtocolType) • Purpose: • Initialization function for HRP protocol • Arguments: • node, hrpPtr, nodeInput, interfaceIndex, hrpProtocolType • Return: • None HrpInit
Advanced Operating System – Spring 2012 // Read user configurable parameters from the configuration file or // initial them with the default value. HrpInitializeConfigurableParameters(node, nodeInput, hrp,interfaceIndex); // Initialize hrp routing table // Allocate chunk of memory // Set the mac status handler function // Set the router function HrpInit code (some)
Advanced Operating System – Spring 2012 • Prototype: • voidHrpFinalize (Node*) • Purpose: • Called at the end of the simulation to collect the results. • Arguments: • node • Return: • None HrpFinalize
Advanced Operating System – Spring 2012 … if ( hrp->statsCollected && !hrp->statsPrinted ) { hrp->statsPrinted = TURE; sprintf(const char* buf, const char *format, …); IO_PrintStat( Node* node, const char* layer, const char* protocol, const char* ipAddrString, intinstanceId, const char* fmt……) … } HrpFinalize code (some)
Advanced Operating System – Spring 2012 • Prototype: • voidHrpHandleProtocolPacket (Node*, Message*, NodeAddress, NodeAddress, int, int) • Purpose: • Called when Hrp packet is received from MAC, the packetsmay be of following types, Route Request, Route Reply, Route Error, Route Acknodwledgement • Arguments: • Node, msg, srcAddr, destAddr, ttl, interfaceIndex • Return: • None HrpHandleProtocolPacket
Advanced Operating System – Spring 2012 char* packetType = MESSASGE_ReturnPacket(msg); switch (*packetType) { case HRP_RREQ: … HrpHandleRequest(node, msg, srcAddr, ttl, interfaceIndex); … case HRP_RREP: … HrpHandleReply(node, msg, srcAddr, interfaceIndex); … case HRP_RERR: … HrpHandleRouteError(node, msg, srcAddr, InterfaceIndex); … } • Let QualNet know HRP as a network layer protocol • In the file include/trace.h HrpHandleProtocolPacket code (some)
Advanced Operating System – Spring 2012 • Prototype: • voidHrpHandleProtocolEvent (Node*, Message*); • Purpose: • Handles all the protocol events • Arguments: • node, msg • Return: • None HrpHandleProtocolEvent
Advanced Operating System – Spring 2012 switch (MESSAGE_GetEvent(msg)) { // Remove an entry from the RREQ Seen Table caseMSG_NETWORK_FlushTables: {} // Remove the route that has not been used for awhile. caseMSG_NETWORK_CheckRouteTimeout: {} caseMSG_NETWORK_DeleteRoute: {} // Check if RREP is received after sending RREQ. caseMSG_NETWORK_CheckReplied: {} caseMSG_NETWORK_BlacklistTimeout: {} caseMSG_NETWORK_SendHello: {} } HrpHandleProtocolEvent code (some)
Advanced Operating System – Spring 2012 • Prototype: • voidHrpRouterFunction (Node*, Message*, NodeAddress, NodeAddress, BOOL*) • Purpose: • Determine the routing action to take for a the given data packet set the wasRouted variable to TRUE if no further handling of this packet by IP is necessary. • Arguments: • node, msg, destAddr, previousHopAddress, wasRouted • Return: • None HrpRouterFunction
Advanced Operating System – Spring 2012 if (NetworkIpIsMyIP(node, destAddr)) { *wasRouted = FALSE; } else { *wasRouted = TRUE; } // Intermediate node or destination of the route if (!NetowrkIpIsMyIP(node, ipHeader->ip_src)) { HrpHandleData(node, msg, destAddr, previousHopAddress); } else{ if (isValidRt) { // HrpCheckRouteExist(destAddr, rtTable, &isValidRt) // Source has a route to the destination HrpTransmitData(node, msg, rtToDest, previousHopAddress); hrp->stats.numDataInitiated++; } else if (!HrpCheckSent(destAddr, &hrp->sent)) { HrpInsertBuffer( node, msg, destAddr, previousHopAddress, &hrp->msgBuffer); // There is no routeto the destination and RREQ has not been sent HrpInitiateRREQ(node, destAddr); } else { // There is no route but RREQ has already been sent HrpInsertBuffer( node, msg, destAddr, previousHopAddress, &hrp->msgBuffer); } } • Let QualNet know HRP as a network layer protocol • In the file include/trace.h HrpRouterFunction code (some)
Advanced Operating System – Spring 2012 • Prototype: • voidHrpHandleRequest (Node*, Message*, NodeAddress, int, int) • Purpose: • Processing procedure when RREQ is received • Arguments: • node, msg, srcAddr, ttl, interfaceIndex • Return: • None HrpHandleRequest
Advanced Operating System – Spring 2012 if (zone == 1) { if (HrpCheckBlacklistTable(srcAddr, &hrp->blacklistTable)) {} if (rreqPkt->hopCount > (unsigned int) HRP_NET_DIAMETER) {} if (FALSE == HrpLookupSeenTable( hrp, rreqPkt->source.address, rreqPkt->floodingId, &hrp->seenTable)) { if(NetworkIpIsMyIP(node, rreqPkt->destination.address) { // dest. node } else { // intermediate node replyByIntermediate = TRUE;} } // The node always creates or updates a reverse route to the Source // IP Address in its routing table. if (replyByIntermediate) { … } // When a node receives an HRP control packet from a neighbor, it // checks its route table for an entry for that neighbor. } • Let QualNet know HRP as a network layer protocol • In the file include/trace.h HrpHandleRequest code (some)
Advanced Operating System – Spring 2012 • Prototype: • voidHrpHandleReply (Node*, Message*, NodeAddress, int) • Purpose: • Processing procedure when RREP is received • Arguments: • node, msg, srcAddr, interfaceIndex • Return: • None HrpHandleReply
Advanced Operating System – Spring 2012 if (rrepPkt->sourceAddr == ANY_IP) { // Whenever a node receives a HELLO packet from a neighbor, } if (rrepPkt->destination.address != srcAddr) { // intermediate node || from destination to source } prevRtPtr = HrpCheckRouteExist(rrepPkt->destination.address, &hrp->routeTable, &isValidRt); if (!prevRtPtr || (prevRtPtr->destination.seqNum < rrepPkt->destination.seqNum) || ((prevRtPtr->destination.seqNum == repPkt->desination.seqNum) && (!isValidRt || revRtPtr->hopCount > hopCount))) { // The forward route for this destination is created or updated only if } if (NetworkIpIsMyIP(node, rrepPkt->sourceAddr)) { // Source of the route } else { // Intermediate node of the route } • Let QualNet know HRP as a network layer protocol • In the file include/trace.h HrpHandleReply code (some)
Advanced Operating System – Spring 2012 • Prototype: • voidHrpHandleRouteError (Node*, Message*, NodeAddress, int) • Purpose: • Processing procedure when RERR is received • Arguments: • node, msg, srcAddr, interfaceIndex • Return: • None HrpHandleRouteError
Advanced Operating System – Spring 2012 unreachableDestList = HrpCalculateNumInactiveRouteByDest( node, msg,srcAddr, &hrp->routeTable, &ifOneUpstream, &upstreamAddr); destCount = BUFFER_GetCurrentSize( &unreachableDestList / sizeof (HrpAddrSeqInfo)); if (destCount) { // Allocate the rerrpacket // rerr packet allocation is complete send out the packet } BUFFER_DestoyDataBuffer(&unreachableDestList); • Let QualNet know HRP as a network layer protocol • In the file include/trace.h HrpHandleRouteError code (some)
Advanced Operating System – Spring 2012 • Prototype: • voidHrpBroadcastHelloMessage (Node*, HrpData*) • Purpose: • Function to advertise hello message if a node wants to • Arguments: • node, hrp • Return: • None HrpBroadcastHelloMessage
Advanced Operating System – Spring 2012 unreachableDestList = HrpCalculateNumInactiveRouteByDest( node, msg,srcAddr, &hrp->routeTable, &ifOneUpstream, &upstreamAddr); destCount = BUFFER_GetCurrentSize( &unreachableDestList / sizeof (HrpAddrSeqInfo)); if (destCount) { // Allocate the rerr packet } // DESC. NetworkDataIP :: Main structure of network layer. NetworkDataIp* ip = (NetworkDataIp*) node->netowrkData.networkVar; intpkt_Size = sizeof (HrpRrepPacket); Message *newMsg = MESSAGE_Alloc(node, layer_type, pkt_Size, event_type); MESSAGE_packetAlloc(node, newMsg, pkt_Size, TRACE_HRP); // Allocate the message and then broadcast to all interface. // No specification in the draft for source address! rrepPkt->sourceAddr = ANY_IP; // #define ANY_IP 0xFFFFFFFF for (inti = 0; i < node->numberInterfaces; i++ ) { ipInterfaceInfoType* intfInfo = ip->interfaceInfo[i]; if (intfInfo->routingProtocolType != ROUTING_PROTOCOL_HRP && DualIpGetInterfaceTunnelType(node, i) != IPv6_TUNNEL) { continue; } rrepPkt->desination.address = intfInfor->ipAddress; } hrp->stats.numHelloSent++; • Let QualNet know HRP as a network layer protocol • In the file include/trace.h HrpBroadcastHelloMessage (some)
Advanced Operating System – Spring 2012 • Prototype: • voidHrpTransmitData (Node*, Message*, HrpRouteEntry*, NodeAddress) • Purpose: • Forward the data packet to the next hop • Arguments: • node, msg, rtEntryToDest, previousHopAddress • Return: • None HrpTransmitData
Advanced Operating System – Spring 2012 unreachableDestList = HrpCalculateNumInactiveRouteByDest( node, msg,srcAddr, &hrp->routeTable, &ifOneUpstream, &upstreamAddr); destCount = BUFFER_GetCurrentSize( &unreachableDestList / sizeof (HrpAddrSeqInfo)); if (destCount) { // Allocate the rerr packet } MESSAGE_SetLayer (msg, MAC_LAYER, 0); MESSAGE_SetEvent (msg, MSG_MAC_FromNetwork); // Each time a route is used to forward a data packet, its Lifetime field is // updated to be no less than the current time + ACTIVE_ROUTE_TIMEOUT If (rtEntryToDest->lifetime < getSimTime(node) + HRP_ACTIVE_ROUTE_TIMEOUT) { rtEntryToDest->lifetime = getSimTime(node) + HRP_ACTIVE_ROUTE_TIMEOUT; HrpMoveRouteEntry (&hrp->routeTable, rtEntryToDest); } // Since the route between each src and dest pair are expected to be symmetric,// the Lifetime for the previous hop, along the reverse path back to the IP source, // is also updated to be no less than the current time + ACTIVE_ROUTE_TIMEOUT if (previousHopAddress != ANY_IP) { HrpUpdateLifetime(…); } // Update lifetime of src. if (previousHopAddress != src) { HrpUpdateLifetime(…); } // Update the lifetime of next hop towards the dest. HrpUpdateLifetime(…); NetworkIpSendPacketToMacLayer(…) {} • Let QualNet know HRP as a network layer protocol • In the file include/trace.h HrpTransmitData code (some)
Advanced Operating System – Spring 2012 • Prototype: • static voidHrpInitializeConfigurableParameters(Node*, constNodeInput*, HrpData*, int) • Purpose: • To initialize the user configurable parameters or initialize the corresponding variables with the default values as specified in draft-ieft-manet-hrp-08.txt • Arguments: • node, nodeInput, hrp, intfIndex • Return: • node HrpInitializeConfigurableParameters
Advanced Operating System – Spring 2012 unreachableDestList = HrpCalculateNumInactiveRouteByDest( node, msg,srcAddr, &hrp->routeTable, &ifOneUpstream, &upstreamAddr); destCount = BUFFER_GetCurrentSize( &unreachableDestList / sizeof (HrpAddrSeqInfo)); if (destCount) { // Allocate the rerr packet } BOOL wasFound = FALSE; NodeAddressinterfaceAddress = NetworkIpGetInterfaceAddress(node, intfIndex) NodeAddressnodeId = node->nodeId; IO_ReadInt(nodeId, interfaceAddress, nodeInput, “HRP-NET-DIAMETER”, &wasFound, &hrp->netDiameter); if (!wasFound) hrp->netDiameter = HRP_DEFAULT_NET_DIAMETER; // #define IO_ReadTime(nodeId, interfaceAddress, nodeInput, “HRP-NODE-TRAVERSAL-TIME”, &wasFound, &hrp->nodeTraversalTime); if (!wasFound) hrp->nodeTraversalTime= HRP_DEFAULT_NODE_TRAVERSAL_TIME; // #define IO_ReadString(nodeId, InterfaceAddress, nodeInput, “HRP-LOCAL-REPAIR”, &wasFound, buf); if ((wasFound == FALSE) || (strcmp(buf, “NO”) == 0)) { hrp->localRepair = FALSE; } else if (strcmp(buf, “YES”) == 0) { hrp->localRepair = TRUE; } else { ERROR_ReportError(“Needs YES/NO against HRP-LOCAL-REPAIR”); } • Let QualNet know HRP as a network layer protocol • In the file include/trace.h HrpInitializeConfigurableParameterscode (some)