[Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip/ospf OSPF.java,1.3,1.4 OSPFDTBdescription_pack
Status: Beta
Brought to you by:
darkkey
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2663/core/protocolsuite/tcp_ip/ospf Modified Files: OSPF.java OSPFDTBdescription_packet.java OSPF_lsaheader.java OSPF_lsatypeone.java OSPFlinkstateupdate_packet.java Log Message: Index: OSPFDTBdescription_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPFDTBdescription_packet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** OSPFDTBdescription_packet.java 22 Feb 2006 14:05:53 -0000 1.5 --- OSPFDTBdescription_packet.java 23 Feb 2006 16:52:54 -0000 1.6 *************** *** 62,66 **** return DDSequenceNumber; } ! /*public String GetRouterID() { --- 62,69 ---- return DDSequenceNumber; } ! public void SetDDsequencenumber(int inDDsequencenumber) ! { ! DDSequenceNumber = inDDsequencenumber; ! } /*public String GetRouterID() { Index: OSPF_lsatypeone.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF_lsatypeone.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OSPF_lsatypeone.java 10 Feb 2006 18:01:56 -0000 1.1 --- OSPF_lsatypeone.java 23 Feb 2006 16:52:54 -0000 1.2 *************** *** 39,43 **** /** Creates a new instance of OSPF_lsatypeone */ ! public OSPF_lsatypeone(int b, int v, int e, int Count) { VEB=new int[8]; --- 39,43 ---- /** Creates a new instance of OSPF_lsatypeone */ ! public OSPF_lsatypeone(int Count) { VEB=new int[8]; *************** *** 47,59 **** VEB[i]=0; } - VEB[0]=b; - VEB[1]=e; - VEB[2]=v; LinkCount=Count; } ! public void OSPFaddlink(String inlinID, String inLinkData, int intype, int inTos0metric) { LinkDeclaration t = new LinkDeclaration(); ! t.LinkID=inlinID; t.LinkData=inLinkData; t.Type=intype; --- 47,56 ---- VEB[i]=0; } LinkCount=Count; } ! public void OSPFaddlink(String inlinkID, String inLinkData, int intype, int inTos0metric) { LinkDeclaration t = new LinkDeclaration(); ! t.LinkID=inlinkID; t.LinkData=inLinkData; t.Type=intype; *************** *** 61,63 **** --- 58,70 ---- this.linkslist.addElement(t); } + + public void SetLinkCount(int incount) + { + LinkCount=incount; + } + + public int GetLinkCount () + { + return LinkCount; + } } Index: OSPFlinkstateupdate_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPFlinkstateupdate_packet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OSPFlinkstateupdate_packet.java 10 Feb 2006 18:01:56 -0000 1.1 --- OSPFlinkstateupdate_packet.java 23 Feb 2006 16:52:54 -0000 1.2 *************** *** 29,33 **** --- 29,53 ---- } + public Vector GetLsaHeaderlist() + { + return lsa_headers; + } + + public Vector GetLsaAdvertismentlist() + { + return lsa_advert; + } + + public void AddLsaHeader(OSPF_lsaheader inheader) + { + lsa_headers.addElement(inheader); + } + + public void AddLsaAdv(OSPF_lsatypeone inlsa) + { + lsa_advert.addElement(inlsa); + } + } Index: OSPF.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OSPF.java 22 Feb 2006 14:05:53 -0000 1.3 --- OSPF.java 23 Feb 2006 16:52:53 -0000 1.4 *************** *** 39,42 **** --- 39,43 ---- private String BackupDesignatedRouter; private int Priority; // Administrator task; + private static int DDSN = -32768; // sequence number // graf net private Vector Graf = new Vector (); *************** *** 55,58 **** --- 56,60 ---- public String RouterID; public int Metric; + public String AdvertisingRouter; public RouterLink() { } }// end *************** *** 216,220 **** // send hello packet AddRouter(inPacket.GetRouterID(), RouterID, 1); ! SendospfHelloPacket(inPacket.GetRouterID()); } --- 218,222 ---- // send hello packet AddRouter(inPacket.GetRouterID(), RouterID, 1); ! SendospfHelloPacket(inPacket.GetRouterID(), ""); } *************** *** 233,238 **** //SendHelloPacket(); ! SendospfHelloPacket(inPacket.GetRouterID()); } } } --- 235,249 ---- //SendHelloPacket(); ! SendospfHelloPacket(inPacket.GetRouterID(), ""); ! } ! } ! else ! { ! if (inPacket.GetPriority()>Priority) ! { ! BackupDesignatedRouter = DesignatedRouter; ! DesignatedRouter = inPacket.GetRouterID(); } + } } *************** *** 243,251 **** *method to send hello packet */ ! public /*OSPFhello_packet*/ void SendospfHelloPacket(String inDestIPAddress) { OSPFhello_packet tosend = new OSPFhello_packet(); tosend.Setpriority(Priority); tosend.SetRouterID(RouterID); int i; for (i=1; i<=Graf.size(); i++) --- 254,263 ---- *method to send hello packet */ ! public /*OSPFhello_packet*/ void SendospfHelloPacket(String inDestIPAddress, String inDesignatedRouter) { OSPFhello_packet tosend = new OSPFhello_packet(); tosend.Setpriority(Priority); tosend.SetRouterID(RouterID); + tosend.SetDesignatedRouter(inDesignatedRouter); int i; for (i=1; i<=Graf.size(); i++) *************** *** 317,321 **** * */ ! public OSPFDTBdescription_packet SendDescriptionPacket(int a, int b, int c, int num, int islist) { OSPFDTBdescription_packet tosend = new OSPFDTBdescription_packet(a,b,c, num); --- 329,333 ---- * */ ! public void SendDescriptionPacket(int a, int b, int c, int num, int islist) { OSPFDTBdescription_packet tosend = new OSPFDTBdescription_packet(a,b,c, num); *************** *** 323,330 **** if (islist>0) // need to send full packet so need to copy all lsa headers { ! //copy all list ! // need to copy from router to the packet } ! return tosend; } --- 335,368 ---- if (islist>0) // need to send full packet so need to copy all lsa headers { ! // find line in graf there are all neighbors of current router ! int flag=0; ! int i=0; ! int j=0; ! while ((flag==0) && (i<Graf.size())) ! { ! if (((RouterRecord)Graf.elementAt(i)).RouterID.equals(RouterID)) ! { ! flag=1; ! } ! } ! if (flag==1) ! { ! // cycle ! for (j=0; j<((RouterRecord)Graf.elementAt(i)).NeighborRouters.size(); j++) ! { ! // create lsa header to each neighbor of router ! OSPF_lsaheader t =new OSPF_lsaheader(); ! tosend.OSPFAddHeader(t); /*!!!*/ ! ! ! } ! } } ! // send packet to designated router ! tosend.SetDDsequencenumber(DDSN); ! //DDSN++; //!!! ! tosend.setDestIPAddress(DesignatedRouter); ! mParentStack.sendPacket(tosend); ! } *************** *** 352,358 **** } ! public OSPFlinkstateupdate_packet SendLinkStateUpdatePacket() { ! return null; } /* --- 390,433 ---- } ! public void SendLinkStateUpdatePacket() { ! if (DesignatedRouter != "") ! { ! OSPFlinkstateupdate_packet tosend = new OSPFlinkstateupdate_packet(); ! tosend.setDestIPAddress(DesignatedRouter); ! // find line of current router neighbors ! int i=0; ! int j=0; ! int flag=0; ! while ((flag==0) && (i<Graf.size())) ! { ! if (((RouterRecord)Graf.elementAt(i)).RouterID == RouterID) ! { ! flag=1; ! } ! i++; ! } ! // create lsa header ! OSPF_lsaheader a = new OSPF_lsaheader(); ! // create lsa message ! OSPF_lsatypeone b = new OSPF_lsatypeone(((RouterRecord)Graf.elementAt(i-1)).NeighborRouters.size()); ! a.SetLStype(1); ! a.SetLSID(DesignatedRouter); ! a.SetLSsequencenumber(DDSN); ! DDSN++; ! for (j=0; j<((RouterRecord)Graf.elementAt(i-1)).NeighborRouters.size(); j++) ! { ! // full all link declaration ! String tempRouterId = ((RouterLink)((RouterRecord)Graf.elementAt(i-1)).NeighborRouters.elementAt(j)).RouterID; ! int tempmetric = ((RouterLink)((RouterRecord)Graf.elementAt(i-1)).NeighborRouters.elementAt(j)).Metric; ! b.OSPFaddlink(tempRouterId, tempRouterId, 1, tempmetric); ! } ! tosend.AddLsaHeader(a); ! tosend.AddLsaAdv(b); ! try ! { ! mParentStack.sendPacket(tosend); ! }catch (Exception e) {} ! } } /* Index: OSPF_lsaheader.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF_lsaheader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OSPF_lsaheader.java 22 Feb 2006 14:05:53 -0000 1.3 --- OSPF_lsaheader.java 23 Feb 2006 16:52:54 -0000 1.4 *************** *** 86,90 **** *v1.0 */ ! public int SetLStype() { return LS_type; --- 86,90 ---- *v1.0 */ ! public int GetLStype() { return LS_type; |