class MDestinationCache : public MInetBase |
This will be accessed using MInterfaceManager and the IMPORT_API_L mechanism. StoreL, etc. will use THashTable. Depending on the granularity parameter, the IP address is used as a hash key either directly or only by a portion of address prefix. The granularity prefix will be an ini parameter, for example:
dstcache= [0="do not use cache", 1="cache entry per each address", 2="cache entry per address prefix", 3="cache entry per network interface" (not yet implemented)]
In addition, another ini parameter, "dst_lifetime" will be defined. This gives the default lifetime for a cache entry (in seconds). 10 minutes could be a good default value, or should it be shorter (5 min?)?
Additionally "dst_maxsize" gives the maximum size of the cache hash in bytes. 2048 would be a good default value.
Public Member Functions | |
---|---|
~MDestinationCache() | |
void | Cleanup() |
IMPORT_C MDestinationCache * | CreateDstCache(TInt) |
const TCacheInfo * | Find(const TInetAddr &) |
const TCacheInfo * | Find(const TIp6Addr &) |
TBool | Match(const TInetAddr &, const TInetAddr &) |
void | RemoveAll() |
void | RemoveL(const TInetAddr &) |
void | SetL(const TInetAddr &, TUint, TUint32) |
void | SetLifetime(TUint) |
void | SetMaxSize(TUint) |
void | StoreL(const TInetAddr &, TCacheInfo &) |
void | StoreL(const TIp6Addr &, TCacheInfo &) |
Inherited Functions | |
---|---|
MInetBase::GetApiL(const TDesC8 &,TUint *) | |
MInetBase::GetApiL(const TDesC8 &,TUint) |
~MDestinationCache | ( | ) | [inline, virtual] |
Causes the actual implementation destructor to be called.
void | Cleanup | ( | ) | [pure virtual] |
Iterate through the hashtable and remove expired entries from it. RemoveIf() method in THashTable can be used for this purpose.
IMPORT_C MDestinationCache * | CreateDstCache | ( | TInt | aKeyMode | ) | [static] |
Creates a destination cache instance into heap.
TInt aKeyMode | Indicates by an integer whether there will be separate cache entry per each address (=1), or common cache entry for addresses with same prefix (=2). The integer is equal to what is read from tcpip6.ini file for 'dstcache'. |
const TCacheInfo * | Find | ( | const TInetAddr & | aAddr | ) | [pure virtual] |
Tries to find data with given address. Returns NULL, if the data was not found, or it was expired.
const TInetAddr & aAddr |
const TCacheInfo * | Find | ( | const TIp6Addr & | aAddr | ) | [inline] |
Old interface for source backwards compatibility. This one has flawed design, because it does not specify scope ID. One should use TInetAddr - version instead.
const TIp6Addr & aAddr |
TBool | Match | ( | const TInetAddr & | aAddrA, |
const TInetAddr & | aAddrB | |||
) | const [pure virtual] |
Checks whether the two addresses are mapped to the same destination cache entry. This takes the selected caching mode (per address or per network) into account.
void | RemoveL | ( | const TInetAddr & | aAddr | ) | [pure virtual] |
Removes given entry from destination cache.
const TInetAddr & aAddr | Address that identifies the cache entry. |
void | SetL | ( | const TInetAddr & | aAddr, |
TUint | aParIndex, | |||
TUint32 | aValue | |||
) | [pure virtual] |
Modifies a single parameter of a cache entry, while maintaining the values of the other parameters. Leaves with error if the given cache entry is not found. The iStoreEntry is also updated to current time.
dstcache->SetL(address, EPathMTU, 536);
void | SetLifetime | ( | TUint | aLifetime | ) | [pure virtual] |
Set the lifetime for cache entries in seconds.
TUint aLifetime |
void | SetMaxSize | ( | TUint | aMaxSize | ) | [pure virtual] |
Set maximum size of the destination cache in bytes. If there are more than this much non-expired cache entries, new hash items are not added.
TUint aMaxSize |
void | StoreL | ( | const TInetAddr & | aAddr, |
TCacheInfo & | aInfo | |||
) | [pure virtual] |
Store a cache entry with given destination address and data. The space for data object is allocated from heap and the object is copied there. If there was an existing cache object with the same key, it is overwritten without further warnings. If the cache is full and no expired objects can be removed, leaves with an error.
const TInetAddr & aAddr | Destination address used by the other end. |
TCacheInfo & aInfo | Parameter values that should be associated with this address. iStoreTime is set in this function, so the caller does not have to set it. |
void | StoreL | ( | const TIp6Addr & | aAddr, |
TCacheInfo & | aInfo | |||
) | [inline] |
Old interface for source backwards compatibility. This one has flawed design, because it does not specify scope ID. One should use TInetAddr - version instead.
The code could be something like following at the protocol SAP side
When opening a connection (This could be in the end of InitL() in TCP SAP):
MInterfaceManager *ifacer = Interfacer(); MDestinationCache *dstcache = IMPORT_API_L(ifacer, MDestinationCache); TIp6Addr& addr = iFlowContext->RemoteAddr().Ip6Address(); TCacheInfo *cache = dstcache->Find(addr); if (cache) { iSsthresh = cache->iMetrics[ESsThresh]; iSRTT = cache->iMetrics[ESRtt]; }
When closing a connection:
MDestinationCache *dstcache = ...IMPORT_API_L()...; TIp6Addr& addr = iFlowContext->RemoteAddr().Ip6Address(); TCacheInfo cache; // Should intialize to zero cache.iMetrics[ESsThresh] = iSsthresh; cache.iMetrics[ESRtt] = iSRTT; dstcache->StoreL(addr, cache);
Probably not. Have to reserve NULL for "invalid" or "don't use"
Just overriding with store would be a straightforward alternative to be implemented in the first place, but it may be subject to instability in stored values.
3) What kind of "safeguards" should there be when storing or applying values in cache? (probably rules something like "don't use ssthresh if it is <= 4" are needed)
4) Should there be some snapshots stored in the cache during lengthy TCP connections, or is it enough to store values only when closing TCP connection?
const TIp6Addr & aAddr | |
TCacheInfo & aInfo |
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.