#include <IPv6InterfaceData.h>
typedef std::vector<AddressData> IPv6InterfaceData::AddressDataVector [private] |
typedef std::vector<AdvPrefix> IPv6InterfaceData::AdvPrefixList [private] |
IPv6InterfaceData::IPv6InterfaceData | ( | ) |
00026 { 00027 /*******************Setting host/node/router Protocol Constants************/ 00028 routerConstants.maxInitialRtrAdvertInterval = IPv6_MAX_INITIAL_RTR_ADVERT_INTERVAL; 00029 routerConstants.maxInitialRtrAdvertisements = IPv6_MAX_INITIAL_RTR_ADVERTISEMENTS; 00030 routerConstants.maxFinalRtrAdvertisements = IPv6_MAX_FINAL_RTR_ADVERTISEMENTS; 00031 routerConstants.minDelayBetweenRAs = IPv6_MIN_DELAY_BETWEEN_RAS; 00032 routerConstants.maxRADelayTime = IPv6_MAX_RA_DELAY_TIME; 00033 00034 hostConstants.maxRtrSolicitationDelay = IPv6_MAX_RTR_SOLICITATION_DELAY; 00035 hostConstants.rtrSolicitationInterval = IPv6_RTR_SOLICITATION_INTERVAL; 00036 hostConstants.maxRtrSolicitations = IPv6_MAX_RTR_SOLICITATIONS; 00037 00038 nodeConstants.maxMulticastSolicit = IPv6_MAX_MULTICAST_SOLICIT; 00039 nodeConstants.maxUnicastSolicit = IPv6_MAX_UNICAST_SOLICIT; 00040 nodeConstants.maxAnycastDelayTime = IPv6_MAX_ANYCAST_DELAY_TIME; 00041 nodeConstants.maxNeighbourAdvertisement = IPv6_MAX_NEIGHBOUR_ADVERTISEMENT; 00042 nodeConstants.reachableTime = IPv6_REACHABLE_TIME; 00043 nodeConstants.retransTimer = IPv6_RETRANS_TIMER; 00044 nodeConstants.delayFirstProbeTime = IPv6_DELAY_FIRST_PROBE_TIME; 00045 nodeConstants.minRandomFactor = IPv6_MIN_RANDOM_FACTOR; 00046 nodeConstants.maxRandomFactor = IPv6_MAX_RANDOM_FACTOR; 00047 00048 /*******************Setting host/node/router variables*********************/ 00049 nodeVars.dupAddrDetectTransmits = IPv6_DEFAULT_DUPADDRDETECTTRANSMITS; 00050 00051 hostVars.linkMTU = IPv6_MIN_MTU; 00052 hostVars.curHopLimit = IPv6_DEFAULT_ADVCURHOPLIMIT;//value specified in RFC 1700-can't find it 00053 hostVars.baseReachableTime = IPv6_REACHABLE_TIME; 00054 hostVars.reachableTime = generateReachableTime(_minRandomFactor(), 00055 _maxRandomFactor(), baseReachableTime()); 00056 hostVars.retransTimer = IPv6_RETRANS_TIMER; 00057 00058 //rtrVars.advSendAdvertisements is set in RoutingTable6.cc:line 143 00059 rtrVars.maxRtrAdvInterval = IPv6_DEFAULT_MAX_RTR_ADV_INT; 00060 rtrVars.minRtrAdvInterval = 0.33*rtrVars.maxRtrAdvInterval; 00061 rtrVars.advManagedFlag = false; 00062 rtrVars.advOtherConfigFlag = false; 00063 rtrVars.advLinkMTU = IPv6_MIN_MTU; 00064 rtrVars.advReachableTime = IPv6_DEFAULT_ADV_REACHABLE_TIME; 00065 rtrVars.advRetransTimer = IPv6_DEFAULT_ADV_RETRANS_TIMER; 00066 rtrVars.advCurHopLimit = IPv6_DEFAULT_ADVCURHOPLIMIT; 00067 rtrVars.advDefaultLifetime = 3*rtrVars.maxRtrAdvInterval; 00068 #if USE_MOBILITY 00069 if (rtrVars.advDefaultLifetime<1) 00070 rtrVars.advDefaultLifetime = 1; 00071 #endif 00072 }
simtime_t IPv6InterfaceData::_delayFirstProbeTime | ( | ) | [inline] |
simtime_t IPv6InterfaceData::_maxAnycastDelayTime | ( | ) | [inline] |
uint IPv6InterfaceData::_maxFinalRtrAdvertisements | ( | ) | [inline] |
simtime_t IPv6InterfaceData::_maxInitialRtrAdvertInterval | ( | ) | [inline] |
Getters/Setters for all variables and constants defined in RFC 2461/2462 can be found here. Operations responsible for protocol constants are marked with a "_" prefix. Constants in this class are stored as instance variables. Default values for certain variables are defined at the top of this file, while certain variables have to be generated. Protocol constants are subject to change as specified in RFC2461:section 10 depending on different link layer operation. Getters and setters have been implemented for protocol constants so that a wireless interface may be set to a different set of constant values. (ie. changed by the FlatNetworkConfigurator) Such a design allows both wired and wireless networks to co-exist within a simulation run.
00407 {return routerConstants.maxInitialRtrAdvertInterval;}
uint IPv6InterfaceData::_maxInitialRtrAdvertisements | ( | ) | [inline] |
uint IPv6InterfaceData::_maxMulticastSolicit | ( | ) | [inline] |
uint IPv6InterfaceData::_maxNeighbourAdvertisement | ( | ) | [inline] |
simtime_t IPv6InterfaceData::_maxRADelayTime | ( | ) | [inline] |
double IPv6InterfaceData::_maxRandomFactor | ( | ) | [inline] |
simtime_t IPv6InterfaceData::_maxRtrSolicitationDelay | ( | ) | [inline] |
uint IPv6InterfaceData::_maxRtrSolicitations | ( | ) | [inline] |
uint IPv6InterfaceData::_maxUnicastSolicit | ( | ) | [inline] |
simtime_t IPv6InterfaceData::_minDelayBetweenRAs | ( | ) | [inline] |
double IPv6InterfaceData::_minRandomFactor | ( | ) | [inline] |
simtime_t IPv6InterfaceData::_reachableTime | ( | ) | [inline] |
simtime_t IPv6InterfaceData::_retransTimer | ( | ) | [inline] |
simtime_t IPv6InterfaceData::_rtrSolicitationInterval | ( | ) | [inline] |
void IPv6InterfaceData::_setDelayFirstProbeTime | ( | simtime_t | d | ) | [inline] |
void IPv6InterfaceData::_setMaxAnycastDelayTime | ( | simtime_t | d | ) | [inline] |
void IPv6InterfaceData::_setMaxFinalRtrAdvertisements | ( | uint | d | ) | [inline] |
void IPv6InterfaceData::_setMaxInitialRtrAdvertInterval | ( | simtime_t | d | ) | [inline] |
void IPv6InterfaceData::_setMaxInitialRtrAdvertisements | ( | uint | d | ) | [inline] |
void IPv6InterfaceData::_setMaxMulticastSolicit | ( | uint | d | ) | [inline] |
void IPv6InterfaceData::_setMaxNeighbourAdvertisement | ( | uint | d | ) | [inline] |
void IPv6InterfaceData::_setMaxRADelayTime | ( | simtime_t | d | ) | [inline] |
void IPv6InterfaceData::_setMaxRandomFactor | ( | double | d | ) | [inline] |
void IPv6InterfaceData::_setMaxRtrSolicitationDelay | ( | simtime_t | d | ) | [inline] |
void IPv6InterfaceData::_setMaxRtrSolicitations | ( | uint | d | ) | [inline] |
void IPv6InterfaceData::_setMaxUnicastSolicit | ( | uint | d | ) | [inline] |
void IPv6InterfaceData::_setMinDelayBetweenRAs | ( | simtime_t | d | ) | [inline] |
void IPv6InterfaceData::_setMinRandomFactor | ( | double | d | ) | [inline] |
void IPv6InterfaceData::_setReachableTime | ( | simtime_t | d | ) | [inline] |
void IPv6InterfaceData::_setRetransTimer | ( | simtime_t | d | ) | [inline] |
void IPv6InterfaceData::_setRtrSolicitationInterval | ( | simtime_t | d | ) | [inline] |
void IPv6InterfaceData::addAdvPrefix | ( | const AdvPrefix & | advPrefix | ) |
Adds the given advertised prefix to the interface.
00256 { 00257 rtrVars.advPrefixList.push_back(advPrefix); 00258 }
const IPv6Address & IPv6InterfaceData::address | ( | int | i | ) | const |
bool IPv6InterfaceData::addrLess | ( | const AddressData & | a, | |
const AddressData & | b | |||
) | [static, private] |
00224 { 00225 // This method is used in choosePreferredAddress(). 00226 // sort() produces increasing order, so "better" addresses should 00227 // compare as "less", to make them appear first in the array 00228 if (a.tentative!=b.tentative) 00229 return !a.tentative; // tentative=false is better 00230 if (a.address.scope()!=b.address.scope()) 00231 return a.address.scope()>b.address.scope(); // bigger scope is better 00232 return (a.expiryTime==0 && b.expiryTime!=0) || a.expiryTime>b.expiryTime; // longer expiry time is better 00233 }
short IPv6InterfaceData::advCurHopLimit | ( | ) | [inline] |
simtime_t IPv6InterfaceData::advDefaultLifetime | ( | ) | [inline] |
int IPv6InterfaceData::advLinkMTU | ( | ) | [inline] |
bool IPv6InterfaceData::advManagedFlag | ( | ) | [inline] |
bool IPv6InterfaceData::advOtherConfigFlag | ( | ) | [inline] |
const IPv6InterfaceData::AdvPrefix & IPv6InterfaceData::advPrefix | ( | int | i | ) | const |
Returns the ith advertised prefix on the interface.
00261 { 00262 ASSERT(i>=0 && i<rtrVars.advPrefixList.size()); 00263 return rtrVars.advPrefixList[i]; 00264 }
int IPv6InterfaceData::advReachableTime | ( | ) | [inline] |
int IPv6InterfaceData::advRetransTimer | ( | ) | [inline] |
bool IPv6InterfaceData::advSendAdvertisements | ( | ) | [inline] |
void IPv6InterfaceData::assignAddress | ( | const IPv6Address & | addr, | |
bool | tentative, | |||
simtime_t | expiryTime, | |||
simtime_t | prefExpiryTime | |||
) |
Assigns the given address to the interface.
00136 { 00137 addresses.push_back(AddressData()); 00138 AddressData& a = addresses.back(); 00139 a.address = addr; 00140 a.tentative = tentative; 00141 a.expiryTime = expiryTime; 00142 a.prefExpiryTime = prefExpiryTime; 00143 choosePreferredAddress(); 00144 }
uint IPv6InterfaceData::baseReachableTime | ( | ) | [inline] |
void IPv6InterfaceData::choosePreferredAddress | ( | ) | [private] |
00236 { 00237 // do we have addresses? 00238 if (addresses.size()==0) 00239 { 00240 preferredAddr = IPv6Address(); 00241 return; 00242 } 00243 00244 // FIXME shouldn't we stick to the current preferredAddress if its prefLifetime 00245 // hasn't expired yet? 00246 00247 // FIXME TBD throw out expired addresses! 0 should be treated as infinity 00248 00249 // sort addresses by scope and expiry time, then pick the first one 00250 std::sort(addresses.begin(), addresses.end(), addrLess); 00251 preferredAddr = addresses[0].address; 00252 preferredAddrExpiryTime = addresses[0].expiryTime; 00253 }
short IPv6InterfaceData::curHopLimit | ( | ) | [inline] |
std::string IPv6InterfaceData::detailedInfo | ( | ) | const |
int IPv6InterfaceData::dupAddrDetectTransmits | ( | ) | [inline] |
int IPv6InterfaceData::findAddress | ( | const IPv6Address & | addr | ) | const [private] |
simtime_t IPv6InterfaceData::generateReachableTime | ( | ) |
Arg-less version.
00287 { 00288 return uniform(_minRandomFactor(), _maxRandomFactor()) * baseReachableTime(); 00289 }
simtime_t IPv6InterfaceData::generateReachableTime | ( | double | MIN_RANDOM_FACTOR, | |
double | MAX_RANDOM_FACTOR, | |||
uint | baseReachableTime | |||
) |
This method randomly generates a reachableTime given the MIN_RANDOM_FACTOR MAX_RANDOM_FACTOR and baseReachableTime. Refer to RFC 2461: Section 6.3.2
00282 { 00283 return uniform(MIN_RANDOM_FACTOR, MAX_RANDOM_FACTOR) * baseReachableTime; 00284 }
bool IPv6InterfaceData::hasAddress | ( | const IPv6Address & | addr | ) | const |
Returns true if the given address is one of the addresses assigned, regardless whether it is tentative or not.
00181 { 00182 return findAddress(addr)!=-1; 00183 }
std::string IPv6InterfaceData::info | ( | ) | const |
00075 { 00076 // FIXME FIXME FIXME FIXME info() should never print a newline 00077 std::ostringstream os; 00078 os << "IPv6:{" << endl; 00079 for (int i=0; i<numAddresses(); i++) 00080 os << (i?"\t , ":"\tAddrs:") << address(i) 00081 << "(" << IPv6Address::scopeName(address(i).scope()) 00082 << (isTentativeAddress(i)?" tent":"") << ") " 00083 << " expiryTime: " << (addresses[i].expiryTime==0?"inf":simtimeToStr(addresses[i].expiryTime)) 00084 << " prefExpiryTime: " << (addresses[i].prefExpiryTime==0?"inf":simtimeToStr(addresses[i].prefExpiryTime)) 00085 << endl; 00086 00087 for (int i=0; i<numAdvPrefixes(); i++) 00088 { 00089 const AdvPrefix& a = advPrefix(i); 00090 os << (i?", ":"\tAdvPrefixes: ") << a.prefix << "/" << a.prefixLength << "(" 00091 << (a.advOnLinkFlag?"":"off-link ") 00092 << (a.advAutonomousFlag?"":"non-auto "); 00093 if (a.advValidLifetime==0) 00094 os << "lifetime:inf"; 00095 else if (a.advValidLifetime>0) 00096 os << "expires:" << simtimeToStr(a.advValidLifetime); 00097 else 00098 os << "lifetime:+" << (-a.advValidLifetime); 00099 os << ")" << endl; 00100 } 00101 os << " "; 00102 00103 // uncomment the following as needed! 00104 os << "\tNode:"; 00105 os << " dupAddrDetectTrans=" << nodeVars.dupAddrDetectTransmits; 00106 //os << " curHopLimit=" << hostVars.curHopLimit; 00107 //os << " retransTimer=" << hostVars.retransTimer; 00108 //os << " baseReachableTime=" << hostVars.baseReachableTime; 00109 os << " reachableTime=" << hostVars.reachableTime << endl; 00110 00111 if (rtrVars.advSendAdvertisements) 00112 { 00113 os << "\tRouter:"; 00114 os << " maxRtrAdvInt=" << rtrVars.maxRtrAdvInterval; 00115 os << " minRtrAdvInt=" << rtrVars.minRtrAdvInterval << endl; 00116 //os << " advManagedFlag=" << rtrVars.advManagedFlag; 00117 //os << " advOtherFlag=" << rtrVars.advOtherFlag; 00118 //os << " advLinkMTU=" << rtrVars.advLinkMTU; 00119 //os << " advReachableTime=" << rtrVars.advReachableTime; 00120 //os << " advRetransTimer=" << rtrVars.advRetransTimer; 00121 //os << " advCurHopLimit=" << rtrVars.advCurHopLimit; 00122 //os << " advDefaultLifetime=" << rtrVars.advDefaultLifetime; 00123 } 00124 00125 os << " }" << endl; 00126 return os.str(); 00127 }
bool IPv6InterfaceData::isTentativeAddress | ( | const IPv6Address & | addr | ) | const |
Returns true if the interface has the given address and it is tentative.
00194 { 00195 int k = findAddress(addr); 00196 return k!=-1 && addresses[k].tentative; 00197 }
bool IPv6InterfaceData::isTentativeAddress | ( | int | i | ) | const |
const IPv6Address & IPv6InterfaceData::linkLocalAddress | ( | ) | const |
Returns the first valid link-local address of the interface, or UNSPECIFIED_ADDRESS if there's none.
00208 { 00209 for (AddressDataVector::const_iterator it=addresses.begin(); it!=addresses.end(); it++) 00210 if (it->address.isLinkLocal()) // FIXME and valid 00211 return it->address; 00212 return IPv6Address::UNSPECIFIED_ADDRESS; 00213 }
bool IPv6InterfaceData::matchesSolicitedNodeMulticastAddress | ( | const IPv6Address & | solNodeAddr | ) | const |
Returns true if the interface has an address matching the given solicited-node multicast addresses.
00186 { 00187 for (AddressDataVector::const_iterator it=addresses.begin(); it!=addresses.end(); it++) 00188 if (it->address.formSolicitedNodeMulticastAddress()==solNodeAddr) 00189 return true; 00190 return false; 00191 }
simtime_t IPv6InterfaceData::maxRtrAdvInterval | ( | ) | [inline] |
simtime_t IPv6InterfaceData::minRtrAdvInterval | ( | ) | [inline] |
int IPv6InterfaceData::numAddresses | ( | ) | const [inline] |
int IPv6InterfaceData::numAdvPrefixes | ( | ) | const [inline] |
Returns the number of advertised prefixes on the interface.
00506 {return rtrVars.advPrefixList.size();}
void IPv6InterfaceData::permanentlyAssign | ( | const IPv6Address & | addr | ) |
Clears the "tentative" flag of an existing interface address.
00200 { 00201 int k = findAddress(addr); 00202 ASSERT(k!=-1); 00203 addresses[k].tentative = false; 00204 choosePreferredAddress(); 00205 }
const IPv6Address& IPv6InterfaceData::preferredAddress | ( | ) | const [inline] |
Chooses a preferred address for the interface and returns it. This is the address that should be used as source address for outgoing datagrams, if one is not explicitly specified.
Selection is based on scope (globally routable addresses are preferred), then on lifetime (the one that expires last is chosen). See private choosePreferredAddress() function.
FIXME turn into preferredGLOBALAddress()!
00381 {return preferredAddr;} // FIXME TBD check expiry time!
simtime_t IPv6InterfaceData::reachableTime | ( | ) | [inline] |
void IPv6InterfaceData::removeAddress | ( | const IPv6Address & | address | ) |
Removes the address. Called when the valid lifetime expires.
00216 { 00217 int k = findAddress(address); 00218 ASSERT(k!=-1); 00219 addresses.erase(addresses.begin()+k); 00220 choosePreferredAddress(); 00221 }
void IPv6InterfaceData::removeAdvPrefix | ( | int | i | ) |
Remove the ith advertised prefix on the interface. Prefixes at larger indices will shift down.
00275 { 00276 ASSERT(i>=0 && i<rtrVars.advPrefixList.size()); 00277 rtrVars.advPrefixList.erase(rtrVars.advPrefixList.begin()+i); 00278 }
uint IPv6InterfaceData::retransTimer | ( | ) | [inline] |
void IPv6InterfaceData::setAdvCurHopLimit | ( | short | d | ) | [inline] |
void IPv6InterfaceData::setAdvDefaultLifetime | ( | simtime_t | d | ) | [inline] |
void IPv6InterfaceData::setAdvLinkMTU | ( | int | d | ) | [inline] |
void IPv6InterfaceData::setAdvManagedFlag | ( | bool | d | ) | [inline] |
void IPv6InterfaceData::setAdvOtherConfigFlag | ( | bool | d | ) | [inline] |
void IPv6InterfaceData::setAdvPrefix | ( | int | i, | |
const AdvPrefix & | advPrefix | |||
) |
Changes the configuration of the ith advertised prefix on the interface. The prefix itself should stay the same.
00267 { 00268 ASSERT(i>=0 && i<rtrVars.advPrefixList.size()); 00269 ASSERT(rtrVars.advPrefixList[i].prefix == advPrefix.prefix); 00270 ASSERT(rtrVars.advPrefixList[i].prefixLength == advPrefix.prefixLength); 00271 rtrVars.advPrefixList[i] = advPrefix; 00272 }
void IPv6InterfaceData::setAdvReachableTime | ( | int | d | ) | [inline] |
void IPv6InterfaceData::setAdvRetransTimer | ( | int | d | ) | [inline] |
void IPv6InterfaceData::setAdvSendAdvertisements | ( | bool | d | ) | [inline] |
void IPv6InterfaceData::setBaseReachableTime | ( | uint | d | ) | [inline] |
void IPv6InterfaceData::setCurHopLimit | ( | short | d | ) | [inline] |
void IPv6InterfaceData::setDupAddrDetectTransmits | ( | int | d | ) | [inline] |
void IPv6InterfaceData::setMaxRtrAdvInterval | ( | simtime_t | d | ) | [inline] |
void IPv6InterfaceData::setMinRtrAdvInterval | ( | simtime_t | d | ) | [inline] |
void IPv6InterfaceData::setReachableTime | ( | simtime_t | d | ) | [inline] |
void IPv6InterfaceData::setRetransTimer | ( | uint | d | ) | [inline] |
void IPv6InterfaceData::updateMatchingAddressExpiryTimes | ( | const IPv6Address & | prefix, | |
int | length, | |||
simtime_t | expiryTime = 0 , |
|||
simtime_t | prefExpiryTime = 0 | |||
) |
Update expiry times of addresses. Expiry times possibly come from prefixes (with on-link flag set to either zero or one) in Router Advertisements. Zero expiry time means infinity.
00148 { 00149 for (AddressDataVector::iterator it=addresses.begin(); it!=addresses.end(); it++) 00150 { 00151 if (it->address.matches(prefix,length)) 00152 { 00153 it->expiryTime = expiryTime; 00154 it->prefExpiryTime = prefExpiryTime; 00155 } 00156 } 00157 choosePreferredAddress(); 00158 }
HostVariables IPv6InterfaceData::hostVars [private] |
NodeVariables IPv6InterfaceData::nodeVars [private] |
IPv6Address IPv6InterfaceData::preferredAddr [private] |
simtime_t IPv6InterfaceData::preferredAddrExpiryTime [private] |
RouterVariables IPv6InterfaceData::rtrVars [private] |