Exemplo n.º 1
0
from pyccn import Interest, Name, Key, CCN, _pyccn
import datetime

k = CCN.getDefaultKey()

i = Interest()
i.name = Name('/hello/world')
i.minSuffixComponents = 2
i.maxSuffixComponents = 4
i.publisherPublicKeyDigest = k.publicKeyID
i.exclude = None
i.childSelector = 1
i.answerOriginKind = 4
i.scope = 2
i.interestLifetime = 30.0
i.nonce = b'abababa'

print(i)
print(i.ccn_data)

i2 = _pyccn.Interest_obj_from_ccn(i.ccn_data)
print(i2)

assert (i.name == i2.name)
assert (i.minSuffixComponents == i2.minSuffixComponents)
assert (i.maxSuffixComponents == i2.maxSuffixComponents)
assert (i.publisherPublicKeyDigest == i2.publisherPublicKeyDigest)
assert (i.exclude == i2.exclude)
assert (i.childSelector == i2.childSelector)
assert (i.scope == i2.scope)
assert (i.interestLifetime == i2.interestLifetime)
Exemplo n.º 2
0
from pyccn import Interest, Name, Key, CCN, _pyccn
import datetime

k = CCN.getDefaultKey()

i = Interest()
i.name = Name('/hello/world')
i.minSuffixComponents = 2
i.maxSuffixComponents = 4
i.publisherPublicKeyDigest = k.publicKeyID
i.exclude = None
i.childSelector = 1
i.answerOriginKind = 4
i.scope = 2
i.interestLifetime = 30.0
i.nonce = b'abababa'

print(i)
print(i.ccn_data)

i2 = _pyccn.Interest_obj_from_ccn(i.ccn_data)
print(i2)

assert(i.name == i2.name)
assert(i.minSuffixComponents == i2.minSuffixComponents)
assert(i.maxSuffixComponents == i2.maxSuffixComponents)
assert(i.publisherPublicKeyDigest == i2.publisherPublicKeyDigest)
assert(i.exclude == i2.exclude)
assert(i.childSelector == i2.childSelector)
assert(i.scope == i2.scope)
assert(i.interestLifetime == i2.interestLifetime)
Exemplo n.º 3
0
from pyccn import CCN, Name, Interest, Key, ContentObject, Closure, KeyLocator, ExclusionFilter
from Tyzx import CompositeObject, BaseObject

prefix = "ccnx:/ndn/ucla.edu/apps/tv1/occupants"

DISCOVER_INTEREST_PERIOD = 0.250  # How often
UPDATE_INTEREST_PERIOD = 0.250
CCN_WAIT_TIME_MS = 1

tyzxObjects = {}
oldObjects = set()  # still may be in the content store

ccn = CCN()

interestDiscover = Interest()
interestDiscover.name = Name(prefix)
interestDiscover.minSuffixComponents = 2  # occupant id + the implicit digest at a minimum

interestUpdate = Interest()
interestUpdate.minSuffixComponents = 2  # time (version) + the implicit digest
interestUpdate.childSelector = 1  # rightmost child
#interestUpdate.interestLifetime = ????

lastdiscovertime = 0


def versionFromTime(t):
    bintime = struct.pack("!Q", int(t * 4096 + 0.5))
    version = bintime.lstrip(b'\x00')
    return b'\xfd' + version
Exemplo n.º 4
0
from pyccn import CCN, Name, Interest, Key, ContentObject, Closure, KeyLocator, ExclusionFilter
from Tyzx import CompositeObject, BaseObject

prefix = "ccnx:/ndn/ucla.edu/apps/tv1/occupants"        

DISCOVER_INTEREST_PERIOD = 0.250    # How often 
UPDATE_INTEREST_PERIOD = 0.250   
CCN_WAIT_TIME_MS = 1
        
tyzxObjects = {}    
oldObjects = set()    # still may be in the content store

ccn = CCN()

interestDiscover = Interest()
interestDiscover.name = Name(prefix)
interestDiscover.minSuffixComponents = 2   # occupant id + the implicit digest at a minimum

interestUpdate = Interest()
interestUpdate.minSuffixComponents = 2   # time (version) + the implicit digest
interestUpdate.childSelector = 1         # rightmost child
#interestUpdate.interestLifetime = ???? 

lastdiscovertime = 0     

def versionFromTime(t):
    bintime = struct.pack("!Q", int(t * 4096 + 0.5))
    version = bintime.lstrip(b'\x00')
    return b'\xfd' + version
last_version_marker = '\xfe\x00\x00\x00\x00\x00\x00'