MDestinationCache Class Reference

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.

Inherits from

Constructor & Destructor Documentation

~MDestinationCache()

~MDestinationCache()[inline, virtual]

Causes the actual implementation destructor to be called.

Member Functions Documentation

Cleanup()

voidCleanup()[pure virtual]

Iterate through the hashtable and remove expired entries from it. RemoveIf() method in THashTable can be used for this purpose.

CreateDstCache(TInt)

IMPORT_C MDestinationCache *CreateDstCache(TIntaKeyMode)[static]

Creates a destination cache instance into heap.

Parameters

TInt aKeyModeIndicates 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'.

Find(const TInetAddr &)

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.

Parameters

const TInetAddr & aAddr

Find(const TIp6Addr &)

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.

Parameters

const TIp6Addr & aAddr

Match(const TInetAddr &, const TInetAddr &)

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.

Parameters

const TInetAddr & aAddrA
const TInetAddr & aAddrB

RemoveAll()

voidRemoveAll()[pure virtual]

Removes all entries from the destination cache.

RemoveL(const TInetAddr &)

voidRemoveL(const TInetAddr &aAddr)[pure virtual]

Removes given entry from destination cache.

Parameters

const TInetAddr & aAddrAddress that identifies the cache entry.

SetL(const TInetAddr &, TUint, TUint32)

voidSetL(const TInetAddr &aAddr,
TUintaParIndex,
TUint32aValue
)[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.

Example:
	dstcache->SetL(address, EPathMTU, 536);

Parameters

const TInetAddr & aAddrDestination address used by the other end.
TUint aParIndexIndex of paramter variable in TCacheInfo array.
TUint32 aValueValue to be stored for the parameter.

SetLifetime(TUint)

voidSetLifetime(TUintaLifetime)[pure virtual]

Set the lifetime for cache entries in seconds.

Parameters

TUint aLifetime

SetMaxSize(TUint)

voidSetMaxSize(TUintaMaxSize)[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.

Parameters

TUint aMaxSize

StoreL(const TInetAddr &, TCacheInfo &)

voidStoreL(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.

Parameters

const TInetAddr & aAddrDestination address used by the other end.
TCacheInfo & aInfoParameter values that should be associated with this address. iStoreTime is set in this function, so the caller does not have to set it.

StoreL(const TIp6Addr &, TCacheInfo &)

voidStoreL(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);
Questions: ---------- 1) Should we assume that once cache entry is found, all values are valid?
  • Probably not. Have to reserve NULL for "invalid" or "don't use"

2) Should we just override the earlier values in cache when a later connection is closed, or should some smarter smoothing methods be used for storing
  • 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?

Parameters

const TIp6Addr & aAddr
TCacheInfo & aInfo