Beispiel #1
0
 public RSUEntity(int id, int hops, int nbs, Certificate cert, bool isWired)
 {
     this.id = id;
     this.hops = hops;
     this.nbs = nbs;
     this.cert = cert;
     this.isWired = isWired;
 }
 public CertificateArg(Certificate cert, CertificateMethod method)
 {
     this.cert = cert;
     this.method = method;
 }
Beispiel #3
0
 public VANETReader(int id, int org)
     : base(id, org)
 {
     this.global = (VANETGlobal)Global.getInstance();
     int[] key = new int[32];
     key[0] = (int)NodeType.READER;
     key[1] = id;
     key[2] = 0;
     this.IssuedCertificate = new Certificate(id, key, Certificate.RootCA.CAId, Certificate.RootCA.CAPubKey);
     this.RSUCache = new Dictionary<int, RSUEntity>();
     this.CertificateCache = new Dictionary<string, CertificateCache>();
     this.NeighborBackbones = new Dictionary<int, int>();
     this.pendingCerterficatingObjects = new Dictionary<int, float>();
 }
Beispiel #4
0
        public void RecvCertificate(Packet pkg)
        {
            if (pkg.Next != this.Id)
                return;

            //rsu收到obu的证书,进行验证
            if (pkg.SrcType != NodeType.OBJECT)
            {
                Console.WriteLine("Wrong prev type!");
                return;
            }

            string key = pkg.VANETCertificate.getStrPubKey();

            Certificate c = new Certificate(pkg.VANETCertificate.Id, pkg.VANETCertificate.PubKey, pkg.VANETCertificate.CAId, pkg.VANETCertificate.CAPubKey);
            float delay = GetCheckCertificateDelay(c);

            //如果本地缓存中没有证书,则向ca请求;不是由本节点认证的话,直接验证(delay=0)
            if (delay > 0.0001f)
            {
                CertificateArg arg = new CertificateArg(c, CertificateMethod.REMOTE_AUTH);
                Console.WriteLine("---------------------------------");
                Event.AddEvent(new Event(scheduler.currentTime + delay, EventType.CHK_CERT, this, arg));
                return;
            }

            if(this.CertificateCache[key].authenticatedRSUId != this.Id)
            {
                CertificateArg arg = new CertificateArg(c, CertificateMethod.LOCAL);
                Console.WriteLine("---------------------------------");
                Event.AddEvent(new Event(scheduler.currentTime + delay, EventType.CHK_CERT, this, arg));
            }
            else//否则直接通过
            {
                //认证完毕之后删除
                float starttime = this.pendingCerterficatingObjects[c.Id];
                this.pendingCerterficatingObjects.Remove(c.Id);

                Packet pkg1 = new Packet(this, global.objects[c.Id], PacketType.DATA_AVAIL);
                pkg1.Data = starttime;
                SendPacketDirectly(scheduler.currentTime, pkg1);
            }
            if (IsPreFetchCertificate(c))
            {
                CertificateArg arg = new CertificateArg(c, CertificateMethod.REMOTE_RETR);
                Console.WriteLine("prefetch---------------------------------");
                Event.AddEvent(new Event(scheduler.currentTime + global.checkCertDelay, EventType.CHK_CERT, this, arg));
                this.prefetchingCertIds.Add(c.Id);
            }
        }
Beispiel #5
0
 public CertificateCache(Certificate cert, int time, int authenticatedRSUId)
 {
     this.cert = cert;
     this.time = time;
     this.authenticatedRSUId = authenticatedRSUId;
 }
Beispiel #6
0
 public bool IsPreFetchCertificate(Certificate cert)
 {
     //已经在取了,取消
     if (this.prefetchingCertIds.Contains(cert.Id))
         return false;
     string key = cert.getStrPubKey();
     //证书缓存中有该项
     //0.3f是一个较小的值
     if (this.CertificateCache.ContainsKey(key) && scheduler.currentTime - this.CertificateCache[key].time > 10-global.checkCertDelay-0.3f)
         return true;
     else
         return false;
 }
Beispiel #7
0
 public float GetCheckCertificateDelay(Certificate cert)
 {
     string key = cert.getStrPubKey();
     //证书缓存中有该项
     if (this.CertificateCache.ContainsKey(key) && scheduler.currentTime - this.CertificateCache[key].time < 10)
         return 0;
     return global.checkCertDelay;
 }
Beispiel #8
0
 public VANETRSUJoinField(int id, int hops, int nbs, Certificate cert, bool isWired)
 {
     this.id = id;
     this.hops = hops;
     this.nbs = nbs;
     this.cert = cert;
     this.isWired = isWired;
 }
Beispiel #9
0
 public VANETNewBackboneResponseField(Certificate cert)
 {
     this.rsuCert = cert;
 }
Beispiel #10
0
 public VANETNewBackboneRequestField(Certificate cert)
 {
     this.backboneCert = cert;
 }
Beispiel #11
0
 public VANETCAForwardField(Certificate rsuCA, Certificate objCA, int time, int hops, int src)
 {
     this.rsuCA = rsuCA;
     this.objCA = objCA;
     this.time = time;
     this.hops = hops;
     this.src = src;
 }