⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 patch2.4

📁 BCAST Implementation for NS2
💻 4
📖 第 1 页 / 共 5 页
字号:
+/* Store the hitless restart parameters in the file+ * /etc/ospfd.restart. These are regular TCL commands, which+ * will get read again when the ospfd restarts.+ */++const char *ospfd_rst_file = "/etc/ospfd.restart";++void LinuxOspfd::store_hitless_parms(int grace_period, int n, MD5Seq *sns)++{+    FILE *f;+    extern rtid_t new_router_id;+    in_addr addr;++    if (!(f = fopen(ospfd_rst_file, "w"))) {+        syslog(LOG_ERR, "Can't open %s for writing: %m", ospfd_rst_file);+	return;+    }++    fprintf(f, "grace_period %d\n", grace_period);+    addr.s_addr = hton32(new_router_id);+    fprintf(f, "routerid %s\n", inet_ntoa(addr));+    for (int i = 0; i < n; i++) {+        if (sns[i].if_addr != 0) {+	    addr.s_addr = hton32(sns[i].if_addr);+	    fprintf(f, "interface %s 1\n", inet_ntoa(addr));+	}+	else+	    fprintf(f, "interface %s 1\n", phyname(sns[i].phyint));+	fprintf(f, "md5_seqno %d\n", sns[i].seqno);+    }+    fclose(f);+}diff -X exclude_files -Nabur ospfd2.3/ospf_sim/linux/Makefile ospfd2.4/ospf_sim/linux/Makefile--- ospfd2.3/ospf_sim/linux/Makefile	Mon May 21 10:19:33 2001+++ ospfd2.4/ospf_sim/linux/Makefile	Thu Sep 13 16:05:52 2001@@ -17,6 +17,7 @@ 	  config.o \ 	  dbage.o \ 	  grplsa.o \+	  helper.o \ 	  hostmode.o \ 	  ifcfsm.o \ 	  lsa.o \@@ -32,6 +33,7 @@ 	  pat.o \ 	  phyint.o \ 	  priq.o \+	  restart.o \ 	  rte.o \ 	  rtrlsa.o \ 	  spfack.o \@@ -51,6 +53,7 @@ 	  linux.o \ 	  ospfd_sim.o \ 	  tcppkt.o \+	  tlv.o \ 	  sim_system.o  diff -X exclude_files -Nabur ospfd2.3/ospf_sim/mtrace.C ospfd2.4/ospf_sim/mtrace.C--- ospfd2.3/ospf_sim/mtrace.C	Mon May 21 10:19:32 2001+++ ospfd2.4/ospf_sim/mtrace.C	Thu Sep 13 16:05:51 2001@@ -177,6 +177,9 @@     int len;     IgmpPkt *igmppkt; +    if (!ospf)+        return;+     len = ntoh16(pkt->i_len);     igmppkt = (IgmpPkt *)(pkt + 1);     switch(igmppkt->ig_type) {diff -X exclude_files -Nabur ospfd2.3/ospf_sim/ospfd_sim.C ospfd2.4/ospf_sim/ospfd_sim.C--- ospfd2.3/ospf_sim/ospfd_sim.C	Mon May 21 10:19:32 2001+++ ospfd2.4/ospf_sim/ospfd_sim.C	Thu Sep 13 16:05:50 2001@@ -112,6 +112,12 @@ 	// Flush any logging messages 	if (ospf) 	    ospf->logflush();+	// If hitless restart preparation done, start ospfd again+	if (simsys->hitless_preparation_complete) {+	    simsys->hitless_preparation_complete = false;+	    delete ospf;+	    ospf = 0;+	} 	// Add connection to controller 	n_fd = simsys->ctl_fd; 	FD_SET(simsys->ctl_fd, &fdset);@@ -191,16 +197,12 @@     InAddr daddr;     SimRte *rte; -    // Discard packet if OSPF not ready-    if (!ospf)-        return;-     pkt = (InPkt *) (pkthdr+1);     daddr = ntoh32(pkt->i_dest);     xmt_stamp = pkthdr->ts;     if (!IN_CLASSD(daddr)) { 	InAddr home;-        if ((!get_port_addr(daddr, home)) || (home != ospf->my_id())) {+        if ((!get_port_addr(daddr, home)) || (home != my_id)) { 	    if (!(rte = rttbl.best_match(daddr))) { 	        sendicmp(ICMP_TYPE_UNREACH, ICMP_CODE_UNREACH_HOST, 			 0, 0, pkt, 0, 0, 0);@@ -259,6 +261,8 @@      switch(pkt->i_prot) {       case PROT_OSPF:+	// Discard packet if OSPF not ready+	if (ospf) 	ospf->rxpkt(phyint, pkt, ntoh16(pkt->i_len)); 	break;       case PROT_ICMP:@@ -337,7 +341,11 @@     socklen size;     SimHello hello; +    grace_period = sys_etime;+    hitless_preparation = false;+    hitless_preparation_complete = false;     ctl_fd = fd;+    my_addr = 0;     // Initialize time     ticks = 0;     // Allow core files@@ -404,6 +412,7 @@ 	PingStartMsg *pm; 	MTraceHdr *mtrm; 	MTraceSession *mtrace;+	HitlessRestartMsg *htlm; 	int phyint;         end = msg + nbytes; 	xmt_stamp = sys_etime;@@ -419,7 +428,7 @@ 	    xmt_stamp = sys_etime; 	    // Start OSPF, delayed so that time is initialized 	    // correctly-	    ospf = new OSPF(my_id);+	    ospf = new OSPF(my_id, sys_etime); 	    break; 	  case SIM_TICK: 	    // Advance time@@ -429,6 +438,7 @@ 	    sys_etime.msec = (ticks%TICKS_PER_SECOND) * 1000/TICKS_PER_SECOND; 	    xmt_stamp = sys_etime; 	    // Process any pending timers+	    if (ospf) 	    ospf->tick(); 	    // Process any queued receives 	    process_rcvqueue();@@ -440,6 +450,7 @@ 	    config(type, subtype, msg); 	    break;  	  case SIM_SHUTDOWN:+	    if (ospf) 	    ospf->shutdown(10); 	    break; 	  case SIM_ADDRMAP:@@ -485,11 +496,13 @@ 	    break; 	  case SIM_ADD_MEMBER: 	    grpm = (GroupMsg *) msg;+	    if (ospf) 	    ospf->join_indication(grpm->group, grpm->phyint); 	    join(grpm->group, grpm->phyint); 	    break; 	  case SIM_DEL_MEMBER: 	    grpm = (GroupMsg *) msg;+	    if (ospf) 	    ospf->leave_indication(grpm->group, grpm->phyint); 	    leave(grpm->group, grpm->phyint); 	    break;@@ -508,6 +521,11 @@ 	    // Will then get First tick, and config 	    break;  	  case SIM_RESTART_HITLESS:+	    htlm = (HitlessRestartMsg *) msg;+	    if (ospf)+	        ospf->hitless_restart(htlm->period, 1);+	    else+	        ospf = new OSPF(my_id, grace_period); 	    break; 	  default: 	    break;@@ -526,6 +544,9 @@          status = (type == SIM_CONFIG) ? ADD_ITEM : DELETE_ITEM; +    if (!ospf)+        return;+     switch(subtype) {         PhyintMap *phyp; 	CfgIfc *ifcmsg;@@ -549,6 +570,8 @@ 	} 	phyp->addr = ifcmsg->address; 	phyp->mask = ifcmsg->mask;+	if (!my_addr)+	    my_addr = ifcmsg->address; 	ospf->cfgIfc(ifcmsg, status); 	break;       case CfgType_VL:@@ -587,7 +610,6 @@  {     DBStats *statp;-    AreaIterator iter(ospf);     SpfArea *ap;     SpfArea *low;     int mlen;@@ -595,16 +617,22 @@     low = 0;     statp = new DBStats;     mlen = sizeof(DBStats);++    if (ospf) {+	AreaIterator iter(ospf);     statp->n_exlsas = ospf->n_extLSAs();     statp->ex_dbxsum = ospf->xsum_extLSAs();--     while ((ap = iter.get_next())) {       if (ap->n_active_if == 0) 	  continue;       if (!low || low->id() > ap->id()) 	  low = ap;     }+    }+    else {+	statp->n_exlsas = 0;+	statp->ex_dbxsum = 0;+    }      if (low) { 	statp->area_id = low->id();@@ -695,6 +723,9 @@     SimPktHdr *data;     MCache *ce; +    if (!ospf)+        return;+     len = ntoh16(pkt->i_len);     data = (SimPktHdr *) new byte[len+sizeof(SimPktHdr)];     data->ts = xmt_stamp;@@ -761,7 +792,7 @@         if (mapp->index1() != (uns32) phyint) 	    break; 	// Loopback ping packets-        if (mapp->home == ospf->my_id()) {+        if (mapp->home == my_id) { 	    if (loopback) 	       rxpkt(data);  	    continue;@@ -936,7 +967,7 @@     iphdr->i_len = hton16(len);     iphdr->i_id = 0;     iphdr->i_ttl = ((ttl != 0) ? ttl : DEFAULT_TTL);-    iphdr->i_src = src ? hton32(src) : hton32(ospf->ip_source(dest));+    iphdr->i_src = src ? hton32(src) : hton32(ip_source(dest));     iphdr->i_dest = hton32(dest);     iphdr->i_chksum = 0;	// Don't bother @@ -1053,5 +1084,22 @@ 	    break;     } -    return(rte->reject ? 0 : rte);+    return((!rte || rte->reject) ? 0 : rte);+}++/* Find the source address that would be used to send+ * packets to the given destination.+ */++InAddr SimSys::ip_source(InAddr dest)++{+    SimRte *rte;++    if ((rte = rttbl.best_match(dest))) {+        if (rte->if_addr != 0)+	    return(rte->if_addr);+    }++    return(my_addr); }diff -X exclude_files -Nabur ospfd2.3/ospf_sim/ospfd_sim.h ospfd2.4/ospf_sim/ospfd_sim.h--- ospfd2.3/ospf_sim/ospfd_sim.h	Mon May 21 10:19:32 2001+++ ospfd2.4/ospf_sim/ospfd_sim.h	Thu Sep 13 16:05:50 2001@@ -78,6 +78,7 @@     int uni_fd;	// Connection for packets addressed to us     uns16 uni_port; // Our port for locally addressed packets     int ticks; // Elapsed time in simulated ticks+    InAddr my_addr;	// One of router's IP addresses     AVLtree address_map; // IP address to group mapping     AVLtree port_map; // Phyint to file descriptor mapping     AVLtree membership; // Interface group membership		   @@ -90,6 +91,12 @@     AVLtree traceroutes;// Active traceroute sessions     AVLtree mtraces;	// Active multicast traceroutes     uns32 mtrace_qid;	// Next mtrace query ID+    // Stored hitless restart parameters+    bool hitless_preparation;+    bool hitless_preparation_complete;+    SPFtime grace_period;+    int n_md5;+    MD5Seq *snarray;   public:     SimSys(int fd);     ~SimSys();@@ -111,6 +118,7 @@     virtual void upload_remnants();     char *phyname(int phyint);     void sys_spflog(int code, char *buffer);+    virtual void store_hitless_parms(int, int, struct MD5Seq *);     void halt(int code, char *string);      void process_uni_fd();@@ -129,6 +137,7 @@     void recv_ctl_command();     void config(int type, int subtype, void *msg);     void send_tick_response();+    InAddr ip_source(InAddr dest);      friend int main(int argc, char *argv[]);     friend class PingSession;diff -X exclude_files -Nabur ospfd2.3/ospf_sim/sim.C ospfd2.4/ospf_sim/sim.C--- ospfd2.3/ospf_sim/sim.C	Mon May 21 10:19:32 2001+++ ospfd2.4/ospf_sim/sim.C	Thu Sep 13 16:05:50 2001@@ -700,6 +700,7 @@     fd = file;     got_tick = true;     home_port = 0;+    awaiting_htl_restart = false;     dbstats = 0;     sim->nodes[fd] = this;     sim->maxfd = MAX(file, sim->maxfd);@@ -781,13 +782,25 @@     SimNode *node;     HitlessRestartMsg m; -    m.period = 60;+    m.period = 100;     id = ntoh32(inet_addr(argv[1]));     if (!(node = (SimNode *) sim->simnodes.find(id, 0)))         Tcl_VarEval(interp, "startrtr ", argv[1], 0);-    else+    else if (node->awaiting_htl_restart) {+	// Complete hitless restart+        in_addr addr;+        node->awaiting_htl_restart =  false;         node->pktdata.queue_xpkt(&m, SIM_RESTART_HITLESS, 0, sizeof(m));-+	// Download node's configuration+	addr.s_addr = hton32(node->id());+	if (Tcl_VarEval(sim->interp,"sendcfg ", inet_ntoa(addr),0) != TCL_OK)+	    printf("sendcfg: %s\n", sim->interp->result);+    }+    else {+        // Prepare for hitless restart+        node->awaiting_htl_restart = true;+        node->pktdata.queue_xpkt(&m, SIM_RESTART_HITLESS, 0, sizeof(m));+    }     return(TCL_OK); } diff -X exclude_files -Nabur ospfd2.3/ospf_sim/sim_system.C ospfd2.4/ospf_sim/sim_system.C--- ospfd2.3/ospf_sim/sim_system.C	Mon May 21 10:19:32 2001+++ ospfd2.4/ospf_sim/sim_system.C	Thu Sep 13 16:05:50 2001@@ -308,7 +308,28 @@  {   char buffer[80]; +    if (code == 0 && hitless_preparation) {+        hitless_preparation = false;+        hitless_preparation_complete = true;+        return;+    }     sprintf(buffer, "Exiting: %s, code %d", string, code);     sys_spflog(ERR_SYS, buffer);     abort(); }++/* Simulated router has successfully prepared for a hitless+ * restart.+ */++void SimSys::store_hitless_parms(int period, int n, MD5Seq *sns)++{+    time_add(sys_etime, period*Timer::SECOND, &grace_period);+    delete snarray;+    snarray = new MD5Seq[n];+    n_md5 = n;+    memcpy(snarray, sns, n*sizeof(MD5Seq));+    hitless_preparation = true;+}+diff -X exclude_files -Nabur ospfd2.3/ospf_sim/simctl.h ospfd2.4/ospf_sim/simctl.h--- ospfd2.3/ospf_sim/simctl.h	Mon May 21 10:19:32 2001+++ ospfd2.4/ospf_sim/simctl.h	Thu Sep 13 16:05:50 2001@@ -95,6 +95,7 @@     bool got_tick;	// Received tick response (init to true!)     NodeStats *dbstats; // Stored database statistics     uns16 home_port;	// Unicast listening port+    bool awaiting_htl_restart;     int color;		// Current node color     enum {		// Available colors         WHITE,		// not syncheddiff -X exclude_files -Nabur ospfd2.3/ospf_sim/x86/Makefile ospfd2.4/ospf_sim/x86/Makefile--- ospfd2.3/ospf_sim/x86/Makefile	Mon May 21 10:19:31 2001+++ ospfd2.4/ospf_sim/x86/Makefile	Thu Sep 13 16:05:50 2001@@ -17,6 +17,7 @@ 	  config.o \ 	  dbage.o \ 	  grplsa.o \+	  helper.o \ 	  hostmode.o \ 	  ifcfsm.o \ 	  lsa.o \@@ -32,6 +33,7 @@ 	  pat.o \ 	  phyint.o \ 	  priq.o \+	  restart.o \ 	  rte.o \ 	  rtrlsa.o \ 	  spfack.o \@@ -51,6 +53,7 @@ 	  linux.o \ 	  ospfd_sim.o \ 	  tcppkt.o \+	  tlv.o \ 	  sim_system.o  diff -X exclude_files -Nabur ospfd2.3/src/asbrlsa.C ospfd2.4/src/asbrlsa.C--- ospfd2.3/src/asbrlsa.C	Mon May 21 10:19:27 2001+++ ospfd2.4/src/asbrlsa.C	Thu Sep 13 16:05:43 2001@@ -107,12 +107,12 @@     }   get_seqno:-    if ((seqno = ospf->ospf_get_seqno(olsap, length, forced)) == InvalidLSSeq)+    if ((seqno = ospf->ospf_get_seqno(LST_ASBR,olsap, forced)) == InvalidLSSeq) 	return;      // Fill in LSA contents     // Header-    hdr = ospf->orig_buffer();+    hdr = ospf->orig_buffer(length);     hdr->ls_opts = 0;     if (ls_id != ospf->my_id())

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -