OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2010 Hemanth Narra, Yufei Cheng | 3 * Copyright (c) 2010 Hemanth Narra, Yufei Cheng |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 NS_LOG_DEBUG ("EventCreated EventUID: " << event.GetUid ()
); | 684 NS_LOG_DEBUG ("EventCreated EventUID: " << event.GetUid ()
); |
685 // if received changed metric, use it but adv it only afte
r wst | 685 // if received changed metric, use it but adv it only afte
r wst |
686 m_routingTable.Update (advTableEntry); | 686 m_routingTable.Update (advTableEntry); |
687 m_advRoutingTable.Update (advTableEntry); | 687 m_advRoutingTable.Update (advTableEntry); |
688 } | 688 } |
689 else | 689 else |
690 { | 690 { |
691 /*Received update with same seq number but with same or gr
eater hop count. | 691 /*Received update with same seq number but with same or gr
eater hop count. |
692 * Discard that update. | 692 * Discard that update. |
693 */ | 693 */ |
694 if (not m_advRoutingTable.AnyRunningEvent (dsdvHeader.GetD
st ())) | 694 if (!m_advRoutingTable.AnyRunningEvent (dsdvHeader.GetDst
())) |
695 { | 695 { |
696 /*update the timer only if nexthop address matches thu
s discarding | 696 /*update the timer only if nexthop address matches thu
s discarding |
697 * updates to that destination from other nodes. | 697 * updates to that destination from other nodes. |
698 */ | 698 */ |
699 if (advTableEntry.GetNextHop () == sender) | 699 if (advTableEntry.GetNextHop () == sender) |
700 { | 700 { |
701 advTableEntry.SetLifeTime (Simulator::Now ()); | 701 advTableEntry.SetLifeTime (Simulator::Now ()); |
702 m_routingTable.Update (advTableEntry); | 702 m_routingTable.Update (advTableEntry); |
703 } | 703 } |
704 m_advRoutingTable.DeleteRoute ( | 704 m_advRoutingTable.DeleteRoute ( |
705 dsdvHeader.GetDst ()); | 705 dsdvHeader.GetDst ()); |
706 } | 706 } |
707 NS_LOG_DEBUG ("Received update with same seq number and " | 707 NS_LOG_DEBUG ("Received update with same seq number and " |
708 "same/worst metric for, " << dsdvHeader.GetD
st () << ". Discarding the update."); | 708 "same/worst metric for, " << dsdvHeader.GetD
st () << ". Discarding the update."); |
709 } | 709 } |
710 } | 710 } |
711 else | 711 else |
712 { | 712 { |
713 // Received update with an old sequence number. Discard the up
date | 713 // Received update with an old sequence number. Discard the up
date |
714 if (not m_advRoutingTable.AnyRunningEvent (dsdvHeader.GetDst (
))) | 714 if (!m_advRoutingTable.AnyRunningEvent (dsdvHeader.GetDst ())) |
715 { | 715 { |
716 m_advRoutingTable.DeleteRoute (dsdvHeader.GetDst ()); | 716 m_advRoutingTable.DeleteRoute (dsdvHeader.GetDst ()); |
717 } | 717 } |
718 NS_LOG_DEBUG (dsdvHeader.GetDst () << " : Received update with
old seq number. Discarding the update."); | 718 NS_LOG_DEBUG (dsdvHeader.GetDst () << " : Received update with
old seq number. Discarding the update."); |
719 } | 719 } |
720 } | 720 } |
721 else | 721 else |
722 { | 722 { |
723 NS_LOG_DEBUG ("Route with infinite metric received for " | 723 NS_LOG_DEBUG ("Route with infinite metric received for " |
724 << dsdvHeader.GetDst () << " from " << sender); | 724 << dsdvHeader.GetDst () << " from " << sender); |
(...skipping 11 matching lines...) Expand all Loading... |
736 != dstsWithNextHopSrc.end (); ++i) | 736 != dstsWithNextHopSrc.end (); ++i) |
737 { | 737 { |
738 i->second.SetSeqNo (i->second.GetSeqNo () + 1); | 738 i->second.SetSeqNo (i->second.GetSeqNo () + 1); |
739 i->second.SetEntriesChanged (true); | 739 i->second.SetEntriesChanged (true); |
740 m_advRoutingTable.AddRoute (i->second); | 740 m_advRoutingTable.AddRoute (i->second); |
741 m_routingTable.DeleteRoute (i->second.GetDestination ()); | 741 m_routingTable.DeleteRoute (i->second.GetDestination ()); |
742 } | 742 } |
743 } | 743 } |
744 else | 744 else |
745 { | 745 { |
746 if (not m_advRoutingTable.AnyRunningEvent (dsdvHeader.GetDst (
))) | 746 if (!m_advRoutingTable.AnyRunningEvent (dsdvHeader.GetDst ())) |
747 { | 747 { |
748 m_advRoutingTable.DeleteRoute (dsdvHeader.GetDst ()); | 748 m_advRoutingTable.DeleteRoute (dsdvHeader.GetDst ()); |
749 } | 749 } |
750 NS_LOG_DEBUG (dsdvHeader.GetDst () << | 750 NS_LOG_DEBUG (dsdvHeader.GetDst () << |
751 " : Discard this link break update as it was rec
eived from a different neighbor " | 751 " : Discard this link break update as it was rec
eived from a different neighbor " |
752 "and I can reach the destination"); | 752 "and I can reach the destination"); |
753 } | 753 } |
754 } | 754 } |
755 } | 755 } |
756 } | 756 } |
(...skipping 22 matching lines...) Expand all Loading... |
779 DsdvHeader dsdvHeader; | 779 DsdvHeader dsdvHeader; |
780 Ptr<Socket> socket = j->first; | 780 Ptr<Socket> socket = j->first; |
781 Ipv4InterfaceAddress iface = j->second; | 781 Ipv4InterfaceAddress iface = j->second; |
782 Ptr<Packet> packet = Create<Packet> (); | 782 Ptr<Packet> packet = Create<Packet> (); |
783 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = allRoute
s.begin (); i != allRoutes.end (); ++i) | 783 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = allRoute
s.begin (); i != allRoutes.end (); ++i) |
784 { | 784 { |
785 NS_LOG_LOGIC ("Destination: " << i->second.GetDestination () | 785 NS_LOG_LOGIC ("Destination: " << i->second.GetDestination () |
786 << " SeqNo:" << i->second.GetSeqNo () <<
" HopCount:" | 786 << " SeqNo:" << i->second.GetSeqNo () <<
" HopCount:" |
787 << i->second.GetHop () + 1); | 787 << i->second.GetHop () + 1); |
788 RoutingTableEntry temp = i->second; | 788 RoutingTableEntry temp = i->second; |
789 if ((i->second.GetEntriesChanged () == true) && (not m_advRoutingTable
.AnyRunningEvent (temp.GetDestination ()))) | 789 if ((i->second.GetEntriesChanged () == true) && (!m_advRoutingTable.An
yRunningEvent (temp.GetDestination ()))) |
790 { | 790 { |
791 dsdvHeader.SetDst (i->second.GetDestination ()); | 791 dsdvHeader.SetDst (i->second.GetDestination ()); |
792 dsdvHeader.SetDstSeqno (i->second.GetSeqNo ()); | 792 dsdvHeader.SetDstSeqno (i->second.GetSeqNo ()); |
793 dsdvHeader.SetHopCount (i->second.GetHop () + 1); | 793 dsdvHeader.SetHopCount (i->second.GetHop () + 1); |
794 temp.SetFlag (VALID); | 794 temp.SetFlag (VALID); |
795 temp.SetEntriesChanged (false); | 795 temp.SetEntriesChanged (false); |
796 m_advRoutingTable.DeleteIpv4Event (temp.GetDestination ()); | 796 m_advRoutingTable.DeleteIpv4Event (temp.GetDestination ()); |
797 if (!(temp.GetSeqNo () % 2)) | 797 if (!(temp.GetSeqNo () % 2)) |
798 { | 798 { |
799 m_routingTable.Update (temp); | 799 m_routingTable.Update (temp); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 RoutingProtocol::MergeTriggerPeriodicUpdates () | 1182 RoutingProtocol::MergeTriggerPeriodicUpdates () |
1183 { | 1183 { |
1184 NS_LOG_FUNCTION ("Merging advertised table changes with main table before send
ing out periodic update"); | 1184 NS_LOG_FUNCTION ("Merging advertised table changes with main table before send
ing out periodic update"); |
1185 std::map<Ipv4Address, RoutingTableEntry> allRoutes; | 1185 std::map<Ipv4Address, RoutingTableEntry> allRoutes; |
1186 m_advRoutingTable.GetListOfAllRoutes (allRoutes); | 1186 m_advRoutingTable.GetListOfAllRoutes (allRoutes); |
1187 if (allRoutes.size () > 0) | 1187 if (allRoutes.size () > 0) |
1188 { | 1188 { |
1189 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = allRoute
s.begin (); i != allRoutes.end (); ++i) | 1189 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = allRoute
s.begin (); i != allRoutes.end (); ++i) |
1190 { | 1190 { |
1191 RoutingTableEntry advEntry = i->second; | 1191 RoutingTableEntry advEntry = i->second; |
1192 if ((advEntry.GetEntriesChanged () == true) && (not m_advRoutingTable.
AnyRunningEvent (advEntry.GetDestination ()))) | 1192 if ((advEntry.GetEntriesChanged () == true) && (!m_advRoutingTable.Any
RunningEvent (advEntry.GetDestination ()))) |
1193 { | 1193 { |
1194 if (!(advEntry.GetSeqNo () % 2)) | 1194 if (!(advEntry.GetSeqNo () % 2)) |
1195 { | 1195 { |
1196 advEntry.SetFlag (VALID); | 1196 advEntry.SetFlag (VALID); |
1197 advEntry.SetEntriesChanged (false); | 1197 advEntry.SetEntriesChanged (false); |
1198 m_routingTable.Update (advEntry); | 1198 m_routingTable.Update (advEntry); |
1199 NS_LOG_DEBUG ("Merged update for " << advEntry.GetDestination
() << " with main routing Table"); | 1199 NS_LOG_DEBUG ("Merged update for " << advEntry.GetDestination
() << " with main routing Table"); |
1200 } | 1200 } |
1201 m_advRoutingTable.DeleteRoute (advEntry.GetDestination ()); | 1201 m_advRoutingTable.DeleteRoute (advEntry.GetDestination ()); |
1202 } | 1202 } |
1203 else | 1203 else |
1204 { | 1204 { |
1205 NS_LOG_DEBUG ("Event currently running. Cannot Merge Routing Table
s"); | 1205 NS_LOG_DEBUG ("Event currently running. Cannot Merge Routing Table
s"); |
1206 } | 1206 } |
1207 } | 1207 } |
1208 } | 1208 } |
1209 } | 1209 } |
1210 } | 1210 } |
1211 } | 1211 } |
OLD | NEW |