diff -ur common/mobilenode.h ns-umts-extensions/code/mobilenode.h
--- common/mobilenode.h	2001-02-07 10:25:35.000000000 +0000
+++ ns-umts-extensions/code/mobilenode.h	2003-06-01 20:10:45.000000000 +0000
@@ -1,5 +1,36 @@
-/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- 
+/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
  *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
+ *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
+/*
  * Copyright (c) 1997 Regents of the University of California.
  * All rights reserved.
  *
@@ -117,7 +148,7 @@
 	MobileNode *node;
 };
 
-class MobileNode : public Node 
+class MobileNode : public Node
 {
 	friend class PositionHandler;
 public:
@@ -127,12 +158,11 @@
 	double	distance(MobileNode*);
 	double	propdelay(MobileNode*);
 	void	start(void);
-        inline void getLoc(double *x, double *y, double *z) {
-		update_position();  *x = X_; *y = Y_; *z = Z_;
-	}
-        inline void getVelo(double *dx, double *dy, double *dz) {
-		*dx = dX_ * speed_; *dy = dY_ * speed_; *dz = 0.0;
-	}
+        // P.M. & P.B. modifications, before there were two inlines 
+	  // not working properly, getLoc y getVelo
+	  void getLoc(double *x, double *y, double *z);
+	  void getVelo(double *dx, double *dy, double *dz);
+
 	inline MobileNode* nextnode() { return link_.le_next; }
 	inline int base_stn() { return base_stn_;}
 	inline void set_base_stn(int addr) { base_stn_ = addr; }
@@ -224,7 +254,11 @@
 	 * Trace Target
 	 */
 	Trace* log_target_;
-        /* 
+	/* P.M. & P.B. modifications
+	 * Link Layer
+	 */
+	LL* ll_;
+	  /*
 	 * base_stn for mobilenodes communicating with wired nodes
          */
 	int base_stn_;
diff -ur common/node.cc ns-umts-extensions/code/node.cc
--- common/node.cc	2002-05-30 17:44:03.000000000 +0000
+++ ns-umts-extensions/code/node.cc	2003-06-01 20:10:45.000000000 +0000
@@ -1,5 +1,36 @@
-/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-
+/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
  *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
+ *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
+/*
  * Copyright (c) 1997 Regents of the University of California.
  * All rights reserved.
  *
@@ -33,9 +64,9 @@
  *
  * $Header: /nfs/jade/vint/CVSROOT/ns-2/common/node.cc,v 1.34 2002/05/30 17:44:03 haldar Exp $
  *
- * CMU-Monarch project's Mobility extensions ported by Padma Haldar, 
+ * CMU-Monarch project's Mobility extensions ported by Padma Haldar,
  * 10/98.
- */
+ */ 
 
 #include <stdio.h>
 #include <stdarg.h>
@@ -47,6 +78,10 @@
 #endif //HAVE_STL
 #include "node.h"
 
+// P.M. & P.B. modifications
+#include <ctype.h>
+
+
 static class LinkHeadClass : public TclClass {
 public:
 	LinkHeadClass() : TclClass("Connector/LinkHead") {}
@@ -57,7 +92,7 @@
 
 LinkHead::LinkHead() : net_if_(0), node_(0), type_(0) { }
 
-int32_t LinkHead::label() 
+int32_t LinkHead::label()
 {
 	if (net_if_)
 		return net_if_->intf_label();
@@ -77,7 +112,7 @@
 				return TCL_ERROR;
 			return TCL_OK;
 		} else if(strcmp(argv[1], "setnode") == 0) {
-			node_ = (Node*) TclObject::lookup(argv[2]); 
+			node_ = (Node*) TclObject::lookup(argv[2]);
 			if (node_ == 0)
 				return TCL_ERROR;
 			return TCL_OK;
@@ -86,7 +121,7 @@
 	return (Connector::command(argc, argv));
 }
 
-
+
 static class NodeClass : public TclClass {
 public:
 	NodeClass() : TclClass("Node") {}
@@ -97,12 +132,15 @@
 
 struct node_head Node::nodehead_ = { 0 }; // replaces LIST_INIT macro
 
+// P.M. & P.B. modifications
+SLList *Node::list = new SLList();
+
 char Node::nwrk_[NODE_NAMLOG_BUFSZ];
 
 /* Additions for NixRouting */
 int NixRoutingUsed = -1;
 
-Node::Node() : 
+Node::Node() :
 	address_(-1), nodeid_ (-1), namChan_(0),
 	rtnotif_(NULL),
 #ifdef HAVE_STL
@@ -128,6 +166,11 @@
 	}
 #endif //HAVE_STL
 	neighbor_list_ = NULL;
+
+	// P.M. & P.B. modifications
+	update_ = 0;
+	bind("update_", &update_);
+
 }
 
 Node::~Node()
@@ -135,6 +178,43 @@
 	LIST_REMOVE(this, entry);
 }
 
+// P.M. & P.B. modifications
+double Node::bw_atof(const char* s)
+{
+	char wrk[32];
+	char* cp = wrk;
+	while (isdigit(*s) || *s == 'e' || *s == '+' ||
+	       *s == '-' || *s == '.')
+		*cp++ = *s++;
+	*cp = 0;
+	double v = atof(wrk);
+	switch (s[0]) {
+	case 'k':
+	case 'K':
+		v *= 1e3;
+		break;
+	case 'm':
+	case 'M':
+		v *= 1e6;
+		break;
+	case 'g':
+	case 'G':
+		v *= 1e9;
+		break;
+	case 't':
+	case 'T':
+		v *= 1e12;
+		break;
+	case 'p':
+	case 'P':
+		v *= 1e15;
+		break;
+	}
+	return (v);
+}
+
+
+
 int
 Node::command(int argc, const char*const* argv)
 {
@@ -215,7 +295,14 @@
 			addNeighbor(node);
 			return TCL_OK;
 		}
-	}
+	// P.M. & P.B. modifications
+	} else if (argc == 5) {
+		if (strcmp(argv[3], "rate_") == 0) {
+			int id = nodeid();
+			list->AddANode(id, atoi(argv[1]), bw_atof(argv[4]), (char*)argv[2]);
+			return TCL_OK;
+		}
+	}  
 	return ParentNode::command(argc,argv);
 }
 
@@ -225,7 +312,7 @@
 	else
 		rtnotif_->route_notify(rtm);
 }
-
+ 
 void Node::unreg_route_notify(RoutingModule *rtm) {
 	if (rtnotif_) {
 		if (rtnotif_ == rtm) {
@@ -264,13 +351,13 @@
 	neighbor_list_node* nlistItem = (neighbor_list_node *)malloc(sizeof(neighbor_list_node));
 	nlistItem->nodeid = neighbor->nodeid();
 	nlistItem->next = neighbor_list_;
-	neighbor_list_=nlistItem; 
+	neighbor_list_=nlistItem;
 }
 
 void Node::namlog(const char* fmt, ...)
 {
 	// Don't do anything if we don't have a log file.
-	if (namChan_ == 0) 
+	if (namChan_ == 0)
 		return;
 	va_list ap;
 	va_start(ap, fmt);
@@ -282,9 +369,10 @@
 {
         int n = 0;
         /* Otherwise nwrk_ isn't initialized */
+
 	n = strlen(nwrk_);
 	if (n >= NODE_NAMLOG_BUFSZ-1) {
-		fprintf(stderr, 
+		fprintf(stderr,
 			"Node::namdump() exceeds buffer size. Bail out.\n");
 		abort();
 	}
@@ -300,12 +388,12 @@
 	}
 }
 
-// Given an interface label for a NetworkInterface on this node, we return 
+// Given an interface label for a NetworkInterface on this node, we return
 // the head of that link
 NsObject* Node::intf_to_target(int32_t label)
 {
 	LinkHead *lhp = linklisthead_.lh_first;
-	for (; lhp; lhp = lhp->nextlinkhead()) 
+	for (; lhp; lhp = lhp->nextlinkhead())
 		if (label == lhp->label())
 			return ((NsObject*) lhp);
 	return NULL;
diff -ur common/node.h ns-umts-extensions/code/node.h
--- common/node.h	2002-05-30 17:44:03.000000000 +0000
+++ ns-umts-extensions/code/node.h	2003-06-01 20:10:45.000000000 +0000
@@ -1,5 +1,36 @@
-/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- 
+/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
  *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
+/*
  * Copyright (c) 1997-2000 Regents of the University of California.
  * All rights reserved.
  *
@@ -59,6 +90,8 @@
 #include "energy-model.h"
 #include "location.h"
 #include "rtmodule.h"
+// P.M. & P.B. modifications
+#include "wired-flows.h"
 
 class NixNode;
 class LinkHead;
@@ -135,7 +168,7 @@
 	virtual int command(int argc, const char*const* argv);
 	virtual void namlog(const char *fmt, ...);
 
-	NsObject* intf_to_target(int32_t); 
+	NsObject* intf_to_target(int32_t);
 
 	static struct node_head nodehead_;  // static head of list of nodes
 	inline void insert(struct node_head* head) {
@@ -146,16 +179,16 @@
 	// The remaining objects handle a (static) linked list of nodes
 	// Used by Tom's satallite code and the wireless code
 	inline const struct if_head& ifhead() const { return ifhead_; }
-	inline const struct linklist_head& linklisthead() const { 
-		return linklisthead_; 
+	inline const struct linklist_head& linklisthead() const {
+		return linklisthead_;
 	}
-	
+
 	//neighbor list maintenance
 	neighbor_list_node* neighbor_list_;
 	void addNeighbor(Node *node);
-	
+
 	static Node* get_node_by_address(nsaddr_t);
-	
+
 	//routines for supporting routing
 	void route_notify (RoutingModule *rtm);
 	void unreg_route_notify(RoutingModule *rtm);
@@ -164,6 +197,11 @@
 	void set_table_size(int nn);
 	void set_table_size(int level, int csize);
 
+	// P.M. & P.B. modifications
+	static SLList *list;
+	inline int update() { return update_;}
+
+
 protected:
 	LIST_ENTRY(Node) entry;  // declare list entry structure
 	int address_;
@@ -171,9 +209,9 @@
 
 	// Nam tracing facility
         Tcl_Channel namChan_;
-	// Single thread ns, so we can use one global storage for all 
+	// Single thread ns, so we can use one global storage for all
 	// node objects
-	static char nwrk_[NODE_NAMLOG_BUFSZ];	
+	static char nwrk_[NODE_NAMLOG_BUFSZ];
 	void namdump();
 
 	struct if_head ifhead_; // list of phys for this node
@@ -187,16 +225,21 @@
 #endif /* STL */
 
 public:
-	// XXX Energy related stuff. Should be moved later to a wireless 
+	// XXX Energy related stuff. Should be moved later to a wireless
 	// routing plugin module instead of sitting here.
 	inline EnergyModel* energy_model() { return energy_model_; }
 	inline Location* location() { return location_; }
 protected:
 	EnergyModel* energy_model_;
-	// XXX Currently this is a placeholder only. It is supposed to 
-	// hold the position-related stuff in MobileNode. Yet another 
+	// XXX Currently this is a placeholder only. It is supposed to
+	// hold the position-related stuff in MobileNode. Yet another
 	// 'Under Construction' sign :(
 	Location* location_;
+
+	// P.M. & P.B. modifications
+	int update_;
+	double bw_atof(const char* s);
+
 };
 
 #endif /* __ns_node_h__ */
diff -ur common/packet.h ns-umts-extensions/code/packet.h
--- common/packet.h	2002-09-18 05:41:50.000000000 +0000
+++ ns-umts-extensions/code/packet.h	2003-06-01 20:10:45.000000000 +0000
@@ -1,4 +1,35 @@
 /* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
+ *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
 /*
  * Copyright (c) 1997 Regents of the University of California.
  * All rights reserved.
@@ -55,6 +86,9 @@
 #define HDR_MAC(p)      (hdr_mac::access(p))
 #define HDR_MAC802_11(p) ((hdr_mac802_11 *)hdr_mac::access(p))
 #define HDR_MAC_TDMA(p) ((hdr_mac_tdma *)hdr_mac::access(p))
+// P.M. & P.B. modifications
+#define HDR_PHY_UMTS(p) (hdr_phy::access(p))
+#define HDR_RLC_UMTS(p) (hdr_rlc_umts::access(p))
 #define HDR_SMAC(p)     ((hdr_smac *)hdr_mac::access(p))
 #define HDR_LL(p)       (hdr_ll::access(p))
 #define HDR_IP(p)       (hdr_ip::access(p))
@@ -91,14 +125,15 @@
 	PT_CtrMcast_Encap,
 	PT_CtrMcast_Decap,
 	PT_SRM,
+
 	/* simple signalling messages */
-	PT_REQUEST,	
-	PT_ACCEPT,	
-	PT_CONFIRM,	
-	PT_TEARDOWN,	
+
+	PT_REQUEST,
+	PT_ACCEPT,
+	PT_CONFIRM,
+	PT_TEARDOWN,
 	PT_LIVE,	// packet from live network
 	PT_REJECT,
-
 	PT_TELNET,	// not needed: telnet use TCP
 	PT_FTP,
 	PT_PARETO,
@@ -126,6 +161,7 @@
 	PT_TFRC_ACK,
 	PT_PING,
 
+
 	// Diffusion packets - Chalermek
 	PT_DIFF,
 
@@ -136,7 +172,7 @@
 	PT_LDP,
 
 	// GAF packet
-        PT_GAF,  
+ 	PT_GAF,
 
 	// ReadAudio traffic
 	PT_REALAUDIO,
@@ -144,6 +180,10 @@
 	// Pushback Messages
 	PT_PUSHBACK,
 
+	// P.M. & P.B. modifications
+	PT_PREAMBLE,	// RACH preamble to NodeB
+ 	PT_RRC_FAILURE,	// PHY->RRC if there is no AICH
+
 #ifdef HAVE_STL
 	// Pragmatic General Multicast
 	PT_PGM,
@@ -181,19 +221,19 @@
 		name_[PT_CtrMcast_Decap]= "CtrMcast_Decap";
 		name_[PT_SRM]= "SRM";
 
-		name_[PT_REQUEST]= "sa_req";	
+		name_[PT_REQUEST]= "sa_req";
 		name_[PT_ACCEPT]= "sa_accept";
 		name_[PT_CONFIRM]= "sa_conf";
 		name_[PT_TEARDOWN]= "sa_teardown";
-		name_[PT_LIVE]= "live"; 
+		name_[PT_LIVE]= "live";
 		name_[PT_REJECT]= "sa_reject";
-
 		name_[PT_TELNET]= "telnet";
 		name_[PT_FTP]= "ftp";
 		name_[PT_PARETO]= "pareto";
 		name_[PT_EXP]= "exp";
 		name_[PT_INVAL]= "httpInval";
 		name_[PT_HTTP]= "http";
+
 		name_[PT_ENCAPSULATED]= "encap";
 		name_[PT_MFTP]= "mftp";
 		name_[PT_ARP]= "ARP";
@@ -220,16 +260,20 @@
 		name_[PT_LDP] = "LDP";
 
 		// for GAF
-                name_[PT_GAF] = "gaf";      
+            name_[PT_GAF] = "gaf";
 
 		// RealAudio packets
 		name_[PT_REALAUDIO] = "ra";
 
-		//pushback 
+		//pushback
 		name_[PT_PUSHBACK] = "pushback";
 
+		// P.M. & P.B. modifications
+		name_[PT_PREAMBLE] = "preamble";
+		name_[PT_RRC_FAILURE] = "rrc_failure";
+
 #ifdef HAVE_STL
-		// for PGM
+		 // for PGM
 		name_[PT_PGM] = "PGM";
 #endif //STL
 
@@ -239,7 +283,7 @@
 
 		name_[PT_NTYPE]= "undefined";
 	}
-	const char* name(packet_t p) const { 
+	const char* name(packet_t p) const {
 		if ( p <= PT_NTYPE ) return name_[p];
 		return 0;
 	}
@@ -289,7 +333,7 @@
 	}
 	virtual ~PacketData() { 
 		if (data_ != NULL) 
-			delete []data_; 
+			delete []data_;
 	}
 	unsigned char* data() { return data_; }
 
@@ -361,7 +405,7 @@
 	// the pkt stamp carries all info about how/where the pkt
         // was sent needed for a receiver to determine if it correctly
         // receives the pkt
-        PacketStamp	txinfo_;  
+        PacketStamp	txinfo_;
 
 	/*
          * According to cmu code:
@@ -369,7 +413,7 @@
          * and is cleared by the link layer.  It is an ugly hack, but
          * there's really no other way because NS always calls
          * the recv() function of an object.
-	 * 
+	 *
          */
         u_int8_t        incoming;
 
@@ -386,7 +430,7 @@
 		UNKN_IFACE= -1, /* 
 				 * iface value for locally originated packets 
 				 */
-		ANY_IFACE= -2   /* 
+		ANY_IFACE= -2   /*
 				 * hashnode with iif == ANY_IFACE_   
 				 * matches any pkt iface (imported from TCL);
 				 * this value should be different from 
@@ -412,6 +456,9 @@
  * systems don't have NONE or ILINK).
  */
 enum ns_af_enum { NS_AF_NONE, NS_AF_ILINK, NS_AF_INET };
+ 
+// P.M. & P.B. modifications
+enum chan_t {AICH, SCH, PICH, PCCPCH, SCCPCH, DPDCH, DPCCH, PRACH, BCH, PCH, FACH, DCH, RACH, BCCH, PCCH, CCCH, DCCH, DTCH, TO_RRC, FROM_RRC};
 
 struct hdr_cmn {
 	enum dir_t { DOWN= -1, NONE= 0, UP= 1 };
@@ -424,9 +471,12 @@
 	double	ts_;		// timestamp: for q-delay measurement
 	int	iface_;		// receiving interface (label)
 	dir_t	direction_;	// direction: 0=none, 1=up, -1=down
-	// source routing 
+	// source routing
         char src_rt_valid;
 
+	// P.M. & P.B. modifications
+	chan_t channel_t_;	// channel type for UMTS
+
 	//Monarch extn begins
 	nsaddr_t prev_hop_;     // IP addr of forwarding hop
 	nsaddr_t next_hop_;	// next hop for this packet
@@ -435,7 +485,7 @@
 
         // called if pkt can't obtain media or isn't ack'd. not called if
         // droped by a queue
-        FailureCallback xmit_failure_; 
+        FailureCallback xmit_failure_;
         void *xmit_failure_data_;
 
         /*
@@ -461,7 +511,7 @@
 	inline static hdr_cmn* access(const Packet* p) {
 		return (hdr_cmn*) p->access(offset_);
 	}
-	
+
         /* per-field member functions */
 	inline packet_t& ptype() { return (ptype_); }
 	inline int& size() { return (size_); }
@@ -471,6 +521,10 @@
 	inline int& fecsize() {return fecsize_; }
 	inline double& timestamp() { return (ts_); }
 	inline int& iface() { return (iface_); }
+
+	// P.M. & P.B. modifications
+	inline chan_t& channel_t() { return (channel_t_); }
+	
 	inline dir_t& direction() { return (direction_); }
 	// monarch_begin
 	inline nsaddr_t& next_hop() { return (next_hop_); }
diff -ur mac/ll.cc ns-umts-extensions/code/ll.cc
--- mac/ll.cc	2002-03-14 01:12:52.000000000 +0000
+++ ns-umts-extensions/code/ll.cc	2003-06-01 20:10:45.000000000 +0000
@@ -12,7 +12,7 @@
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
+ *    must display the following acknowledgement: 
  *	This product includes software developed by the Daedalus Research
  *	Group at the University of California Berkeley.
  * 4. Neither the name of the University nor of the Laboratory may be used
@@ -32,18 +32,28 @@
  * SUCH DAMAGE.
  *
  * Contributed by the Daedalus Research Group, http://daedalus.cs.berkeley.edu
- */
+ */   
 
 #ifndef lint
 static const char rcsid[] =
     "@(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/mac/ll.cc,v 1.46 2002/03/14 01:12:52 haldar Exp $ (UCB)";
 #endif
 
-#include <errmodel.h>
-#include <mac.h>
-#include <ll.h>
+
+#include "packet.h"
+#include "delay.h"
+#include "mobilenode.h"
+#include "address.h"
+
+#include "arp.h"
+#include "queue.h"
+#include "cmu-trace.h"
+
+//#include <errmodel.h>
+#include "mac.h"
+#include "ll.h"
 #include <address.h>
-#include <dsr/hdr_sr.h>
+
 
 int hdr_ll::offset_;
 
@@ -107,7 +117,7 @@
 			lanrouter_ = (LanRouter*) TclObject::lookup(argv[2]);
 			return (TCL_OK);
 		}
-
+ 
 	}
 	else if (argc == 2) {
 		if (strcmp(argv[1], "ifq") == 0) {
@@ -165,7 +175,7 @@
 
 
 void LL::sendDown(Packet* p)
-{	
+{
 	hdr_cmn *ch = HDR_CMN(p);
 	hdr_ip *ih = HDR_IP(p);
 
@@ -173,14 +183,14 @@
 	//nsaddr_t dst = ih->dst();
 	hdr_ll *llh = HDR_LL(p);
 	char *mh = (char*)p->access(hdr_mac::offset_);
-	
+
 	llh->seqno_ = ++seqno_;
 	llh->lltype() = LL_DATA;
 
 	mac_->hdr_src(mh, mac_->addr());
 	mac_->hdr_type(mh, ETHERTYPE_IP);
 	int tx = 0;
-	
+
 	switch(ch->addr_type()) {
 
 	case NS_AF_ILINK:
@@ -190,9 +200,9 @@
 	case NS_AF_INET:
 		dst = ch->next_hop();
 		/* FALL THROUGH */
-		
+
 	case NS_AF_NONE:
-		
+
 		if (IP_BROADCAST == (u_int32_t) dst)
 		{
 			mac_->hdr_dst((char*) HDR_MAC(p), MAC_BROADCAST);
@@ -206,12 +216,12 @@
 		//if (varp_) {
 		//tx = varp_->arpresolve(dst, p);
 		//break;
-			
-		//}			
+
+		//}
 		/* FALL THROUGH */
 
-	default:
-		
+	default:    
+
 		int IPnh = (lanrouter_) ? lanrouter_->next_hop(p) : -1;
 		if (IPnh < 0)
 			mac_->hdr_dst((char*) HDR_MAC(p),macDA_);
@@ -221,7 +231,7 @@
 			mac_->hdr_dst((char*) HDR_MAC(p), IPnh);
 		break;
 	}
-	
+
 	if (tx == 0) {
 		Scheduler& s = Scheduler::instance();
 	// let mac decide when to take a new packet from the queue.
diff -ur mac/ll.h ns-umts-extensions/code/ll.h
--- mac/ll.h	2000-09-01 03:04:06.000000000 +0000
+++ ns-umts-extensions/code/ll.h	2003-06-01 20:10:45.000000000 +0000
@@ -1,4 +1,35 @@
 /* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
+ *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
 /*
  * Copyright (c) 1997 Regents of the University of California.
  * All rights reserved.
@@ -39,26 +70,44 @@
 #ifndef ns_ll_h
 #define ns_ll_h
 
-#include <delay.h>
-#include <queue.h>
+#include "marshall.h"
+#include <connector.h>
+#include <random.h>
+#include <mac.h>
+
+#include "packet.h"
+#include "delay.h"
+#include "queue.h"
 #include <arp.h>
 #include <classifier.h>
 #include <lanRouter.h>
 #include <varp.h>
 
+
 enum LLFrameType {
 	LL_DATA		= 0x0001,
-	LL_ACK		= 0x0010
+	LL_ACK		= 0x0010,
+	LL_SETUP		= 0x0011,
+	LL_SETUP_REPLY	= 0x0100,
+	LL_FAILURE		= 0X0101,
+	LL_PAGING		= 0x0110,
+	LL_RES_REQ		= 0x0111,
+	LL_RES_REPLY	= 0x1000,
+	LL_HANDOVER		= 0x1001,
+	LL_RELEASE_REQ	= 0x1010,
+	LL_RELEASE_REPLY	= 0x1011
 };
 
 struct hdr_ll {
-	LLFrameType lltype_;		// link-layer frame type
+	LLFrameType lltype_;	// link-layer frame type
 	int seqno_;			// sequence number
 	int ackno_;			// acknowledgement number
 	int bopno_;			// begin of packet seqno
 	int eopno_;			// end of packet seqno
 	int psize_;			// size of packet
 	double sendtime_;		// time the packet is sent
+	int paging_ok_;		// for paging procedure
+	double tx_rate_;		// transmission rate of the data flow
 
 	static int offset_;
 	inline int& offset() { return offset_; }
@@ -73,6 +122,7 @@
 	inline int& eopno() { return eopno_; }
 	inline int& psize() { return psize_; }
 	inline double& sendtime() { return sendtime_; }
+	inline double& tx_rate() { return tx_rate_; }
 };
 
 
@@ -89,7 +139,13 @@
 
 	virtual void sendUp(Packet* p);
 	virtual void sendDown(Packet* p);
-	
+
+	// P.M. & P.B. modifications
+	virtual void switch_on(void) {}
+	virtual void update_flow(int acked, int fraged, int flowid) {}
+	virtual void configure_flow(int flow, const char*const& type , double rate) {}
+
+
 	inline int seqno() { return seqno_; }
 	inline int ackno() { return ackno_; }
 	inline int macDA() { return macDA_; }
@@ -97,24 +153,23 @@
         inline NsObject* downtarget() { return downtarget_; }
         inline NsObject* uptarget() { return uptarget_; }
  	inline ARPTable *arp_table() { return arptable_; }
-	
+
 protected:
 	int command(int argc, const char*const* argv);
-	
+
 	int seqno_;			// link-layer sequence number
 	int ackno_;			// ACK received so far
 	int macDA_;			// destination MAC address
-	
-        Queue* ifq_;			// interface queue
+
+	  Queue* ifq_;			// interface queue
 	Mac*   mac_;		        // MAC object
         LanRouter* lanrouter_;          // for lookups of the next hop
 	ARPTable*  arptable_;           // ARP table object
 	VARPTable* varp_;               // Virtual ARP object
-	
-	NsObject* downtarget_;		// for outgoing packet 
+
+	NsObject* downtarget_;		// for outgoing packet
 	NsObject* uptarget_;		// for incoming packet
-        
-	
+
 };
 
 #endif
diff -ur mac/mac.cc ns-umts-extensions/code/mac.cc
--- mac/mac.cc	2001-06-05 23:49:43.000000000 +0000
+++ ns-umts-extensions/code/mac.cc	2003-06-01 20:10:45.000000000 +0000
@@ -1,4 +1,35 @@
 /* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
+ *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
 /*
  * Copyright (c) 1997 Regents of the University of California.
  * All rights reserved.
@@ -92,13 +123,16 @@
 	bind_bw("bandwidth_", &bandwidth_);
 	bind_time("delay_", &delay_);
 	bind_bool("abstract_", &abstract_);
+	
+	// P.M. & P.B. modifications
+	tti_=0.01;
 }
 
 int Mac::command(int argc, const char*const* argv)
 {
 	if(argc == 2) {
 		Tcl& tcl = Tcl::instance();
-		
+
 		if(strcmp(argv[1], "id") == 0) {
 			tcl.resultf("%d", addr());
 			return TCL_OK;
@@ -106,7 +140,7 @@
 			tcl.resultf("%s", channel_->name());
 			return (TCL_OK);
 		}
-		
+
 	} else if (argc == 3) {
 		TclObject *obj;
 		if( (obj = TclObject::lookup(argv[2])) == 0) {
diff -ur mac/mac.h ns-umts-extensions/code/mac.h
--- mac/mac.h	2000-12-20 10:11:36.000000000 +0000
+++ ns-umts-extensions/code/mac.h	2003-06-01 20:10:45.000000000 +0000
@@ -1,4 +1,35 @@
 /* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
+ *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
 /*
  * Copyright (c) 1997 Regents of the University of California.
  * All rights reserved.
@@ -146,7 +177,8 @@
 	// it must not alter or free the pkt.  If you want to frob it, copy it.
 };
 
-
+class Mac;
+class LL;
 class MacHandlerResume : public Handler {
 public:
 	MacHandlerResume(Mac* m) : mac_(m) {}
@@ -177,7 +209,7 @@
 
 	virtual void resume(Packet* p = 0);
 	virtual void installTap(Tap *t) { tap_ = t; }
-	
+
 	inline double txtime(int bytes) {
 		return (8. * bytes / bandwidth_);
 	}
@@ -186,11 +218,17 @@
 			     (HDR_CMN(p))->size()) / bandwidth_;
 	}
 	inline double bandwidth() const { return bandwidth_; }
-	
+
 	inline int addr() { return index_; }
 	inline MacState state() { return state_; }
 	inline MacState state(int m) { return state_ = (MacState) m; }
-	
+
+	// P.M. & P.B. modifications
+      inline double& tti() { return tti_;}
+	virtual void dl_interference(unsigned long error) {printf("error, dl\n");}
+	virtual void ul_interference(int addr[], unsigned long error[]) {printf("error, ul\n");}
+	virtual void remove(int addr) {printf("error, remove\n");}
+
         //mac methods to set dst, src and hdt_type in pkt hdrs.
 	// note: -1 is the broadcast mac addr.
 	virtual inline int hdr_dst(char* hdr, int dst = -2) {
@@ -220,16 +258,16 @@
 
 protected:
 	int command(int argc, const char*const* argv);
-	virtual int initialized() { 
-		return (netif_ && uptarget_ && downtarget_); 
+	virtual int initialized() {
+		return (netif_ && uptarget_ && downtarget_);
 	}
-	int index_;		// MAC address
+	int index_;			// MAC address
 	double bandwidth_;      // channel bitrate
 	double delay_;		// MAC overhead
-	int abstract_;         //   MAC support for abstract LAN 
-        
+	int abstract_;         	// MAC support for abstract LAN
+
 	Phy *netif_;            // network interface
-        Tap *tap_;              // tap agent
+        Tap *tap_;            // tap agent
 	LL *ll_;             	// LL this MAC is connected to
 	Channel *channel_;	// channel this MAC is connected to
 
@@ -238,6 +276,9 @@
 	MacHandlerSend hSend_;	// handle delay send due to busy channel
 	Event intr_;
 
+	// P.M. & P.B. modifications
+	double tti_;
+
 	/*
 	 * Internal MAC State
 	 */
diff -ur mac/phy.cc ns-umts-extensions/code/phy.cc
--- mac/phy.cc	1999-10-14 22:19:28.000000000 +0000
+++ ns-umts-extensions/code/phy.cc	2003-06-01 20:10:45.000000000 +0000
@@ -1,4 +1,35 @@
 /* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
+ *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
 /*
  * Copyright (c) 1997 Regents of the University of California.
  * All rights reserved.
@@ -105,9 +136,9 @@
 void
 Phy::recv(Packet* p, Handler*)
 {
-	struct hdr_cmn *hdr = HDR_CMN(p);	
+	struct hdr_cmn *hdr = HDR_CMN(p);
 	//struct hdr_sr *hsr = HDR_SR(p);
-	
+
 	/*
 	 * Handle outgoing packets
 	 */
@@ -128,6 +159,13 @@
 			 * contributes to the Noise floor and hence
 			 * may affect the reception of other packets.
 			 */
+
+			/// P.M. & P.B. modifications
+			// we do not discard packets, only mark them
+			hdr->error() = 1;
+			uptarget_->recv(p, (Handler*) 0);
+			return;
+
 			Packet::free(p);
 			return;
 		} else {
diff -ur mac/wireless-phy.cc ns-umts-extensions/code/wireless-phy.cc
--- mac/wireless-phy.cc	2002-05-30 00:10:15.000000000 +0000
+++ ns-umts-extensions/code/wireless-phy.cc	2003-06-01 20:10:45.000000000 +0000
@@ -1,5 +1,36 @@
-/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- 
+/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-*/
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
  *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
+ *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
+/*
  * Copyright (c) 1996 Regents of the University of California.
  * All rights reserved.
  *
@@ -53,6 +84,9 @@
 #include <agent.h>
 #include <trace.h>
 
+// P.M. & P.B. modifications
+#include "phy-umts.h"
+
 #include "diffusion/diff_header.h"
 
 #define max(a,b) (((a)<(b))?(b):(a))
@@ -98,7 +132,7 @@
 	bind("Pt_", &Pt_);
 	bind("freq_", &freq_);
 	bind("L_", &L_);
-	
+
 	lambda_ = SPEED_OF_LIGHT / freq_;
 
 	node_ = 0;
@@ -122,25 +156,25 @@
 	channel_idle_time_ = NOW;
 	update_energy_time_ = NOW;
 	last_send_time_ = NOW;
-	
+
 	idle_timer_.resched(1.0);
 }
 
 int
 WirelessPhy::command(int argc, const char*const* argv)
 {
-	TclObject *obj; 
+	TclObject *obj;
 
 	if (argc==2) {
 		if (strcasecmp(argv[1], "NodeOn") == 0) {
-			if (em() == NULL) 
+			if (em() == NULL)
 				return TCL_OK;
 			if (NOW > update_energy_time_) {
 				update_energy_time_ = NOW;
 			}
 			return TCL_OK;
 		} else if (strcasecmp(argv[1], "NodeOff") == 0) {
-			if (em() == NULL) 
+			if (em() == NULL)
 				return TCL_OK;
 			if (NOW > update_energy_time_) {
 				em()->DecrIdleEnergy(NOW-update_energy_time_,
@@ -160,7 +194,7 @@
 			P_idle_ = atof(argv[2]);
 			return TCL_OK;
 		} else if( (obj = TclObject::lookup(argv[2])) == 0) {
-			fprintf(stderr,"WirelessPhy: %s lookup of %s failed\n", 
+			fprintf(stderr,"WirelessPhy: %s lookup of %s failed\n",
 				argv[1], argv[2]);
 			return TCL_ERROR;
 		} else if (strcmp(argv[1], "propagation") == 0) {
@@ -178,16 +212,16 @@
 	}
 	return Phy::command(argc,argv);
 }
- 
-void 
+
+void
 WirelessPhy::sendDown(Packet *p)
 {
 	/*
 	 * Sanity Check
 	 */
 	assert(initialized());
-	
-	if (em()) 
+
+	if (em())
 		if ((em()->node_on() != true) || (em()->sleep())) {
 			Packet::free(p);
 			return;
@@ -205,14 +239,14 @@
 		    double actual_txtime = end_time-start_time;
 
 		    if (start_time > update_energy_time_) {
-			    em()->DecrIdleEnergy(start_time - 
+			    em()->DecrIdleEnergy(start_time -
 						 update_energy_time_, P_idle_);
 			    update_energy_time_ = start_time;
 		    }
 
 		    /* It turns out that MAC sends packet even though, it's
 		       receiving some packets.
-		    
+
 		    if (txtime-actual_txtime > 0.000001) {
 			    fprintf(stderr,"Something may be wrong at MAC\n");
 			    fprintf(stderr,"act_tx = %lf, tx = %lf\n", actual_txtime, txtime);
@@ -227,7 +261,7 @@
 			   fprintf(stderr,"Argggg !! Overlapping transmission. NOW %lf last %lf temp %lf\n", NOW, last_send_time_, temp);
 		   }
 		   */
-		   
+
 		   double begin_adjust_time = min(channel_idle_time_, temp);
 		   double finish_adjust_time = min(channel_idle_time_, NOW+txtime);
 		   double gap_adjust_time = finish_adjust_time - begin_adjust_time;
@@ -244,7 +278,7 @@
 		   if (end_time > channel_idle_time_) {
 			   status_ = SEND;
 		   }
-							
+
 		   last_send_time_ = NOW+txtime;
 		   channel_idle_time_ = end_time;
 		   update_energy_time_ = end_time;
@@ -269,7 +303,7 @@
 	channel_->recv(p, this);
 }
 
-int 
+int
 WirelessPhy::sendUp(Packet *p)
 {
 	/*
@@ -280,14 +314,14 @@
 	PacketStamp s;
 	double Pr;
 	int pkt_recvd = 0;
-	
+
 	// if the node is in sleeping mode, drop the packet simply
-	if (em()) 
+	if (em())
 		if (em()->sleep() || (em()->node_on() != true)) {
 			pkt_recvd = 0;
 			goto DONE;
 		}
-	
+
 	// if the energy goes to ZERO, drop the packet simply
 	if (em()) {
 		if (em()->energy() <= 0) {
@@ -299,6 +333,11 @@
 	if(propagation_) {
 		s.stamp((MobileNode*)node(), ant_, 0, lambda_);
 		Pr = propagation_->Pr(&p->txinfo_, &s, this);
+
+		// P.M. & P.B. modifications
+		hdr_phy *ph = HDR_PHY_UMTS(p);
+		ph->rx_power() = Pr;
+		
 		if (Pr < CSThresh_) {
 			pkt_recvd = 0;
 			goto DONE;
@@ -322,7 +361,7 @@
 		hdr_cmn *hdr = HDR_CMN(p);
 		hdr->error() = modulation_->BitError(Pr);
 	}
-	
+
 	/*
 	 * The MAC layer must be notified of the packet reception
 	 * now - ie; when the first bit has been detected - so that
@@ -336,7 +375,7 @@
 	/* WILD HACK: The following two variables are a wild hack.
 	   They will go away in the next release...
 	   They're used by the mac-802_11 object to determine
-	   capture.  This will be moved into the net-if family of 
+	   capture.  This will be moved into the net-if family of
 	   objects in the future. */
 	p->txinfo_.RxPr = Pr;
 	p->txinfo_.CPThresh = CPThresh_;
@@ -348,9 +387,9 @@
 		//double rcvtime = (8. * hdr_cmn::access(p)->size())/bandwidth_;
 		double rcvtime = hdr_cmn::access(p)->txtime();
 		// no way to reach here if the energy level < 0
-		
+
 		/*
-		  node()->add_rcvtime(rcvtime);	  
+		  node()->add_rcvtime(rcvtime);
 		  em()->DecrRcvEnergy(rcvtime,Pr_consume_);
 		*/
 
@@ -363,7 +402,7 @@
 					     P_idle_);
 			update_energy_time_ = start_time;
 		}
-		
+
 		em()->DecrRcvEnergy(actual_rcvtime,Pr_consume_);
 		if (end_time > channel_idle_time_) {
 			status_ = RECV;
@@ -375,17 +414,17 @@
 		/*
 		  hdr_diff *dfh = HDR_DIFF(p);
 		  printf("Node %d receives (%d, %d, %d) energy %lf.\n",
-		  node()->address(), dfh->sender_id.addr_, 
+		  node()->address(), dfh->sender_id.addr_,
 		  dfh->sender_id.port_, dfh->pk_num, node()->energy());
 		*/
-		
-		if (em()->energy() <= 0) {  
+
+		if (em()->energy() <= 0) {
 			// saying node died
 			em()->setenergy(0);
 			((MobileNode*)node())->log_energy(0);
 		}
 	}
-	
+
 	return pkt_recvd;
 }
 
@@ -393,13 +432,13 @@
 WirelessPhy::node_on()
 {
         if (em() == NULL)
- 	    return;	
+ 	    return;
    	if (NOW > update_energy_time_) {
       	    update_energy_time_ = NOW;
    	}
 }
 
-void 
+void
 WirelessPhy::node_off()
 {
 	if (em() == NULL)
diff -ur Makefile.in ns-umts-extensions/code/Makefile.in
--- Makefile.in	2002-10-09 23:57:15.000000000 +0000
+++ ns-umts-extensions/code/Makefile.in	2003-06-01 20:10:45.000000000 +0000
@@ -67,7 +67,8 @@
 	-I./routing -I./tools -I./classifier -I./mcast \
 	-I./diffusion3/lib/main -I./diffusion3/lib \
 	-I./diffusion3/lib/nr -I./diffusion3/ns \
-	-I./diffusion3/diffusion -I./asim/
+	-I./diffusion3/diffusion -I./asim/ \
+	-I./umts
 
 
 LIB	= \
@@ -101,7 +102,7 @@
 
 # To allow conf/makefile.win overwrite this macro
 # We will set these two macros to empty in conf/makefile.win since VC6.0
-# does not seem to support the STL in gcc 2.8 and up. 
+# does not seem to support the STL in gcc 2.8 and up.
 OBJ_STL = diffusion3/lib/nr/nr.o diffusion3/lib/dr.o \
 	diffusion3/ns/diffagent.o diffusion3/ns/diffrtg.o \
 	diffusion3/ns/difftimer.o \
@@ -213,6 +214,14 @@
 	queue/priqueue.o queue/dsr-priqueue.o \
 	mac/phy.o mac/wired-phy.o mac/wireless-phy.o \
 	mac/mac-timers.o trace/cmu-trace.o mac/varp.o \
+	umts/phy-timers.o umts/phy-umts.o umts/phy-umts-nodeb.o \
+	umts/mac-umts.o umts/mac-umts-nodeb.o \
+	umts/rlc-umts-nodeb.o umts/rlc-umts.o \
+	umts/wired-flows.o umts/ll-flows.o \
+	umts/ll-ue.o umts/ll-nodeb.o \
+	umts/fc-queue.o umts/bsfc-queue.o noah/noah.o \
+	umts/linked-list.o umts/tree.o \
+	classifier/classifier-umts.o \
 	dsdv/dsdv.o dsdv/rtable.o queue/rtqueue.o \
 	routing/rttable.o \
 	imep/imep.o imep/dest_queue.o imep/imep_api.o \
@@ -361,6 +370,8 @@
 	tcl/lib/ns-lib.tcl \
 	tcl/lib/ns-link.tcl \
 	tcl/lib/ns-mobilenode.tcl \
+	tcl/lib/ns-uenode.tcl \
+	tcl/lib/ns-nodeb.tcl \
 	tcl/lib/ns-sat.tcl \
 	tcl/lib/ns-cmutrace.tcl \
 	tcl/lib/ns-node.tcl \
@@ -398,9 +409,10 @@
 	tcl/mcast/mftp_rcv_stat.tcl \
 	tcl/mobility/dsdv.tcl \
 	tcl/mobility/dsr.tcl \
-        tcl/ctr-mcast/CtrMcast.tcl \
-        tcl/ctr-mcast/CtrMcastComp.tcl \
-        tcl/ctr-mcast/CtrRPComp.tcl \
+	tcl/mobility/noah.tcl \
+ 	tcl/ctr-mcast/CtrMcast.tcl \
+      tcl/ctr-mcast/CtrMcastComp.tcl \
+      tcl/ctr-mcast/CtrRPComp.tcl \
 	tcl/rlm/rlm.tcl \
 	tcl/rlm/rlm-ns.tcl \
 	tcl/session/session.tcl \
@@ -470,12 +482,12 @@
 
 tags:	force
 	ctags -wtd *.cc *.h webcache/*.cc webcache/*.h dsdv/*.cc dsdv/*.h \
-	dsr/*.cc dsr/*.h webcache/*.cc webcache/*.h lib/*.cc lib/*.h \
-	../Tcl/*.cc ../Tcl/*.h 
+	dsr/*.cc dsr/*.h noah/*.cc noah/*.h webcache/*.cc webcache/*.h lib/*.cc lib/*.h \
+	../Tcl/*.cc ../Tcl/*.h
 
 TAGS:	force
 	etags *.cc *.h webcache/*.cc webcache/*.h dsdv/*.cc dsdv/*.h \
-	dsr/*.cc dsr/*.h webcache/*.cc webcache/*.h lib/*.cc lib/*.h \
+	dsr/*.cc dsr/*.h noah/*.cc noah/*.h webcache/*.cc webcache/*.h lib/*.cc lib/*.h \
 	../Tcl/*.cc ../Tcl/*.h
 
 tcl/lib/TAGS:	force
diff -ur mobile/tworayground.cc ns-umts-extensions/code/tworayground.cc
--- mobile/tworayground.cc	2000-10-02 20:23:16.000000000 +0000
+++ ns-umts-extensions/code/tworayground.cc	2003-06-01 20:10:45.000000000 +0000
@@ -99,25 +99,27 @@
   tX += t->getAntenna()->getX();
   tY += t->getAntenna()->getY();
 
-  d = sqrt((rX - tX) * (rX - tX) 
-	   + (rY - tY) * (rY - tY) 
+  d = sqrt((rX - tX) * (rX - tX)
+	   + (rY - tY) * (rY - tY)
 	   + (rZ - tZ) * (rZ - tZ));
-    
+
+
   /* We're going to assume the ground is essentially flat.
-     This empirical two ground ray reflection model doesn't make 
+     This empirical two ground ray reflection model doesn't make
      any sense if the ground is not a plane. */
 
-  if (rZ != tZ) {
-    printf("%s: TwoRayGround propagation model assume flat ground\n",
-	   __FILE__);
-  }
+  // P.M. & P.B. modifications, ???????????????????????????????
+//  if (rZ != tZ) {
+//    printf("%s: TwoRayGround propagation model assume flat ground\n",
+//	   __FILE__);
+//  }
 
   hr = rZ + r->getAntenna()->getZ();
   ht = tZ + t->getAntenna()->getZ();
 
   if (hr != last_hr || ht != last_ht)
     { // recalc the cross-over distance
-      /* 
+      /*
 	         4 * PI * hr * ht
 	 d = ----------------------------
 	             lambda
@@ -139,14 +141,14 @@
    *  ground reflection model.
    */
 
-  double Gt = t->getAntenna()->getTxGain(rX - tX, rY - tY, rZ - tZ, 
+  double Gt = t->getAntenna()->getTxGain(rX - tX, rY - tY, rZ - tZ,
 					 t->getLambda());
   double Gr = r->getAntenna()->getRxGain(tX - rX, tY - rY, tZ - rZ,
 					 r->getLambda());
 
 #if DEBUG > 3
   printf("TRG %.9f %d(%d,%d)@%d(%d,%d) d=%f xo=%f :",
-	 Scheduler::instance().clock(), 
+	 Scheduler::instance().clock(),
 	 t->getNode()->index(), (int)tX, (int)tY,
 	 r->getNode()->index(), (int)rX, (int)rY,
 	 d, crossover_dist);
@@ -165,7 +167,7 @@
     Pr = TwoRay(t->getTxPr(), Gt, Gr, ht, hr, L, d);
 #if DEBUG > 3
     printf("TwoRay %e\n",Pr);
-#endif    
+#endif
     return Pr;
   }
 }
diff -ur queue/queue.h ns-umts-extensions/code/queue.h
--- queue/queue.h	2002-05-07 18:28:28.000000000 +0000
+++ ns-umts-extensions/code/queue.h	2003-06-01 20:10:45.000000000 +0000
@@ -1,8 +1,39 @@
 /* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
+ *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
 /*
  * Copyright (c) 1996-1997 The Regents of the University of California.
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -18,7 +49,7 @@
  * 4. Neither the name of the University nor of the Laboratory may be used
  *    to endorse or promote products derived from this software without
  *    specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -46,7 +77,7 @@
 public:
 	PacketQueue() : head_(0), tail_(0), len_(0), bytes_(0) {}
 	virtual int length() const { return (len_); }
-	virtual int byteLength() const { return (bytes_); }
+	virtual double byteLength() const { return (bytes_); } // P.M. & P.B. modifications
 	virtual Packet* enque(Packet* p) { // Returns previous tail
 		Packet* pt = tail_;
 		if (!tail_) head_= tail_= p;
@@ -90,18 +121,19 @@
 		bytes_ += hdr_cmn::access(p)->size();
 	}
         void resetIterator() {iter = head_;}
-        Packet* getNext() { 
+        Packet* getNext() {
 	        if (!iter) return 0;
 		Packet *tmp = iter; iter = iter->next_;
 		return tmp;
 	}
 
+
 protected:
 	Packet* head_;
 	Packet* tail_;
 	int len_;		// packet count
-	int bytes_;		// queue size in bytes
-
+	double bytes_;		// queue size in bytes
+					// P.M. & P.B. modifications
 
 // MONARCH EXTNS
 private:
@@ -125,16 +157,18 @@
 	virtual void enque(Packet*) = 0;
 	virtual Packet* deque() = 0;
 	virtual void recv(Packet*, Handler*);
-	virtual void updateStats(int queuesize); 
+	virtual void updateStats(int queuesize);
 	void resume();
 	int blocked() const { return (blocked_ == 1); }
 	void unblock() { blocked_ = 0; }
 	void block() { blocked_ = 1; }
 	int limit() { return qlim_; }
-	int length() { return pq_->length(); }	/* number of pkts currently in
+	double length() { return pq_->length(); }	/* number of pkts currently in
 						 * underlying packet queue */
-	int byteLength() { return pq_->byteLength(); }	/* number of bytes *
+						 // P.M. & P.B. modifications
+	double byteLength() { return pq_->byteLength(); }	/* number of bytes *
 						 * currently in packet queue */
+						 // P.M. & P.B. modifications
 protected:
 	Queue();
 	void reset();
@@ -142,11 +176,12 @@
 	int blocked_;		/* blocked now? */
 	int unblock_on_resume_;	/* unblock q on idle? */
 	QueueHandler qh_;
-	PacketQueue *pq_;	/* pointer to actual packet queue 
+	PacketQueue *pq_;	/* pointer to actual packet queue
 				 * (maintained by the individual disciplines
 				 * like DropTail and RED). */
 	double true_ave_;	/* true long-term average queue size */
 	double total_time_;	/* total time average queue size compute for */
+
 };
 
 #endif
diff -ur routing/rtmodule.cc ns-umts-extensions/code/rtmodule.cc
--- routing/rtmodule.cc	2002-09-18 05:41:52.000000000 +0000
+++ ns-umts-extensions/code/rtmodule.cc	2003-06-01 20:10:45.000000000 +0000
@@ -1,5 +1,36 @@
-/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- 
+/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-*/
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
  *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
+ *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
+/*
  * Copyright (C) 2000 by USC/ISI
  * All rights reserved.                                            
  *                                                                
@@ -56,6 +87,15 @@
 	}
 } class_hier_routing_module;
 
+// P.M. & P.B. modifications
+static class UmtsRoutingModuleClass : public TclClass {
+public:
+	UmtsRoutingModuleClass() : TclClass("RtModule/Umts") {}
+	TclObject* create(int, const char*const*) {
+		return (new UmtsRoutingModule);
+	}
+} class_umts_routing_module;
+
 
 static class ManualRoutingModuleClass : public TclClass {
 public:
@@ -101,7 +141,7 @@
         }
 } class_lms_routing_module;
 
-RoutingModule::RoutingModule() : 
+RoutingModule::RoutingModule() :
 	next_rtm_(NULL), n_(NULL), classifier_(NULL) {
 	bind("classifier_", (TclObject**)&classifier_);
 }
@@ -117,11 +157,11 @@
 		} else if (strcmp(argv[1], "module-name") == 0) {
 			if (module_name() != NULL)
 				tcl.resultf("%s", module_name());
-			else 
+			else
 				tcl.result("");
 			return TCL_OK;
 		}
-		
+
 	} else if (argc == 3) {
 		if (strcmp(argv[1], "attach-node") == 0) {
 			n_ = (Node*)TclObject::lookup(argv[2]);
@@ -176,6 +216,7 @@
 	return (RoutingModule::command(argc, argv));
 }
 
+
 int SourceRoutingModule::command(int argc, const char*const* argv) {
 	Tcl& tcl = Tcl::instance();
 	if (argc == 3) {
@@ -283,6 +324,40 @@
 	return (RoutingModule::command(argc, argv));
 }
 
+// P.M. & P.B. modifications
+int UmtsRoutingModule::command(int argc, const char*const* argv) {
+	Tcl& tcl = Tcl::instance();
+	if (argc == 3) {
+		if (strcmp(argv[1] , "route-notify") == 0) {
+			Node *node = (Node *)(TclObject::lookup(argv[2]));
+			if (node == NULL) {
+				tcl.add_errorf("Invalid node object %s", argv[2]);
+				return TCL_ERROR;
+			}
+			if (node != n_) {
+				tcl.add_errorf("Node object %s different from n_", argv[2]);
+				return TCL_ERROR;
+			}
+			n_->route_notify(this);
+			return TCL_OK;
+		}
+		if (strcmp(argv[1] , "unreg-route-notify") == 0) {
+			Node *node = (Node *)(TclObject::lookup(argv[2]));
+			if (node == NULL) {
+				tcl.add_errorf("Invalid node object %s", argv[2]);
+				return TCL_ERROR;
+			}
+			if (node != n_) {
+				tcl.add_errorf("Node object %s different from n_", argv[2]);
+				return TCL_ERROR;
+			}
+			n_->unreg_route_notify(this);
+			return TCL_OK;
+		}
+	}
+	return (RoutingModule::command(argc, argv));
+}
+
 
 int ManualRoutingModule::command(int argc, const char*const* argv) {
 	Tcl& tcl = Tcl::instance();
@@ -371,7 +446,7 @@
 			next_rtm_->unreg_route_notify(rtm);
 		}
 	}
-}
+} 
 
 void RoutingModule::add_route(char *dst, NsObject *target) 
 {
@@ -384,9 +459,9 @@
 void RoutingModule::delete_route(char *dst, NsObject *nullagent)
 {
 	if (classifier_) 
-		classifier_->do_install(dst, nullagent); 
+		classifier_->do_install(dst, nullagent);
 	if (next_rtm_)
-		next_rtm_->add_route(dst, nullagent); 
+		next_rtm_->add_route(dst, nullagent);
 }
 
 void RoutingModule::set_table_size(int nn)
diff -ur routing/rtmodule.h ns-umts-extensions/code/rtmodule.h
--- routing/rtmodule.h	2002-09-18 05:41:52.000000000 +0000
+++ ns-umts-extensions/code/rtmodule.h	2003-06-01 20:10:45.000000000 +0000
@@ -1,8 +1,39 @@
-/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- 
+/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
  *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
+/*
  * Copyright (C) 2000 by USC/ISI
- * All rights reserved.                                            
- *                                                                
+ * All rights reserved.
+ *
  * Redistribution and use in source and binary forms are permitted
  * provided that the above copyright notice and this paragraph are
  * duplicated in all such forms and that any documentation, advertising
@@ -11,15 +42,15 @@
  * Southern California, Information Sciences Institute.  The name of the
  * University may not be used to endorse or promote products derived from
  * this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * $Header: /nfs/jade/vint/CVSROOT/ns-2/routing/rtmodule.h,v 1.13 2002/09/18 05:41:52 sundarra Exp $
  *
- * Definition of RoutingModule, base class for all extensions to routing 
- * functionality in a Node. These modules are meant to be "plugin", and 
+ * Definition of RoutingModule, base class for all extensions to routing
+ * functionality in a Node. These modules are meant to be "plugin", and
  * should be configured via node-config{} interface in tcl/lib/ns-lib.tcl.
  */
 
@@ -32,7 +63,8 @@
 #include "classifier-hash.h"
 #include "classifier-hier.h"
 
-
+// P.M. & P.B. modifications
+#include "classifier-umts.h"
 
 class NsObject;
 class Node;
@@ -42,16 +74,16 @@
 
 class RoutingModule : public TclObject {
 public:
-	RoutingModule(); 
+	RoutingModule();
 	/*
 	 * Returns the node to which this module is attached.
-	 */ 
+	 */
 	inline Node* node() { return n_; }
 	/*
 	 * Node-related module-specific initialization can be done here.
 	 * However: (1) RoutingModule::attach() must be called from derived
-	 * class so the value of n_ is setup, (2) module-specific 
-	 * initialization that does not require knowledge of Node should 
+	 * class so the value of n_ is setup, (2) module-specific
+	 * initialization that does not require knowledge of Node should
 	 * always stay in the module constructor.
 	 *
 	 * Return TCL_ERROR if initialization fails.
@@ -63,12 +95,12 @@
 	/* support for populating rtg table */
 	void route_notify(RoutingModule *rtm);
 	void unreg_route_notify(RoutingModule *rtm);
-	virtual void add_route(char *dst, NsObject *target); 
+	virtual void add_route(char *dst, NsObject *target);
 	virtual void delete_route(char *dst, NsObject *nullagent);
 	void set_table_size(int nn);
 	void set_table_size(int level, int csize);
 	RoutingModule *next_rtm_;
-	
+
 protected:
 	Node *n_;
 	Classifier *classifier_;
@@ -89,7 +121,7 @@
 	virtual const char* module_name() const { return "Mcast"; }
 	virtual int command(int argc, const char*const* argv);
 protected:
-	DestHashClassifier *classifier_;	
+	DestHashClassifier *classifier_;
 };
 
 class HierRoutingModule : public RoutingModule {
@@ -101,6 +133,16 @@
 	HierClassifier *classifier_;
 };
 
+// P.M. & P.B. modifications
+class UmtsRoutingModule : public RoutingModule {
+public:
+	UmtsRoutingModule() : RoutingModule() {}
+	virtual const char* module_name() const { return "Umts"; }
+	virtual int command(int argc, const char*const* argv);
+protected:
+	UmtsClassifier *classifier_;
+};
+
 class ManualRoutingModule : public RoutingModule {
 public:
 	ManualRoutingModule() : RoutingModule() {}
diff -ur tcl/lib/ns-default.tcl ns-umts-extensions/code/ns-default.tcl
--- tcl/lib/ns-default.tcl	2002-10-19 22:41:36.000000000 +0000
+++ ns-umts-extensions/code/ns-default.tcl	2003-06-01 20:10:45.000000000 +0000
@@ -1,7 +1,35 @@
 # -*-	Mode:tcl; tcl-indent-level:8; tab-width:8; indent-tabs-mode:t -*-
 #
-# Time-stamp: <2000-09-13 13:48:04 haoboy>
+# * Modified and extended by Pablo Martin and Paula Ballester,
+# * Strathclyde University, Glasgow.
+# * June, 2003.
+# *
+#
+# Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+# * All rights reserved.
+# *
+# * Redistribution and use in source and binary forms, with or without
+# * modification, are permitted provided that the following conditions
+# * are met:
+# *
+# * 1. Redistributions of source code and binary code must contain
+# * the above copyright notice, this list of conditions and the following
+# * disclaimer.
+# *
+# * 2. All advertising materials mentioning features or use of this software
+# * must display the following acknowledgement:
+# * This product includes software developed at Strathclyde University of
+# * Glasgow, Scotland.
+# *
+# * 3. The name of the University may not be used to endorse or promote
+# * products derived from this software without specific prior written
+# * permission.
+# * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+# * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+# * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+# * is provided "as is" without express or implied warranty of any kind.
 #
+
 # Copyright (c) 1996-1997 Regents of the University of California.
 # All rights reserved.
 # 
@@ -98,6 +126,12 @@
 
 Queue/DropTail/PriQueue set Prefer_Routing_Protocols    1
 
+# P.M. & P.B. modifications
+Queue/DropTail/FCQueue set limit_ 1000
+Queue/DropTail/FCQueue set verbose_ 0
+Queue/DropTail/BsFCQueue set limit_ 5000
+Queue/DropTail/BsFCQueue set verbose_ 0
+
 # special cmu implemented priority queue used by DSR
 CMUPriQueue set qlen_logthresh_ 10
 CMUPriQueue set fw_logthresh_ 25
@@ -206,7 +240,7 @@
 # Default for queue_in_bytes_ changed to true on 4/28/2002.
 Queue/Vq set markpkts_ false 
 Queue/Vq set ecnlim_ 0.8
-Queue/Vq set buflim_ 1.0 
+Queue/Vq set buflim_ 1.0
 # Queue/Vq set gamma_ 0.895
 Queue/Vq set gamma_ 0.98
 # Default for gamma_ changed to 0.98 on 4/28/2002.
@@ -359,6 +393,11 @@
 Classifier/Addr/MPLS set control_driven_ 0
 Classifier/Addr/MPLS set data_driven_ 0
 
+# P.M. & P.B. modifications
+Classifier/Umts set type_ 0	;# default wired node
+Classifier/Umts set id_ -1
+
+
 #
 # FEC models
 #
@@ -501,6 +540,9 @@
 Node set multiPath_ 0
 Node set rtagent_port_ 255
 
+# P.M. & P.B. modifications
+Node set update_ 0
+
 # setting port for diffusion application agent
 Node set DIFFUSION_APP_PORT 254
 
@@ -517,8 +559,8 @@
 
 # Default settings for Hierarchical topology
 #
-# Bits are allocated for different fields like port, nodeid, mcast, 
-# hierarchical-levels. 
+# Bits are allocated for different fields like port, nodeid, mcast,
+# hierarchical-levels.
 # All Mask and Shift values are stored in Class AddrParams.
 AddrParams set ALL_BITS_SET 0xffffffff
 AddrParams PortShift 0
@@ -542,7 +584,7 @@
 Simulator set addressType_   ""
 Simulator set MovementTrace_ OFF
 # This flag should be initially empty. It will be set to either ON or OFF
-# by Simulator::create-wireless-node{}. 
+# by Simulator::create-wireless-node{}.
 Simulator set IMEPFlag_ ""
 Simulator set WirelessNewTrace_ 0
 Simulator set propInstCreated_ 0
@@ -558,10 +600,15 @@
 Simulator set AgentTrace_ ON
 Simulator set RouterTrace_ OFF
 Simulator set MacTrace_   OFF
+# P.M. & P.B. modifications
+Simulator set PhyTrace_   OFF
 
 # use tagged traces or positional traces?
 Simulator set TaggedTrace_ OFF
 
+# P.M. & P.B. modifications
+Simulator set umts-routing 0
+
 SessionHelper set rc_ 0                      ;# just to eliminate warnings
 SessionHelper set debug_ false
 
@@ -587,17 +634,17 @@
 MIPEncapsulator set debug_ false
 
 # GAF
- 
+
 GAFPartner set addr_ 0
 GAFPartner set port_ 254
 GAFPartner set shift_ 0
 GAFPartner set mask_ [AddrParams set ALL_BITS_SET]
-GAFPartner set debug_ false                  
- 
+GAFPartner set debug_ false
+
 # HTTP-related defaults are in ../tcl/webcache/http-agent.tcl
 
 #
-# Wireless simulation support 
+# Wireless simulation support
 #
 
 Mac set debug_ false
@@ -607,6 +654,41 @@
 Mac/Tdma set slot_packet_len_	1500
 Mac/Tdma set max_node_num_	64
 
+# P.M. & P.B. modifications
+Phy/Umts set verbose_ 0
+Phy/Umts set error_rate_ 0
+Phy/Umts set phy_error_ 0
+Phy/Umts set delay_ 0
+Phy/Umts set bandwidth_ 0
+Phy/Umts set debug_ 0
+Phy/Umts set max_num_ms_ 100
+Phy/UmtsNodeB set verbose_ 0
+Phy/UmtsNodeB set error_rate_ 0
+Phy/UmtsNodeB set phy_error_ 0
+Phy/UmtsNodeB set delay_ 0
+Phy/UmtsNodeB set bandwidth_ 0
+Phy/UmtsNodeB set debug_ 0
+
+# P.M. & P.B. modifications
+Mac/Umts set verbose_ 0
+Mac/UmtsNodeb set verbose_ 0
+
+# P.M. & P.B. modifications
+Rlc/Umts set rlcverbose_ 0
+Rlc/Umts set delay_ 0
+Rlc/Umts set bandwidth_ 0
+Rlc/Umts set rlcfragsz_  20; # rlc frag size
+Rlc/Umts set debug_ 0
+Rlc/UmtsNodeB set rlcverbose_ 0
+Rlc/UmtsNodeB set delay_ 0
+Rlc/UmtsNodeB set rlcfragsz_  20; # rlc frag size
+Rlc/UmtsNodeB set bandwidth_ 0
+Rlc/UmtsNodeB set debug_ 0
+
+# P.M. & P.B. modifications
+LL/Nodeb set verbose_ 0
+LL/UE set verbose_ 0
+
 LL set mindelay_                50us
 LL set delay_                   25us
 LL set bandwidth_               0       ;# not used
@@ -615,7 +697,7 @@
 Snoop set debug_ false
 
 
-# 
+#
 # Support for Abstract LAN
 #
 
@@ -632,7 +714,7 @@
 # Set up the antennas to be centered in the node and 1.5 meters above it
 Antenna/OmniAntenna set X_ 0
 Antenna/OmniAntenna set Y_ 0
-Antenna/OmniAntenna set Z_ 1.5 
+Antenna/OmniAntenna set Z_ 1.5
 Antenna/OmniAntenna set Gt_ 1.0
 Antenna/OmniAntenna set Gr_ 1.0
 
@@ -644,7 +726,7 @@
 Phy/WirelessPhy set bandwidth_ 2e6
 Phy/WirelessPhy set Pt_ 0.28183815
 Phy/WirelessPhy set freq_ 914e+6
-Phy/WirelessPhy set L_ 1.0  
+Phy/WirelessPhy set L_ 1.0
 Phy/WirelessPhy set debug_ false
 
 Phy/WiredPhy set bandwidth_ 10e6
@@ -869,7 +951,7 @@
 Agent/TFRC set rttvar_exp_ 2	
 Agent/TFRC set T_SRTT_BITS 3	
 Agent/TFRC set T_RTTVAR_BITS 2	
-Agent/TFRC set InitRate_ 300 ;	# Initial send rate	
+Agent/TFRC set InitRate_ 300 ;	# Initial send rate
 Agent/TFRC set overhead_ 0 ;	# If > 0, dither outgoing packets
 Agent/TFRC set ssmult_ 2 ; 	# Rate of increase during slow-start:
 Agent/TFRC set bval_ 1 ;	# Value of B for TCP formula
diff -ur tcl/lib/ns-lib.tcl ns-umts-extensions/code/ns-lib.tcl
--- tcl/lib/ns-lib.tcl	2002-10-30 21:05:23.000000000 +0000
+++ ns-umts-extensions/code/ns-lib.tcl	2003-06-01 20:10:45.000000000 +0000
@@ -1,12 +1,42 @@
 # -*-	Mode:tcl; tcl-indent-level:8; tab-width:8; indent-tabs-mode:t -*-
 #
+# * Modified and extended by Pablo Martin and Paula Ballester,
+# * Strathclyde University, Glasgow.
+# * June, 2003.
+# *
+#
+# Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+# * All rights reserved.
+# *
+# * Redistribution and use in source and binary forms, with or without
+# * modification, are permitted provided that the following conditions
+# * are met:
+# *
+# * 1. Redistributions of source code and binary code must contain
+# * the above copyright notice, this list of conditions and the following
+# * disclaimer.
+# *
+# * 2. All advertising materials mentioning features or use of this software
+# * must display the following acknowledgement:
+# * This product includes software developed at Strathclyde University of
+# * Glasgow, Scotland.
+# *
+# * 3. The name of the University may not be used to endorse or promote
+# * products derived from this software without specific prior written
+# * permission.
+# * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+# * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+# * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+# * is provided "as is" without express or implied warranty of any kind.
+#
+
 # Copyright (c) 1996 Regents of the University of California.
 # All rights reserved.
 # 
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
 # are met:
-# 1. Redistributions of source code must retain the above copyright
+# 1. Redistributions of source code must retain the above copyright 
 #    notice, this list of conditions and the following disclaimer.
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
@@ -18,7 +48,7 @@
 # 4. Neither the name of the University nor of the Research Group may be
 #    used to endorse or promote products derived from this software without
 #    specific prior written permission.
-# 
+#
 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -91,8 +121,8 @@
 		kb { return [expr $b*1000] }
 		Mb { return [expr $b*1000000] }
 		Gb { return [expr $b*1000000000] }
-		default { 
-			puts "error: bw_parse: unknown unit `$unit'" 
+		default {
+			puts "error: bw_parse: unknown unit `$unit'"
 			exit 1
 		}
 	}
@@ -109,8 +139,8 @@
 		us { return [expr $t*1e-6] }
 		ns { return [expr $t*1e-9] }
 		ps { return [expr $t*1e-12] }
-		default { 
-			puts "error: time_parse: unknown unit `$unit'" 
+		default {
+			puts "error: time_parse: unknown unit `$unit'"
 			exit 1
 		}
 	}
@@ -188,11 +218,17 @@
 source ../mobility/dsdv.tcl
 source ../mobility/dsr.tcl
 source ../mobility/com.tcl
+# P.M. & P.B. modifications
+source ../mobility/noah.tcl
 
 source ../plm/plm.tcl
 source ../plm/plm-ns.tcl
 source ../plm/plm-topo.tcl
 
+# P.M. & P.B. modifications
+source ns-nodeb.tcl
+source ns-uenode.tcl
+
 # MPLS
 source ../mpls/ns-mpls-simulator.tcl
 source ../mpls/ns-mpls-node.tcl
@@ -226,19 +262,19 @@
 
 Simulator instproc init args {
 
-	# Debojyoti added this for asim 
+	# Debojyoti added this for asim
 
 	$self instvar useasim_
 	$self instvar slinks_
 	$self instvar nconn_
 	$self instvar sflows_
 	$self instvar nsflows_
-		
+
 	set slinks_(0:0) 0
 	set nconn_ 0
 	set conn_ ""
 	# for short flows stuff
-	set sflows_ "" 
+	set sflows_ ""
 	set nsflows_ 0
 	set useasim_ 0
 
@@ -297,8 +333,10 @@
 #
 # Define global node configuration
 # $ns_ node-config -addressType flat/hierarchical
-#                  -adhocRouting   DSDV/DSR/TORA
+#                  -adhocRouting   DSDV/DSR/TORA/NOAH
 #                  -llType
+#		   -rlcType
+#			 -phyLayer
 #                  -macType
 #                  -propType
 #                  -ifqType
@@ -316,15 +354,20 @@
 #                  -txPower        (in W)
 #                  -idlePower      (in W)
 #                  -agentTrace  ON
-#                  -routerTrace ON 
-#                  -macTrace OFF 
-#                  -toraDebug OFF                
+#                  -routerTrace ON
+#                  -macTrace OFF
+#			 -phyTrace OFF
+#                  -toraDebug OFF
 #                  -movementTrace OFF
+#                  -umtsType 	   UE/NodeB
 
 Simulator instproc addressType  {val} { $self set addressType_  $val }
 Simulator instproc adhocRouting  {val} { $self set routingAgent_  $val }
 Simulator instproc llType  {val} { $self set llType_  $val }
 Simulator instproc macType  {val} { $self set macType_  $val }
+# P.M. & P.B. modifications
+Simulator instproc phyLayer  {val} { $self set phyLayer_  $val }
+Simulator instproc rlcType {val} { $self set rlcType_ $val }
 Simulator instproc propType  {val} { $self set propType_  $val }
 Simulator instproc propInstance  {val} { $self set propInstance_  $val }
 Simulator instproc ifqType  {val} { $self set ifqType_  $val }
@@ -347,12 +390,16 @@
 Simulator instproc agentTrace  {val} { $self set agentTrace_  $val }
 Simulator instproc routerTrace  {val} { $self set routerTrace_  $val }
 Simulator instproc macTrace  {val} { $self set macTrace_  $val }
+# P.M. & P.B. modifications, nam
+Simulator instproc phyTrace  {val} { $self set phyTrace_  $val }
 Simulator instproc movementTrace  {val} { $self set movementTrace_  $val }
 Simulator instproc toraDebug {val} {$self set toraDebug_ $val }
 Simulator instproc satNodeType {val} {$self set satNodeType_ $val}
 Simulator instproc downlinkBW {val} {$self set downlinkBW_ $val}
 Simulator instproc stopTime {val} {$self set stopTime_ $val}
-Simulator instproc MPLS { val } { 
+# P.M. & P.B. modifications
+Simulator instproc umtsType {val} {$self set umtsType_ $val}
+Simulator instproc MPLS { val } {
 	if { $val == "ON" } {
 		Node enable-module "MPLS"
 	} else {
@@ -360,7 +407,7 @@
 	}
 }
 
-Simulator instproc PGM { val } { 
+Simulator instproc PGM { val } {
         if { $val == "ON" } {
                 Node enable-module "PGM"
         } else {
@@ -376,7 +423,7 @@
 }
 
 Simulator instproc get-nodetype {} {
-	$self instvar addressType_ routingAgent_ wiredRouting_ 
+	$self instvar addressType_ routingAgent_ wiredRouting_ umtsType_
 	set val ""
 
 	if { [info exists addressType_] && $addressType_ == "hierarchical" } {
@@ -391,6 +438,13 @@
 	if { [info exists wiredRouting_] && $wiredRouting_ == "OFF"} {
 		set val Base
 	}
+	# P.M. & P.B. modifications
+	if { [info exists umtsType_] && $umtsType_ == "UE"} {
+		set val UE
+	}
+	if { [info exists umtsType_] && $umtsType_ == "NodeB"} {
+		set val NodeB
+	}
 	if { [Simulator set mobile_ip_] } {
 		if { $val == "Base" && $wiredRouting_ == "ON" } {
 			set val MIPBS
@@ -406,27 +460,36 @@
         # Object::init-vars{} is defined in ~tclcl/tcl-object.tcl.
         # It initializes all default variables in the following way:
         #  1.  Look for pairs of {-cmd val} in args
-        #  2.  If "$self $cmd $val" is not valid then put it in a list of 
+        #  2.  If "$self $cmd $val" is not valid then put it in a list of
         #      arguments to be returned to the caller.
-        # 
-        # Since we do not handle undefined {-cmd val} pairs, we ignore 
+        #
+        # Since we do not handle undefined {-cmd val} pairs, we ignore
         # return value from init-vars{}.
         set args [eval $self init-vars $args]
 
         $self instvar addressType_  routingAgent_ propType_  macTrace_ \
-		routerTrace_ agentTrace_ movementTrace_ channelType_ channel_ \
+		phyTrace_ routerTrace_ agentTrace_ movementTrace_ channelType_ channel_ \
 		chan topoInstance_ propInstance_ mobileIP_ rxPower_ \
-		txPower_ idlePower_ satNodeType_
+		txPower_ idlePower_ satNodeType_ umtsType_
+
 
         if [info exists macTrace_] {
 		Simulator set MacTrace_ $macTrace_
 	}
+	  # P.M. & P.B. modifications, nam
+	  if [info exists phyTrace_] {
+		Simulator set PhyTrace_ $phyTrace_
+	}
         if [info exists routerTrace_] {
 		Simulator set RouterTrace_ $routerTrace_
 	}
         if [info exists agentTrace_] {
 		Simulator set AgentTrace_ $agentTrace_
 	}
+	# P.M. & P.B. modifications
+	if [info exists umtsType_] {
+		Simulator set UmtsType_ $umtsType_
+	}
         if [info exists movementTrace_] {
 		Simulator set MovementTrace_ $movementTrace_
 	}
@@ -444,12 +507,12 @@
 			Simulator set propInstCreated_ 1
 		}
 	}
-	
+
 	# Add multi-interface support:
- 	# User can only specify either channelType_ (single_interface as 
+ 	# User can only specify either channelType_ (single_interface as
 	# before) or channel_ (multi_interface)
  	# If both variables are specified, error!
- 	if {[info exists channelType_] && [info exists channel_]} { 
+ 	if {[info exists channelType_] && [info exists channel_]} {
 		error "Can't specify both channel and channelType, error!"
 	} elseif {[info exists channelType_] && ![info exists satNodeType_]} {
 		# Single channel, single interface
@@ -466,7 +529,7 @@
 	}
 	# set address type, hierarchical or expanded
 	if {[string compare $addressType_ ""] != 0} {
-		$self set-address-format $addressType_ 
+		$self set-address-format $addressType_
 	}
 	# set mobileIP flag
 	if { [info exists mobileIP_] && $mobileIP_ == "ON"} {
@@ -478,10 +541,10 @@
 	}
 }
 
-# Default behavior is changed: consider nam as not initialized if 
+# Default behavior is changed: consider nam as not initialized if
 # no shape OR color parameter is given
 Simulator instproc node args {
-	$self instvar Node_ routingAgent_ wiredRouting_ satNodeType_
+	$self instvar Node_ routingAgent_ wiredRouting_ satNodeType_ umtsType_
         if { [Simulator info vars EnableMcast_] != "" } {
                 warn "Flag variable Simulator::EnableMcast_ discontinued.\n\t\
                       Use multicast methods as:\n\t\t\
@@ -495,15 +558,23 @@
                       Setting this variable will not affect simulations."
                 Simulator unset NumberInterfaces_
         }
-	
+
 	# wireless-ready node
 	if { [info exists routingAgent_] && ($routingAgent_ != "") } {
 		set node [eval $self create-wireless-node $args]
-		# for base node
-		if {[info exists wiredRouting_] && $wiredRouting_ == "ON"} {
+
+		# P.M. & P.B. modifications
+		if {[info exists umtsType_]} {
 			set Node_([$node id]) $node
 			#simulator's nodelist in C++ space
-			$self add-node $node [$node id] 
+			$self add-node $node [$node id]
+		} else {
+			# for base node
+			if {[info exists wiredRouting_] && $wiredRouting_ == "ON"} {
+				set Node_([$node id]) $node
+				#simulator's nodelist in C++ space
+				$self add-node $node [$node id]
+			}
 		}
 		return $node
 	}
@@ -521,16 +592,17 @@
 	}
 
 	# Enable-mcast is now done automatically inside Node::init{}
-	# 
+	#
 	# XXX node_factory_ is deprecated, HOWEVER, since it's still used by
-	# mobile IP, algorithmic routing, manual routing, and backward 
+	# mobile IP, algorithmic routing, manual routing, and backward
 	# compability tests of hierarchical routing, we should keep it around
 	# before all related code are wiped out.
+
 	set node [eval new [Simulator set node_factory_] $args]
 	set Node_([$node id]) $node
-	
+
 	#add to simulator's nodelist in C++ space
-	$self add-node $node [$node id] 
+	$self add-node $node [$node id]
 
 	#set the nodeid in c++ Node - ratul
 	$node nodeid [$node id]
@@ -540,34 +612,36 @@
 	return $node
 }
 
-# XXX This is stupid hack. When old code (not using node-config) is used, 
+# XXX This is stupid hack. When old code (not using node-config) is used,
 # create-wireless-node{} will not be called, and IMEPFlag_ will remain empty
-# (as set in ns-default.tcl), then Node/MobileNode will use global proc 
-# cmu-trace to create trace objects; otherwise mobility-trace{} will be 
+# (as set in ns-default.tcl), then Node/MobileNode will use global proc
+# cmu-trace to create trace objects; otherwise mobility-trace{} will be
 # triggered.
 Simulator instproc imep-support {} {
 	return [Simulator set IMEPFlag_]
 }
 
-# XXX This should be moved into the node initialization procedure instead 
+# XXX This should be moved into the node initialization procedure instead
 # of standing here in ns-lib.tcl.
 Simulator instproc create-wireless-node args {
         $self instvar routingAgent_ wiredRouting_ propInstance_ llType_ \
 		macType_ ifqType_ ifqlen_ phyType_ chan antType_ energyModel_ \
 		initialEnergy_ txPower_ rxPower_ idlePower_ \
-		topoInstance_ level1_ level2_ inerrProc_ outerrProc_ FECProc_
+		topoInstance_ level1_ level2_ inerrProc_ outerrProc_ FECProc_ \
+		umtsType_ phyLayer_ rlcType_
 
 	Simulator set IMEPFlag_ OFF
 
         # create node instance
         set node [eval $self create-node-instance $args]
-        
+
         # basestation address setting
         if { [info exist wiredRouting_] && $wiredRouting_ == "ON" } {
 		$node base-station [AddrParams addr2id [$node node-addr]]
     	}
         switch -exact $routingAgent_ {
 	    DSDV {
+		    puts "DSDV elegido"
 		    set ragent [$self create-dsdv-agent $node]
 	    }
 	    DSR {
@@ -596,6 +670,10 @@
 		    eval $node addr $args
 		    set ragent [$self create-flooding-agent $node]
 	    }
+	    # P.M. & P.B. modifications
+	    NOAH {
+		    set ragent [$self create-noah-agent $node]
+          }
 	    OMNIMCAST {
 		    eval $node addr $args
 		    set ragent [$self create-omnimcast-agent $node]
@@ -604,12 +682,12 @@
 		    set ragent [$self create-dumb-agent $node]
 	    }
 	    default {
-		    puts "Wrong node routing agent!"
+		    puts "Wrong_ node routing agent!"
 		    exit
 	    }
 	}
 
-	# errProc_ and FECProc_ are an option unlike other 
+	# errProc_ and FECProc_ are an option unlike other
         # parameters for node interface
 	if ![info exist inerrProc_] {
 		set inerrProc_ ""
@@ -622,9 +700,17 @@
 	}
 
 	# Add main node interface
-	$node add-interface $chan $propInstance_ $llType_ $macType_ \
+
+	# P.M. & P.B. modifications
+	if { [info exists rlcType_] && [info exists phyLayer_]} {
+		$node add-interface $chan $propInstance_ $llType_ $rlcType_ $macType_ \
+			$phyLayer_ $ifqType_ $ifqlen_ $phyType_ $antType_ \
+			$inerrProc_ $outerrProc_ $FECProc_
+	} else {
+		$node add-interface $chan $propInstance_ $llType_ $macType_ \
 			$ifqType_ $ifqlen_ $phyType_ $antType_ \
 			$inerrProc_ $outerrProc_ $FECProc_
+	}
 	# Attach agent
 	if {$routingAgent_ != "DSR"} {
 		$node attach $ragent [Node set rtagent_port_]
@@ -641,9 +727,9 @@
 	if { $routingAgent_ == "DumbAgent" } {
 		$ragent port-dmux [$node demux]
 	}
-	
 
-	# Bind routing agent and mip agent if existing basestation 
+
+	# Bind routing agent and mip agent if existing basestation
 	# address setting
         if { [info exist wiredRouting_] && $wiredRouting_ == "ON" } {
 		if { $routingAgent_ != "DSR" } {
@@ -687,27 +773,33 @@
 		$node setPidle $idlePower_
         }
 	$node topography $topoInstance_
+
 	return $node
 }
 
 Simulator instproc create-node-instance args {
-	$self instvar routingAgent_
+	$self instvar routingAgent_ umtsType_
 	# DSR is a special case
 	if {$routingAgent_ == "DSR"} {
 		set nodeclass [$self set-dsr-nodetype]
 	} else {
+		# P.M. & P.B. modifications
 		set nodeclass Node/MobileNode
+		if {[info exists umtsType_]} {
+			set nodeclass_temp [$self get-nodetype]
+			set nodeclass Node/MobileNode/$nodeclass_temp
+		}
 	}
 	return [eval new $nodeclass $args]
 }
 
 Simulator instproc set-dsr-nodetype {} {
-	$self instvar wiredRouting_ 
+	$self instvar wiredRouting_
 	set nodetype SRNodeNew
 	# MIP mobilenode
 	if [Simulator set mobile_ip_] {
 		set nodetype SRNodeNew/MIPMH
-	} 
+	}
 	# basestation dsr node
 	if { [info exists wiredRouting_] && $wiredRouting_ == "ON"} {
 		set nodetype Node/MobileNode/BaseStationNode
@@ -738,17 +830,42 @@
 	return $ragent
 }
 
+# P.M. & P.B. modifications
+Simulator instproc create-noah-agent { node } {
+	# Create a noah routing agent for this node
+	set ragent [new Agent/NOAH]
+
+	## setup address (supports hier-addr) for noah agent
+   ## and mobilenode
+	set addr [$node node-addr]
+
+	$ragent addr $addr
+	$ragent node $node
+
+	if [Simulator set mobile_ip_] {
+		$ragent port-dmux [$node set dmux_]
+	}
+	$node addr $addr
+    $node set ragent_ $ragent
+
+    #delay till after add interface
+	 #$node attach $ragent 255
+
+	#$self at 0.0 "$ragent start-noah"    ;# start updates
+
+	return $ragent
+}
 
 Simulator instproc create-dumb-agent { node } {
-	
+
 	# create a simple wireless agent
 	# that only forwards packets
-	# used for testing single hop brdcast/unicast mode 
+	# used for testing single hop brdcast/unicast mode
 	# for wireless macs
 
 	set ragent [new Agent/DumbAgent]
 	$node set ragent_ $ragent
-	
+
 	return $ragent
 }
 
@@ -763,7 +880,7 @@
 
 Simulator instproc use-newtrace {} {
 	Simulator set WirelessNewTrace_ 1
-} 
+}
 
 Simulator instproc use-taggedtrace { {tag ON} } {
 	Simulator set TaggedTrace_ $tag
@@ -798,7 +915,7 @@
 }
 
 #
-# check if total num of nodes exceed 2 to the power n 
+# check if total num of nodes exceed 2 to the power n
 # where <n=node field size in address>
 #
 Simulator instproc check-node-num {} {
@@ -809,7 +926,7 @@
 
 #
 # Check if number of items at each hier level (num of nodes, or clusters or
-# domains) exceed size of that hier level field size (in bits). should be 
+# domains) exceed size of that hier level field size (in bits). should be
 # modified to support n-level of hierarchies
 #
 Simulator instproc chk-hier-field-lengths {} {
@@ -818,9 +935,9 @@
 		if {[expr $domain_num_ - 1]> [AddrParams NodeMask 1]} {
 			error "\# of domains exceed dom-field-size "
 		}
-	} 
+	}
 	if [info exists cluster_num_] {
-		set maxval [expr [find-max $cluster_num_] - 1] 
+		set maxval [expr [find-max $cluster_num_] - 1]
 		if {$maxval > [expr pow(2, [AddrParams NodeMask 2])]} {
 			error "\# of clusters exceed clus-field-size "
 		}
@@ -840,10 +957,10 @@
 	$self check-node-num
 	$self rtmodel-configure			;# in case there are any
 	[$self get-routelogic] configure
-	$self instvar scheduler_ Node_ link_ started_ 
-	
+	$self instvar scheduler_ Node_ link_ started_
+
 	set started_ 1
-	
+
 	#
 	# Reset every node, which resets every agent.
 	#
@@ -874,6 +991,12 @@
 	return [$scheduler_ run]
 }
 
+# P.M. & P.B. modifications
+Simulator instproc set-umts-routing { } {
+    Simulator set umts-routing 1
+    Node enable-module "Umts"
+}
+
 # johnh xxx?
 Simulator instproc log-simstart { } {
         # GFR Modification to log actual start
@@ -977,13 +1100,13 @@
 		set pushback 0
 	}
 	$n1 add-neighbor $n2 $pushback
-	
+
 	#XXX yuck
-	if {[string first "RED" $qtype] != -1 || 
-		[string first "PI" $qtype] != -1 || 
+	if {[string first "RED" $qtype] != -1 ||
+		[string first "PI" $qtype] != -1 ||
 		[string first "Vq" $qtype] != -1 ||
-		[string first "REM" $qtype] != -1 ||  
-		[string first "GK" $qtype] != -1 ||  
+		[string first "REM" $qtype] != -1 ||
+		[string first "GK" $qtype] != -1 ||
 		[string first "RIO" $qtype] != -1} {
 		$q link [$link_($sid:$did) set link_]
 	}
@@ -996,14 +1119,14 @@
 	if {$trace != ""} {
 		$self namtrace-queue $n1 $n2 $trace
 	}
-	
-	# Register this simplex link in nam link list. Treat it as 
+
+	# Register this simplex link in nam link list. Treat it as
 	# a duplex link in nam
 	$self register-nam-linkconfig $link_($sid:$did)
 }
 
 #
-# This is used by Link::orient to register/update the order in which links 
+# This is used by Link::orient to register/update the order in which links
 # should created in nam. This is important because different creation order
 # may result in different layout.
 #
@@ -1024,7 +1147,7 @@
 						"ORIENTATION"]
 				set a2 [$link get-attribute "ORIENTATION"]
 				if {$a1 == "" && $a2 != ""} {
-					# If this duplex link has not been 
+					# If this duplex link has not been
 					# assigned an orientation, do it.
 					set linkConfigList_ [lreplace \
 						$linkConfigList_ $pos $pos]
@@ -1145,18 +1268,18 @@
 }
 
 Simulator instproc namtrace-all-wireless {file optx opty} {
-        $self instvar namtraceAllFile_  
- 
-        if {$file != ""} { 
+        $self instvar namtraceAllFile_
+
+        if {$file != ""} {
                 set namtraceAllFile_ $file
         } else {
                 unset namtraceAllFile_
-        }       
+        }
         $self puts-nam-config "W -t * -x $optx -y $opty"
 }
 
 # Support for event-tracing
-        
+
 Simulator instproc eventtrace-all {{file ""}} {
 	$self instvar eventTraceAll_ eventtraceAllFile_ traceAllFile_
 	set eventTraceAll_ 1
@@ -1165,26 +1288,27 @@
 	} else {
 		set eventtraceAllFile_ $traceAllFile_
 	}
-	
+
 }
 
 
 
 Simulator instproc initial_node_pos {nodep size} {
 	$self instvar addressType_
-	$self instvar energyModel_ 
+	$self instvar energyModel_
 
-	if [info exists energyModel_] {  
+	if [info exists energyModel_] {
 		set nodeColor "green"
 	} else {
 		set nodeColor "black"
 	}
+	# P.M. & P.B. modifications
 	if { [info exists addressType_] && $addressType_ == "hierarchical" } {
 		# Hierarchical addressing
 		$self puts-nam-config "n -t * -a [$nodep set address_] \
 -s [$nodep id] -x [$nodep set X_] -y [$nodep set Y_] -Z [$nodep set Z_] \
 -z $size -v circle -c $nodeColor"
-	} else { 
+	} else {
 		# Flat addressing
 		$self puts-nam-config "n -t * -s [$nodep id] \
 -x [$nodep set X_] -y [$nodep set Y_] -Z [$nodep set Z_] -z $size \
@@ -1233,7 +1357,7 @@
 	}
 }
 
-# namConfigFile is used for writing color/link/node/queue/annotations. 
+# namConfigFile is used for writing color/link/node/queue/annotations.
 # XXX It cannot co-exist with namtraceAll.
 Simulator instproc namtrace-config { f } {
 	$self instvar namConfigFile_
@@ -1250,11 +1374,11 @@
 }
 
 # Used only for writing nam configurations to trace file(s). This is different
-# from puts-nam-traceall because we may want to separate configuration 
+# from puts-nam-traceall because we may want to separate configuration
 # informations and actual tracing information
 Simulator instproc puts-nam-config { str } {
 	$self instvar namtraceAllFile_ namConfigFile_
-	
+
 	if [info exists namConfigFile_] {
 		puts $namConfigFile_ $str
 	} elseif [info exists namtraceAllFile_] {
@@ -1287,23 +1411,23 @@
 	}
 	lappend alltrace_ $p
 	if {$file != ""} {
-		$p ${op}attach $file		
+		$p ${op}attach $file
 	}
 	return $p
 }
 
 
 Simulator instproc create-eventtrace {type owner } {
-	$self instvar alltrace_ 
+	$self instvar alltrace_
 	$self instvar eventTraceAll_ eventtraceAllFile_ namtraceAllFile_
-	
+
 	if ![info exists eventTraceAll_] return
 
 	if { $eventTraceAll_ == 1 } {
-		
+
 		set et [new BaseTrace/$type]
 		$owner cmd eventtrace $et
-		
+
 		lappend alltrace_ $et
 		$et attach $eventtraceAllFile_
 		if [info exists namtraceAllFile_] {
@@ -1320,10 +1444,10 @@
 		set file $namtraceAllFile_
 	}
 	$link_([$n1 id]:[$n2 id]) nam-trace $self $file
-    
-	# Added later for queue specific tracing events other than enque, 
-	# deque and drop as of now nam does not understand special events. 
-	# Changes will have to be made to nam for it to understand events 
+
+	# Added later for queue specific tracing events other than enque,
+	# deque and drop as of now nam does not understand special events.
+	# Changes will have to be made to nam for it to understand events
 	# like early drops if they are prefixed differently than "d". - ratul
 	set queue [$link_([$n1 id]:[$n2 id]) queue]
 	$queue attach-nam-traces $n1 $n2 $file
@@ -1336,8 +1460,8 @@
 		set file $traceAllFile_
 	}
 	$link_([$n1 id]:[$n2 id]) trace $self $file
-	
-	# Added later for queue specific tracing events other than enque, 
+
+	# Added later for queue specific tracing events other than enque,
 	# deque and drop - ratul
 	set queue [$link_([$n1 id]:[$n2 id]) queue]
 	$queue attach-traces $n1 $n2 $file
@@ -1385,11 +1509,11 @@
 	$self instvar conn_ nconn_ sflows_ nsflows_ useasim_
 
 	if {$useasim_ == 1} {
-		set list "" 
+		set list ""
 		set s [$node id]
 		set d [[$self get-node-by-addr [$agent set dst_addr_]] id]
 		foreach x $conn_ {
-			set t [split $x ":"] 
+			set t [split $x ":"]
 			if {[string compare [lindex $t 0]:[lindex $t 1] $s:$d] != 0} {
 				lappend list_ $x
 			}
@@ -1422,7 +1546,7 @@
 	}
 }
 
-# 
+#
 #   Helper proc for setting bandwidth on an existing link
 #
 Simulator instproc bandwidth { n1 n2 bandwidth {type simplex} } {
@@ -1432,7 +1556,7 @@
         if [info exists link_($sid:$did)] {
                 set d [$link_($sid:$did) link]
                 $d set bandwidth_ $bandwidth
-        } 
+        }
         if {$type == "duplex"} {
                 if [info exists link_($did:$sid)] {
                         set d [$link_($did:$sid) link]
@@ -1458,7 +1582,7 @@
 		set sport [$src set agent_port_]
 		set did [$dst nodeid]
 		set dport [$dst set agent_port_]
-		
+
 		if {[lindex [split [$src info class] "/"] 1] == "TCP"} {
 			lappend conn_ $sid:$did:$sport:$dport
 			incr nconn_
@@ -1471,7 +1595,7 @@
 }
 
 Simulator instproc simplex-connect { src dst } {
-	$src set dst_addr_ [$dst set agent_addr_] 
+	$src set dst_addr_ [$dst set agent_addr_]
 	$src set dst_port_ [$dst set agent_port_]
 
 
@@ -1524,7 +1648,7 @@
 	error "get-node-id-by-addr:Cannot find node with given address"
 }
 
-# Given an node's address, return the node 
+# Given an node's address, return the node
 Simulator instproc get-node-by-addr address {
 	return [$self get-node-by-id [$self get-node-id-by-addr $address]]
 }
@@ -1564,11 +1688,11 @@
 	$self attach-agent $source $s_agent
 	$self attach-agent $dest $d_agent
 	$self connect $s_agent $d_agent
-	
+
 	return $s_agent
 }
 
-# Creates a highspeed connection. Similar to create-connection 
+# Creates a highspeed connection. Similar to create-connection
 # above except the sink agent requires additional work -- Sylvia
 Simulator instproc create-highspeed-connection {s_type source d_type dest pktClass} {
         set s_agent [new Agent/$s_type]
@@ -1597,12 +1721,12 @@
     $self connect $s_agent $d_agent
 
     return [list $s_agent $d_agent]
-}   
+}
 
 # Creates connection. First creates a source agent of type s_type and binds
 # it to source.  Next creates a destination agent of type d_type and binds
 # it to dest.  Finally creates bindings for the source and destination agents,
-# connects them, and  returns the source agent. 
+# connects them, and  returns the source agent.
 # The destination agent is set to listen, for full-tcp.
 Simulator instproc create-connection-listen {s_type source d_type dest pktClass} {
     set s_agent [new Agent/$s_type]
@@ -1614,8 +1738,8 @@
     $self connect $s_agent $d_agent
     $d_agent listen
 
-    return $s_agent 
-}   
+    return $s_agent
+}
 
 # This seems to be an obsolete procedure.
 Simulator instproc create-tcp-connection {s_type source d_type dest pktClass} {
@@ -1629,7 +1753,7 @@
 }
 
 #
-# Other classifier methods overload the instproc-likes to track 
+# Other classifier methods overload the instproc-likes to track
 # and return the installed objects.
 #
 Classifier instproc install {slot val} {
@@ -1705,15 +1829,15 @@
 Simulator instproc makeflowmon { cltype { clslots 29 } } {
 	set flowmon [new QueueMonitor/ED/Flowmon]
 	set cl [new Classifier/Hash/$cltype $clslots]
-	
+
 	$cl proc unknown-flow { src dst fid }  {
 		set fdesc [new QueueMonitor/ED/Flow]
 		set dsamp [new Samples]
 		$fdesc set-delay-samples $dsamp
-		set slot [$self installNext $fdesc] 
+		set slot [$self installNext $fdesc]
 		$self set-hash auto $src $dst $fid $slot
 	}
-	
+
 	$cl proc no-slot slotnum {
 		#
 		# note: we can wind up here when a packet passes
@@ -1771,7 +1895,7 @@
                 $fdesc set target_rate_ $rate
                 $fdesc set bucket_depth_ $depth
                 # Initialize the bucket as full
-                $fdesc set tbucket_ $init  
+                $fdesc set tbucket_ $init
                 set slot [$self installNext $fdesc]
                 $self set-hash $hashbucket $src $dst $fid $slot
         }
@@ -1871,7 +1995,7 @@
 }
 
 Simulator instproc abstract-tcp {} {
-	$self instvar TahoeAckfsm_ RenoAckfsm_ TahoeDelAckfsm_ RenoDelAckfsm_ dropper_ 
+	$self instvar TahoeAckfsm_ RenoAckfsm_ TahoeDelAckfsm_ RenoDelAckfsm_ dropper_
 	$self set TahoeAckfsm_ [new FSM/TahoeAck]
 	$self set RenoAckfsm_ [new FSM/RenoAck]
 	$self set TahoeDelAckfsm_ [new FSM/TahoeDelAck]
@@ -1879,7 +2003,7 @@
 	$self set nullAgent_ [new DropTargetAgent]
 }
 
-# Chalermek: For Diffusion, Flooding, and Omnicient Multicast 
+# Chalermek: For Diffusion, Flooding, and Omnicient Multicast
 
 Simulator instproc create-diffusion-rate-agent {node} {
 	global opt
@@ -1896,7 +2020,7 @@
 		} else {
 			$diff disable-pos
 		}
-	} 
+	}
 
 	if [info exist opt(enableNeg)] {
 		if {$opt(enableNeg) == "true"} {
@@ -1904,47 +2028,47 @@
 		} else {
 			$diff disable-neg
 		}
-	} 
-    
+	}
+
 	if [info exist opt(suppression)] {
 		if {$opt(suppression) == "true"} {
 			$diff enable-suppression
 		} else {
 			$diff disable-suppression
 		}
-	} 
+	}
 
 	if [info exist opt(subTxType)] {
 		$diff set-sub-tx-type $opt(subTxType)
-	} 
+	}
 
 	if [info exist opt(orgTxType)] {
 		$diff set-org-tx-type $opt(orgTxType)
-	} 
+	}
 
 	if [info exist opt(posType)] {
 		$diff set-pos-type $opt(posType)
-	} 
+	}
 
 	if [info exist opt(posNodeType)] {
 		$diff set-pos-node-type $opt(posNodeType)
-	} 
+	}
 
 	if [info exist opt(negWinType)] {
 		$diff set-neg-win-type $opt(negWinType)
-	} 
+	}
 
 	if [info exist opt(negThrType)] {
 		$diff set-neg-thr-type $opt(negThrType)
-	} 
+	}
 
 	if [info exist opt(negMaxType)] {
 		$diff set-neg-max-type $opt(negMaxType)
-	} 
+	}
 
 	$self put-in-list $diff
 	$self at 0.0 "$diff start"
-	
+
 	return $diff
 }
 
@@ -1963,15 +2087,15 @@
 		} else {
 			$diff disable-pos
 		}
-	} 
+	}
 	if [info exist opt(enableNeg)] {
 		if {$opt(enableNeg) == "true"} {
 			$diff enable-neg
 		} else {
 			$diff disable-neg
 		}
-	} 
-	
+	}
+
 	$self put-in-list $diff
 	$self at 0.0 "$diff start"
 
@@ -1990,7 +2114,7 @@
 	if { [info exists stopTime_] } {
 		$ragent stop-time $stopTime_
 	}
-	
+
 	$node create-diffusionApp-agent
 	return $ragent
 }
@@ -2040,4 +2164,4 @@
 		$i stop
 	}
 }
-    
+
diff -ur tcl/lib/ns-mobilenode.tcl ns-umts-extensions/code/ns-mobilenode.tcl
--- tcl/lib/ns-mobilenode.tcl	2002-04-01 23:07:27.000000000 +0000
+++ ns-umts-extensions/code/ns-mobilenode.tcl	2003-06-01 20:10:45.000000000 +0000
@@ -1,12 +1,42 @@
 # -*-	Mode:tcl; tcl-indent-level:8; tab-width:8; indent-tabs-mode:t -*-
 #
+# * Modified and extended by Pablo Martin and Paula Ballester,
+# * Strathclyde University, Glasgow.
+# * June, 2003.
+# *
+#
+# Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+# * All rights reserved.
+# *
+# * Redistribution and use in source and binary forms, with or without
+# * modification, are permitted provided that the following conditions
+# * are met:
+# *
+# * 1. Redistributions of source code and binary code must contain
+# * the above copyright notice, this list of conditions and the following
+# * disclaimer.
+# *
+# * 2. All advertising materials mentioning features or use of this software
+# * must display the following acknowledgement:
+# * This product includes software developed at Strathclyde University of
+# * Glasgow, Scotland.
+# *
+# * 3. The name of the University may not be used to endorse or promote
+# * products derived from this software without specific prior written
+# * permission.
+# * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+# * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+# * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+# * is provided "as is" without express or implied warranty of any kind.
+#
+
 # Copyright (c) 1998-2000 Regents of the University of California.
 # All rights reserved.
 # 
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
 # are met:
-# 1. Redistributions of source code must retain the above copyright
+# 1. Redistributions of source code must retain the above copyright 
 #    notice, this list of conditions and the following disclaimer.
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
@@ -73,8 +103,8 @@
 
 #----------------------------------------------------------------------
 
-# XXX Following are the last remnant of nodetype_. Need to be completely 
-# removed, however, we need a better mechanism to distinguish vanilla 
+# XXX Following are the last remnant of nodetype_. Need to be completely
+# removed, however, we need a better mechanism to distinguish vanilla
 # mobile node from MIP base station, and MIP mobile host.
 
 Node/MobileNode instproc makemip-NewMobile {} {
@@ -83,6 +113,12 @@
 Node/MobileNode instproc makemip-NewBase {} {
 }
 
+Node/MobileNode instproc makemip-NewNodeB {} {
+}
+
+Node/MobileNode instproc makemip-NewUE {} {
+}
+
 Node/MobileNode instproc makemip-New {} {
 }
 
@@ -160,7 +196,7 @@
 		$arptable_ reset 
 	}
 }
-
+ 
 #
 # Attach an agent to a node.  Pick a port and
 # bind the agent to the port number.
@@ -547,7 +583,7 @@
 		if {$imepflag != ""} {
 			set drpT [$self mobility-trace Drop "MAC"]
 		} else {
-			set drpT [cmu-trace Drop "MAC" $self]`
+			set drpT [cmu-trace Drop "MAC" $self]
 		}
 		$mac drop-target $drpT
 		if { $namfp != "" } {
@@ -563,6 +599,15 @@
 	$self addif $netif
 }
 
+# P.M. & P.B. modifications
+Node/MobileNode instproc update-changed { destid } {
+	$self instvar rtObject_
+	set entrypoint [$self entry]
+	if [info exists rtObject_] {	;# i.e. detailed dynamic routing
+		$rtObject_ update-changed $destid $entrypoint
+	}
+}
+
 # set transmission power
 Node/MobileNode instproc setPt { val } {
 	$self instvar netif_
diff -ur tcl/lib/ns-namsupp.tcl ns-umts-extensions/code/ns-namsupp.tcl
--- tcl/lib/ns-namsupp.tcl	2002-09-25 20:40:19.000000000 +0000
+++ ns-umts-extensions/code/ns-namsupp.tcl	2003-06-01 20:10:45.000000000 +0000
@@ -1,4 +1,34 @@
-# 
+# * Modified and extended by Pablo Martin and Paula Ballester,
+# * Strathclyde University, Glasgow.
+# * June, 2003.
+# *
+#
+# Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+# * All rights reserved.
+# *
+# * Redistribution and use in source and binary forms, with or without
+# * modification, are permitted provided that the following conditions
+# * are met:
+# *
+# * 1. Redistributions of source code and binary code must contain
+# * the above copyright notice, this list of conditions and the following
+# * disclaimer.
+# *
+# * 2. All advertising materials mentioning features or use of this software
+# * must display the following acknowledgement:
+# * This product includes software developed at Strathclyde University of
+# * Glasgow, Scotland.
+# *
+# * 3. The name of the University may not be used to endorse or promote
+# * products derived from this software without specific prior written
+# * permission.
+# * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+# * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+# * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+# * is provided "as is" without express or implied warranty of any kind.
+#
+
+#
 #  Copyright (c) 1997 by the University of Southern California
 #  All rights reserved.
 # 
@@ -114,7 +144,7 @@
 
 	if ![info exists attr_(SHAPE)] {
 		set attr_(SHAPE) "circle"
-	} 
+	}
 	if ![info exists attr_(COLOR)] {
 		set attr_(COLOR) "black"
 	        set attr_(LCOLOR) "black"
@@ -122,10 +152,33 @@
         if ![info exists attr_(DCOLOR)] {
                 set attr_(DCOLOR) "black"
         }
+
 	$ns puts-nam-config \
 		[eval list "n -t * -a $address_ -s $id_ -S UP -v $attr_(SHAPE) -c $attr_(COLOR) -i $attr_(LCOLOR)"]
 }
 
+# P.M. & P.B. modifications
+Node instproc dump-namconfig-flat {} {
+	$self instvar attr_ id_ address_ X_ Y_ Z_
+	set ns [Simulator instance]
+
+	if ![info exists attr_(SHAPE)] {
+		set attr_(SHAPE) "circle"
+	}
+	if ![info exists attr_(COLOR)] {
+		set attr_(COLOR) "black"
+	        set attr_(LCOLOR) "black"
+	}
+        if ![info exists attr_(DCOLOR)] {
+                set attr_(DCOLOR) "black"
+        }
+
+	$ns puts-nam-config \
+		[eval list "n -t * -s $id_ -S UP -x $X_ -y $Y_ -Z $Z_ -v $attr_(SHAPE) -c $attr_(COLOR) -i $attr_(LCOLOR)"]
+}
+
+
+
 Node instproc change-color { color } {
 	puts "Warning: Node::change-color is obsolete. Use Node::color instead"
 	$self color $color
@@ -428,12 +481,27 @@
 
 Simulator instproc dump-namnodes {} {
 	$self instvar Node_
+	# P.M. & P.B. modifications
+	$self instvar addressType_
+
 	if ![$self is-started] {
 		return
 	}
 	foreach nn [array names Node_] {
 		if ![$Node_($nn) is-lan?] {
-			$Node_($nn) dump-namconfig
+			# P.M. & P.B. modifications, make distinction between hierarchical
+			# and flat addressing like in ns-lib.tcl, proc initial_node_pos
+			set prov [$Node_($nn) nodetype]
+			if {!$prov} {
+				$Node_($nn) dump-namconfig
+			}
+#			if { [info exists addressType_] && $addressType_ == "hierarchical" } {
+#				# Hierarchical addressing
+#				$Node_($nn) dump-namconfig
+#			} else {
+#				# Flat addressing
+#				$Node_($nn) dump-namconfig-flat
+#			}
 		}
 	}
 }
@@ -462,29 +530,29 @@
 }
 
 Simulator instproc init-nam {} {
-	$self instvar annotationSeq_ 
+	$self instvar annotationSeq_
 
 	set annotationSeq_ 0
 
 	# Setting nam trace file version first
 	$self dump-namversion 1.0a5
-	
+
 	# Addressing scheme
 	$self dump-namaddress
 	
 	# Color configuration for nam
 	$self dump-namcolors
-	
+
 	# Node configuration for nam
 	$self dump-namnodes
-	
+
 	# Lan and Link configurations for nam
-	$self dump-namlinks 
+	$self dump-namlinks
 	$self dump-namlans
-	
+
 	# nam queue configurations
 	$self dump-namqueues
-	
+
 	# Traced agents for nam
 	$self dump-namagents
 
diff -ur tcl/lib/ns-node.tcl ns-umts-extensions/code/ns-node.tcl
--- tcl/lib/ns-node.tcl	2001-11-06 06:16:21.000000000 +0000
+++ ns-umts-extensions/code/ns-node.tcl	2003-06-01 20:10:45.000000000 +0000
@@ -1,6 +1,35 @@
 # -*-	Mode:tcl; tcl-indent-level:8; tab-width:8; indent-tabs-mode:t -*-
 #
-# Time-stamp: <2000-09-22 09:41:04 haoboy>
+# * Modified and extended by Pablo Martin and Paula Ballester,
+# * Strathclyde University, Glasgow.
+# * June, 2003.
+# *
+#
+# Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+# * All rights reserved.
+# *
+# * Redistribution and use in source and binary forms, with or without
+# * modification, are permitted provided that the following conditions
+# * are met:
+# *
+# * 1. Redistributions of source code and binary code must contain
+# * the above copyright notice, this list of conditions and the following
+# * disclaimer.
+# *
+# * 2. All advertising materials mentioning features or use of this software
+# * must display the following acknowledgement:
+# * This product includes software developed at Strathclyde University of
+# * Glasgow, Scotland.
+# *
+# * 3. The name of the University may not be used to endorse or promote
+# * products derived from this software without specific prior written
+# * permission.
+# * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+# * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+# * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+# * is provided "as is" without express or implied warranty of any kind.
+#
+
 #
 # Copyright (c) 1996-2000 Regents of the University of California.
 # All rights reserved.
@@ -20,7 +49,7 @@
 # 4. Neither the name of the University nor of the Research Group may be
 #    used to endorse or promote products derived from this software without
 #    specific prior written permission.
-# 
+#
 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -43,7 +72,7 @@
 	return $id
 }
 
-# The list of modules to be installed. More can be added via node-config. 
+# The list of modules to be installed. More can be added via node-config.
 # Base should always be the first module in this list.
 Node set module_list_ { Base }
 
@@ -77,8 +106,9 @@
 	} else {
 		set address_ $id_
 	}
+
 	$self cmd addr $address_; # Propagate address_ into C++ space
-	#$ns_ add-node $self $id_        
+	#$ns_ add-node $self $id_
 	set neighbor_ ""
 	set agents_ ""
 	set dmux_ ""
@@ -94,7 +124,7 @@
 }
 
 # XXX This instproc is backward compatibility; when satellite node, mobile
-# node (incl. MIP) are converted to routing modules, this should be merged 
+# node (incl. MIP) are converted to routing modules, this should be merged
 # into init{}
 Node instproc mk-default-classifier {} {
 	Node instvar module_list_
@@ -108,6 +138,11 @@
 	return [$self set id_]
 }
 
+# P.M. & P.B. modifications, 0 means "node"
+Node instproc nodetype {} {
+	return 0
+}
+
 Node instproc node-addr {} {
 	return [$self set address_]
 }
@@ -179,7 +214,7 @@
 	return [$self set classifier_]
 }
 
-# Place classifier $clsfr at the node entry point. 
+# Place classifier $clsfr at the node entry point.
 #
 # - Place the existing entry at slot $hook of the new classifier. Usually 
 #   it is an address classifier sitting in a node entry, so this means that
@@ -187,7 +222,7 @@
 #   classifier, if this is necessary. 
 #
 # - Associate the new classifier with $module (stored in mod_assoc_). This
-#   information is used later when the associated classifier is replaced, 
+#   information is used later when the associated classifier is replaced,
 #   then $module will be notified of this event and requested to unregister.
 #
 # - The original classifier is stored in hook_assoc_, this is used in 
@@ -216,7 +251,7 @@
 # We separate insert-entry from install-entry because we need a method to 
 # replace the current entry classifier and _remove_ routing functionality 
 # associated with that classifier. These two methods cannot be merged by 
-# checking whether $hook is empty. 
+# checking whether $hook is empty.
 Node instproc install-entry { module clsfr {hook ""} } {
 	$self instvar classifier_ mod_assoc_ hook_assoc_
 	if [info exists classifier_] {
@@ -322,7 +357,6 @@
 	}
 }
 
-
 #----------------------------------------------------------------------
 
 # XXX Eventually add-routes{} and delete-routes{} should be 
@@ -330,15 +364,20 @@
 
 # Node support for equal cost multi path routing
 Node instproc add-routes {id ifs} {
-	$self instvar classifier_ multiPath_ routes_ mpathClsfr_
+	$self instvar classifier_ multiPath_ routes_ mpathClsfr_ update_
 	if !$multiPath_ {
 		if {[llength $ifs] > 1} {
 			warn "$class::$proc cannot install multiple routes"
 			set ifs [lindex $ifs 0]
 		}
-		$self add-route $id [$ifs head]
-		set routes_($id) 1
-		return
+		# P.M. & P.B. modifications
+		if {[$self nodetype] == 2 && [set update_]} {
+			return
+		} else {
+			$self add-route $id [$ifs head]
+			set routes_($id) 1
+			return
+		}
 	}
 	if {$routes_($id) <= 0 && [llength $ifs] == 1 && \
 			![info exists mpathClsfr_($id)]} {
@@ -381,21 +420,21 @@
 	} else {
 		$self delete-route $id $nullagent
 		incr routes_($id) -1
-		# Notice that after this operation routes_($id) may not 
+		# Notice that after this operation routes_($id) may not
 		# necessarily be 0.
 	}
 }
 
-# Enable multicast routing support in this node. 
-# 
-# XXX This instproc should ONLY be used when you want multicast only on a 
+# Enable multicast routing support in this node.
+#
+# XXX This instproc should ONLY be used when you want multicast only on a
 # subset of nodes as a means to save memory. If you want to run multicast on
 # your entire topology, use [new Simulator -multicast on].
 Node instproc enable-mcast args {
-	# Do NOT add Mcast using Node enable-module, because the latter 
+	# Do NOT add Mcast using Node enable-module, because the latter
 	# enables mcast for all nodes that may be created later
 	$self register-module [new RtModule/Mcast]
-	
+
 }
 
 #--------------------------------------------------------------
@@ -461,12 +500,12 @@
 # Attach an agent to a node: pick a port and bind the agent to the port.
 #
 # To install module-specific demuxers, do that in your module's register{}
-# method. Since this method will be called during Node::init{}, when 
+# method. Since this method will be called during Node::init{}, when
 # Node::attach{} is called dmux_ will already be present hence the following
 # default dmux_ construction will not be triggered.
 #
 Node instproc attach { agent { port "" } } {
-	$self instvar agents_ address_ dmux_ 
+	$self instvar agents_ address_ dmux_
 	#
 	# Assign port number (i.e., this agent receives
 	# traffic addressed to this host and port)
@@ -477,11 +516,13 @@
 	# We call the entry method on ourself to find the front door
 	# (e.g., for multicast the first object is not the unicast classifier)
 	#
-	# Also, stash the node in the agent and set the local addr of 
+	# Also, stash the node in the agent and set the local addr of
 	# this agent.
 	#
 	$agent set node_ $self
 	$agent set agent_addr_ [AddrParams addr2id $address_]
+
+
 	#
 	# If a port demuxer doesn't exist, create it.
 	#
@@ -527,7 +568,7 @@
 	$agent set node_ ""
 	$agent set agent_addr_ 0
 	$agent target $nullagent
-	# Install nullagent to sink transit packets   
+	# Install nullagent to sink transit packets
 	$dmux_ install [$agent set agent_port_] $nullagent
 
 	foreach m [$self set ptnotif_] {
diff -ur tcl/lib/ns-packet.tcl ns-umts-extensions/code/ns-packet.tcl
--- tcl/lib/ns-packet.tcl	2002-01-14 20:05:43.000000000 +0000
+++ ns-umts-extensions/code/ns-packet.tcl	2003-06-01 20:10:45.000000000 +0000
@@ -1,6 +1,34 @@
 # -*-	Mode:tcl; tcl-indent-level:8; tab-width:8; indent-tabs-mode:t -*-
 #
-# Time-stamp: <2000-08-31 19:01:26 haoboy>
+# * Modified and extended by Pablo Martin and Paula Ballester,
+# * Strathclyde University, Glasgow.
+# * June, 2003.
+# *
+#
+# Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+# * All rights reserved.
+# *
+# * Redistribution and use in source and binary forms, with or without
+# * modification, are permitted provided that the following conditions
+# * are met:
+# *
+# * 1. Redistributions of source code and binary code must contain
+# * the above copyright notice, this list of conditions and the following
+# * disclaimer.
+# *
+# * 2. All advertising materials mentioning features or use of this software
+# * must display the following acknowledgement:
+# * This product includes software developed at Strathclyde University of
+# * Glasgow, Scotland.
+# *
+# * 3. The name of the University may not be used to endorse or promote
+# * products derived from this software without specific prior written
+# * permission.
+# * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+# * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+# * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+# * is provided "as is" without express or implied warranty of any kind.
+#
 #
 # Copyright (c) 1997 Regents of the University of California.
 # All rights reserved.
@@ -113,37 +141,38 @@
 foreach prot {
 	AODV
 	ARP
-  	aSRM 
-	Common 
-	CtrMcast 
+  	aSRM
+	Common
+	CtrMcast
 	Diffusion
 	Encap
 	Flags
 	HttpInval
 	IMEP
 	IP
-        IPinIP 
+        IPinIP
 	IVS
 	LDP
 	LL
 	mcastCtrl
 	MFTP
 	MPLS
-	Mac 
+	Mac
 	Message
-        MIP 
+        MIP
 	Ping
+
 	PGM
 	PGM_SPM
 	PGM_NAK
-	RAP 
+	RAP
 	RTP
-	Resv 
+	Resv
 	rtProtoDV
 	rtProtoLS
 	SR
 	Src_rt
-  	SRM 
+  	SRM
   	SRMEXT
 	Snoop
 	TCP
@@ -152,7 +181,12 @@
 	TFRC_ACK
 	TORA
 	GAF
-	UMP 
+	UMP
+
+	# P.M. & P.B. modifications
+	RlcUmts
+ 	PhyUmts
+
 	Pushback
 	NV
 } {
diff -ur tcl/lib/ns-rtmodule.tcl ns-umts-extensions/code/ns-rtmodule.tcl
--- tcl/lib/ns-rtmodule.tcl	2002-05-31 23:11:31.000000000 +0000
+++ ns-umts-extensions/code/ns-rtmodule.tcl	2003-06-01 20:10:45.000000000 +0000
@@ -1,10 +1,39 @@
 # -*-	Mode:tcl; tcl-indent-level:8; tab-width:8; indent-tabs-mode:t -*-
 #
-#  Time-stamp: <2000-09-13 18:22:04 haoboy>
-# 
+# * Modified and extended by Pablo Martin and Paula Ballester,
+# * Strathclyde University, Glasgow.
+# * June, 2003.
+# *
+#
+# Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+# * All rights reserved.
+# *
+# * Redistribution and use in source and binary forms, with or without
+# * modification, are permitted provided that the following conditions
+# * are met:
+# *
+# * 1. Redistributions of source code and binary code must contain
+# * the above copyright notice, this list of conditions and the following
+# * disclaimer.
+# *
+# * 2. All advertising materials mentioning features or use of this software
+# * must display the following acknowledgement:
+# * This product includes software developed at Strathclyde University of
+# * Glasgow, Scotland.
+# *
+# * 3. The name of the University may not be used to endorse or promote
+# * products derived from this software without specific prior written
+# * permission.
+# * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+# * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+# * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+# * is provided "as is" without express or implied warranty of any kind.
+#
+
+#
 #  Copyright (c) 2000 by the University of Southern California
 #  All rights reserved.
-# 
+#
 #  Permission to use, copy, modify, and distribute this software and its
 #  documentation in source and binary forms for non-commercial purposes
 #  and without fee is hereby granted, provided that the above copyright
@@ -16,19 +45,19 @@
 #  Sciences Institute.  The name of the University may not be used to
 #  endorse or promote products derived from this software without
 #  specific prior written permission.
-# 
+#
 #  THE UNIVERSITY OF SOUTHERN CALIFORNIA makes no representations about
 #  the suitability of this software for any purpose.  THIS SOFTWARE IS
 #  PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
 #  INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-# 
+#
 #  Other copyrights might apply to parts of this software and are so
 #  noted when applicable.
-# 
+#
 #  $Header: /nfs/jade/vint/CVSROOT/ns-2/tcl/lib/ns-rtmodule.tcl,v 1.10 2002/05/31 23:11:31 haldar Exp $
 #
-# OTcl interface definition for the base routing module. They provide 
+# OTcl interface definition for the base routing module. They provide
 # linkage to Node, hence all derived classes should inherit these interfaces
 # and fill in their specific handling code.
 
@@ -109,10 +138,10 @@
 # Base routing module
 #
 
-# Use standard naming although this is a pure OTcl class 
+# Use standard naming although this is a pure OTcl class
 #
 # In fact, all functionalities of Base are already implemented in RtModule.
-# We add this class only to provide a uniform interface to the RtModule 
+# We add this class only to provide a uniform interface to the RtModule
 # creation process, where a single line [new RtModule/$name] is used.
 #
 # Defined in ~ns/rtmodule.{h,cc}
@@ -132,24 +161,24 @@
 
 #
 # Illustrates usage of insert-entry{}. However:
-# 
+#
 # XXX Ugly hack: We should keep all variables local to this particular
-# module. However, given all existing multicast code assumes that 
-# switch_ and multiclassifier_ are inside Node, we have to make this 
+# module. However, given all existing multicast code assumes that
+# switch_ and multiclassifier_ are inside Node, we have to make this
 # compromise if we do not want to modify all existing code. :(
 #
 RtModule/Mcast instproc register { node } {
 	$self next $node
 	$self instvar classifier_
-	
+
 	# Keep old classifier so we can use RtModule::add-route{}.
 	$self set classifier_ [$node entry]
-	
+
 	#if {[$classifier_ info class] != "Classifier/Virtual"} {
 	# donot want to add-route if virtual classifier
 	#$self attach-classifier $classifier_
 	#}
-	
+
 	$node set switch_ [new Classifier/Addr]
 
 	# Set up switch to route unicast packet to slot 0 and
@@ -160,7 +189,7 @@
 	# Create a classifier for multicast routing
 	$node set multiclassifier_ [new Classifier/Multicast/Replicator]
 	[$node set multiclassifier_] set node_ $node
-	
+
 	$node set mrtObject_ [new mrtObject $node]
 
 	# Install existing classifier at slot 0, new classifier at slot 1
@@ -169,7 +198,7 @@
 }
 
 #
-# Hierarchical routing module. 
+# Hierarchical routing module.
 #
 RtModule/Hier instproc register { node } {
 	$self next $node
@@ -201,7 +230,7 @@
 
 Classifier/Hier instproc clear args {
 	set l [llength $args]
-	[$self cmd classifier $l] clear [lindex $args [expr $l-1]] 
+	[$self cmd classifier $l] clear [lindex $args [expr $l-1]]
 }
 
 Classifier/Hier instproc install { dst target } {
@@ -215,6 +244,22 @@
 	[$self cmd classifier $l] install [lindex $al [expr $l-1]] $target
 }
 
+# P.M. & P.B. modifications
+#
+# Umts routing module.
+#
+
+RtModule/Umts instproc register { node } {
+	$self next $node
+	$self instvar classifier_
+	set classifier_ [new Classifier/Umts]
+	$classifier_ set mask_ [AddrParams NodeMask 1]
+	$classifier_ set shift_ [AddrParams NodeShift 1]
+	$classifier_ index $node
+	$classifier_ set id_ [$node id]
+	$classifier_ set type_ [$node nodetype]
+	$node install-entry $self $classifier_
+}
 
 #
 # Manual Routing Nodes:
@@ -222,7 +267,7 @@
 #
 RtModule/Manual instproc register { node } {
 	$self next $node
-	$self instvar classifier_	
+	$self instvar classifier_
 	# Note the very small hash size---
 	# you're supposed to resize it if you want more.
 	set classifier_ [new Classifier/Hash/Dest 2]
@@ -232,7 +277,7 @@
 }
 
 RtModule/Manual instproc add-route {dst_address target} {
-	$self instvar classifier_ 
+	$self instvar classifier_
 	set slot [$classifier_ installNext $target]
 	if {$dst_address == "default"} {
 		$classifier_ set default_ $slot
@@ -244,7 +289,7 @@
 }
 
 RtModule/Manual instproc add-route-to-adj-node { args } {
-	$self instvar classifier_ 
+	$self instvar classifier_
 
 	set dst ""
 	if {[lindex $args 0] == "-default"} {
@@ -318,7 +363,7 @@
 	$classifier_ set mask_ [AddrParams NodeMask 1]
 	$classifier_ set shift_ [AddrParams NodeShift 1]
 	$classifier_ nodeaddr [$node node-addr]
-	$node install-entry $self $classifier_ 
+	$node install-entry $self $classifier_
 }
 
 RtModule/VC instproc add-route { dst target } {
diff -ur tcl/rtglib/route-proto.tcl ns-umts-extensions/code/route-proto.tcl
--- tcl/rtglib/route-proto.tcl	2000-09-14 18:19:30.000000000 +0000
+++ ns-umts-extensions/code/route-proto.tcl	2003-06-01 20:10:45.000000000 +0000
@@ -1,3 +1,32 @@
+# * Modified and extended by Pablo Martin and Paula Ballester,
+# * Strathclyde University, Glasgow.
+# * June, 2003.
+# *
+#
+# Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+# * All rights reserved.
+# *
+# * Redistribution and use in source and binary forms, with or without
+# * modification, are permitted provided that the following conditions
+# * are met:
+# *
+# * 1. Redistributions of source code and binary code must contain
+# * the above copyright notice, this list of conditions and the following
+# * disclaimer.
+# *
+# * 2. All advertising materials mentioning features or use of this software
+# * must display the following acknowledgement:
+# * This product includes software developed at Strathclyde University of
+# * Glasgow, Scotland.
+# *
+# * 3. The name of the University may not be used to endorse or promote
+# * products derived from this software without specific prior written
+# * permission.
+# * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+# * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+# * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+# * is provided "as is" without express or implied warranty of any kind.
+#
 #
 #  Copyright (c) 1997 by the University of Southern California
 #  All rights reserved.
@@ -41,7 +70,7 @@
 rtObject set unreach_ -1
 rtObject set maxpref_   255
 
-# This may not be called by all routing agents. For instance, DV calls 
+# This may not be called by all routing agents. For instance, DV calls
 # this one but static does not. As a result, static routing does not have
 # rtObject on any node.
 rtObject proc init-all args {
@@ -102,6 +131,7 @@
     # choose the best route to each destination from all protocols
     $self instvar ns_ node_ rtProtos_ nullAgent_
     $self instvar nextHop_ rtpref_ metric_ rtVia_
+
     set protos ""
     set changes 0
     foreach p [array names rtProtos_] {
@@ -115,24 +145,59 @@
 
     set changes 0
     foreach dst [$ns_ all-nodes-list] {
+	# P.M. & P.B. modifications
 	if {$dst == $node_} continue
 	set nh ""
 	set pf [$class set maxpref_]
 	set mt [$class set unreach_]
 	set rv ""
+	# P.M. & P.B. modifications
+    	set prov 0
 	foreach p $protos {
 	    set pnh [$p set nextHop_($dst)]
 	    if { $pnh == "" } continue
-
 	    set ppf [$p set rtpref_($dst)]
 	    set pmt [$p set metric_($dst)]
-	    if {$ppf < $pf || ($ppf == $pf && $pmt < $mt) || $mt < 0} {
+	    # P.M. & P.B. modifications for UE destinations
+	    if {[$p dynamic?] == 1 && [$dst nodetype] == 1 && [$p set changed_($dst)] == 0} {
+		set prov 1
+		break
+	    }
+
+	    if {[$dst nodetype] == 1 && [$node_ nodetype] == 2} {
+		set nh  $pnh
+		set pf  $ppf
+		set mt  $pmt
+		set rv  $p
+
+		if {[$p dynamic?] == 1 && [$p set changed_($dst)] == 1 && [$node_ nodetype] == 2 && [set pnh] != [set nextHop_($dst)]} {
+			$p set changed_($dst) 0
+			set nextHop_($dst) $nh
+			set rtpref_($dst)  $pf
+			set metric_($dst)  $mt
+			set rtVia_($dst)   $rv
+			$node_ delete-routes [$dst id] $nextHop_($dst) $nullAgent_
+			set nextHop_($dst) $nh
+			$node_ add-routes [$dst id] $nextHop_($dst)
+			$p send-updates 1
+			return
+		} else {
+			set prov 1
+		}
+	    }
+	    if {$ppf < $pf || ($ppf == $pf && $pmt < $mt) || $mt < 0 || $nextHop_($dst) != $pnh} {
 		set nh  $pnh
 		set pf  $ppf
 		set mt  $pmt
 		set rv  $p
 	    }
+	    $p set changed_($dst) 0
+	}
+	# P.M. & P.B. modifications
+	if { $prov == 1 } {
+		continue
 	}
+
 	if { $nh == "" } {
 	    # no route...  delete any existing routes
 	    if { $nextHop_($dst) != "" } {
@@ -198,11 +263,36 @@
     $self flag-multicast $changes
 }
 
+
 rtObject instproc flag-multicast changes {
     $self instvar node_
     $node_ notify-mcast $changes
 }
 
+# P.M. & P.B. modifications
+rtObject instproc update-changed { destid entry } {
+   $self instvar ns_ node_ rtProtos_ nextHop_ nextHopPeer_ rtpref_ metric_
+   set changes 0
+   foreach dst [$ns_ all-nodes-list] {
+	if {$destid == [$dst id]} {
+		foreach p [array names rtProtos_] {
+			if {[$rtProtos_($p) dynamic?]} {
+				$rtProtos_($p) set nextHop_($dst) $entry
+				$rtProtos_($p) set metric_($dst) 0
+				$rtProtos_($p) set update_($dst) [clock clicks]
+			}
+		}
+		set nextHop_($dst) $entry
+		set metric_($dst)  0
+		incr changes
+		foreach proto [array names rtProtos_] {
+			$rtProtos_($proto) send-updates $changes
+		}
+	}
+   }
+}
+
+
 rtObject instproc intf-changed {} {
     $self instvar ns_ node_ rtProtos_ rtVia_ nextHop_ rtpref_ metric_
     foreach p [array names rtProtos_] {
@@ -274,7 +364,7 @@
     $self set metric_($dest)
 }
 
-#
+#
 Class rtPeer
 
 rtPeer instproc init {addr port cls} {
@@ -318,7 +408,8 @@
     return $rtpref_($dest)
 }
 
-#
+
+#
 #Class Agent/rtProto -superclass Agent
 
 Agent/rtProto proc pre-init-all args {
@@ -331,7 +422,7 @@
 
 Agent/rtProto instproc init node {
     $self next
-    
+
     $self instvar ns_ node_ rtObject_ preference_ ifs_ ifstat_
     set ns_ [Simulator instance]
 
@@ -363,6 +454,11 @@
     #NOTHING
 }
 
+# P.M. & P.B. modifications
+Agent/rtProto instproc dynamic? {} {
+    return 0
+}
+
 #
 # Static routing, the default
 #
@@ -388,7 +484,7 @@
     [Simulator instance] compute-routes
 }
 
-#
+#
 #########################################################################
 #
 # Code below this line is experimental, and should be considered work
@@ -465,6 +561,8 @@
     $self next $node
     $self instvar ns_ rtObject_ ifsUp_
     $self instvar preference_ rtpref_ nextHop_ nextHopPeer_ metric_ multiPath_
+    # P.M. & P.B. modifications
+    $self instvar update_ changed_
 
     set UNREACHABLE [$class set UNREACHABLE]
     foreach dest [$ns_ all-nodes-list] {
@@ -472,13 +570,22 @@
 	set nextHop_($dest) ""
 	set nextHopPeer_($dest) ""
 	set metric_($dest)  $UNREACHABLE
+	# P.M. & P.B. modifications
+	set changed_($dest) 0
+	set update_($dest) ""
     }
+
     set ifsUp_ ""
     set multiPath_ [[$rtObject_ set node_] set multiPath_]
     set updateTime [$rtglibRNG uniform 0.0 0.5]
     $ns_ at $updateTime "$self send-periodic-update"
 }
 
+# P.M. & P.B. modifications
+Agent/rtProto/DV instproc dynamic? {} {
+    return 1
+}
+
 Agent/rtProto/DV instproc add-peer {nbr agentAddr agentPort} {
     $self instvar peers_
     $self set peers_($nbr) [new rtPeer $agentAddr $agentPort $class]
@@ -488,15 +595,17 @@
     global rtglibRNG
 
     $self instvar ns_
-    $self send-updates 1	;# Anything but 0
-    set updateTime [expr [$ns_ now] + \
-	    ([$class set advertInterval] * [$rtglibRNG uniform 0.9 1.1])]
-    $ns_ at $updateTime "$self send-periodic-update"
+	$self send-updates 1	;# Anything but 0
+	set updateTime [expr [$ns_ now] + \
+		([$class set advertInterval] * [$rtglibRNG uniform 0.9 1.1])]
+	$ns_ at $updateTime "$self send-periodic-update"
 }
 
 Agent/rtProto/DV instproc compute-routes {} {
     $self instvar ns_ ifs_ rtpref_ metric_ nextHop_ nextHopPeer_
     $self instvar peers_ rtsChanged_ multiPath_
+    # P.M. & P.B. modifications
+    $self instvar changed_
 
     set INFINITY [$class set INFINITY]
     set MAXPREF  [rtObject set maxpref_]
@@ -504,7 +613,8 @@
     set rtsChanged_ 0
     foreach dst [$ns_ all-nodes-list] {
 	set p [lindex $nextHopPeer_($dst) 0]
-	if {$p != ""} {
+	# P.M. & P.B. modifications
+	if {$p != "" && [$dst nodetype] != 1} {
 	    set metric_($dst) [$p metric? $dst]
 	    set rtpref_($dst) [$p preference? $dst]
 	}
@@ -524,12 +634,28 @@
 	    #	if peer metric lower	set to latest values
 	    #	else peer metrics equal	append latest values
 
-	    if { $pmt < 0 || $pmt >= $INFINITY || $ppf > $pf || $pmt > $mt } \
+	    if { $pmt < 0 || $pmt >= $INFINITY || $ppf > $pf || $pmt > $mt } {
 		    continue
-	    if { $ppf < $pf || $pmt < $mt } {
+		    }
+	    # P.M. & P.B. modifications
+	    if { $ppf < $pf || $pmt < $mt || $changed_($dst) == 1} {
 		set pf $ppf
 		set mt $pmt
 		unset nh	;# because we must compute *new* next hops
+		if {$changed_($dst) == 1} {
+			set nh($ifs_($nbr)) $peers_($nbr)
+			if {$nextHop_($dst) != $ifs_($nbr)} {
+				set nh($ifs_($nbr)) $peers_($nbr)
+				set rtpref_($dst) $pf
+				set metric_($dst) $mt
+				set nextHop_($dst) ""
+				set nextHopPeer_($dst) ""
+				lappend nextHop_($dst) $ifs_($nbr)
+				lappend nextHopPeer_($dst) $nh($ifs_($nbr))
+				incr rtsChanged_
+				return
+			}
+		}
 	    }
 	    set nh($ifs_($nbr)) $peers_($nbr)
 	}
@@ -543,6 +669,7 @@
 	}
 
 	incr rtsChanged_
+
 	if { $pf < $rtpref_($dst) || $mt < $metric_($dst) } {
 	    set rtpref_($dst) $pf
 	    set metric_($dst) $mt
@@ -555,7 +682,7 @@
 	    }
 	    continue
 	}
-	
+
 	set rtpref_($dst) $pf
 	set metric_($dst) $mt
 	set newNextHop ""
@@ -614,8 +741,17 @@
     set ret
 }
 
+# P.M. & P.B. modifications
+Agent/rtProto/DV proc retrieve-msg-chan id {
+    set ret [Agent/rtProto/DV set msg_chan_($id)]
+    Agent/rtProto/DV unset msg_chan_($id)
+    set ret
+}
+
 Agent/rtProto/DV instproc send-updates changes {
     $self instvar peers_ ifs_ ifsUp_
+    # P.M. & P.B. modifications
+    $self instvar ns_ update_ node_
 
     if $changes {
 	set to-send-to [lsort -dictionary [array names peers_]]
@@ -628,10 +764,17 @@
 	    $self send-to-peer $nbr
 	}
     }
+    # P.M. & P.B. modifications
+    foreach dest [$ns_ all-nodes-list] {
+    	set changed_($dest) 0
+    }
 }
 
 Agent/rtProto/DV instproc send-to-peer nbr {
     $self instvar ns_ rtObject_ ifs_ peers_
+    # P.M. & P.B. modifications
+    $self instvar update_
+
     set INFINITY [$class set INFINITY]
     foreach dest [$ns_ all-nodes-list] {
 	set metric [$rtObject_ metric? $dest]
@@ -657,6 +800,12 @@
     set id [$class get-next-mid]
     $class set msg_($id) [array get update]
 
+    # P.M. & P.B. modifications
+    foreach dest [$ns_ all-nodes-list] {
+	    set upd($dest) [set update_($dest)]
+    }
+    $class set msg_chan_($id) [array get upd]
+
     # XXX Note the singularity below...
     $self send-update [$peers_($nbr) addr?] [$peers_($nbr) port?] $id [array size update]
 }
@@ -664,11 +813,18 @@
 Agent/rtProto/DV instproc recv-update {peerAddr id} {
     $self instvar peers_ ifs_ nextHopPeer_ metric_
     $self instvar rtsChanged_ rtObject_
+    # P.M. & P.B. modifications
+    $self instvar node_ update_ changed_
 
     set INFINITY [$class set INFINITY]
     set UNREACHABLE  [$class set UNREACHABLE]
     set msg [$class retrieve-msg $id]
     array set metrics $msg
+
+    # P.M. & P.B. modifications
+    set msg_chan [$class retrieve-msg-chan $id]
+    array set chan $msg_chan
+
     foreach nbr [lsort -dictionary [array names peers_]] {
 	if {[$peers_($nbr) addr?] == $peerAddr} {
 	    set peer $peers_($nbr)
@@ -677,15 +833,31 @@
 	    }
 	    set metricsChanged 0
 	    foreach dest [array names metrics] {
-                set metric [expr $metrics($dest) + [$ifs_($nbr) cost?]]
+		    set metric [expr $metrics($dest) + [$ifs_($nbr) cost?]]
+
 		if {$metric > $INFINITY} {
 		    set metric $INFINITY
 		}
+
 		if {$metric != [$peer metric? $dest]} {
 		    $peer metric $dest $metric
 		    incr metricsChanged
 		}
+		# P.M. & P.B. modifications, for UE destinations
+		if {[$dest nodetype] == 1} {
+			set c [set chan($dest)]
+			if {$c != ""} {
+				if {($update_($dest) != "" && $c > $update_($dest)) || $update_($dest) == ""} {
+					set changed_($dest) 1
+					set update_($dest) [set c]
+					incr metricsChanged
+					break
+				}
+			}
+		}
+
 	    }
+
 	    if $metricsChanged {
 		$self compute-routes
 		incr rtsChanged_ $metricsChanged
diff -ur trace/cmu-trace.cc ns-umts-extensions/code/cmu-trace.cc
--- trace/cmu-trace.cc	2002-09-12 00:22:01.000000000 +0000
+++ ns-umts-extensions/code/cmu-trace.cc	2003-06-01 20:10:45.000000000 +0000
@@ -1,4 +1,35 @@
 /* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
+ *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
 /*
  * Copyright (c) 1997 Regents of the University of California.
  * All rights reserved.
@@ -37,7 +68,7 @@
  * $Header: /nfs/jade/vint/CVSROOT/ns-2/trace/cmu-trace.cc,v 1.67 2002/09/12 00:22:01 buchheim Exp $
  */
 
-#include <packet.h>
+#include "packet.h"
 #include <ip.h>
 #include <tcp.h>
 #include <rtp.h>
@@ -51,6 +82,9 @@
 #include <aodv/aodv_packet.h> //AODV
 #include <cmu-trace.h>
 #include <mobilenode.h>
+// P.M. & P.B. modifications
+#include "rlc-umts.h"
+#include "phy-umts.h"
 
 #include "diffusion/diff_header.h" // DIFFUSION -- Chalermek
 
@@ -82,6 +116,10 @@
         else if(strcmp(tracename, "MAC") == 0) {
                 tracetype = TR_MAC;
         }
+	  // P.M. & P.B. modifications
+	  else if(strcmp(tracename, "PHY") == 0) {
+                tracetype = TR_PHY;
+        }
         else if(strcmp(tracename, "IFQ") == 0) {
                 tracetype = TR_IFQ;
         }
@@ -96,7 +134,7 @@
 	assert(type_ == DROP || type_ == SEND || type_ == RECV);
 
 	newtrace_ = 0;
-	for (int i=0 ; i < MAX_NODE ; i++) 
+	for (int i=0 ; i < MAX_NODE ; i++)
 		nodeColor[i] = 3 ;
         node_ = 0;
 }
@@ -108,7 +146,7 @@
 	struct hdr_ip *ih = HDR_IP(p);
 	struct hdr_mac802_11 *mh = HDR_MAC802_11(p);
 	double x = 0.0, y = 0.0, z = 0.0;
-       
+
 	char op = (char) type_;
 	Node* thisnode = Node::get_node_by_address(src_);
 	double energy = -1;
@@ -132,7 +170,7 @@
 	if (pt_->tagged()) {
 		int next_hop = -1 ;
 		Node* nextnode = Node::get_node_by_address(ch->next_hop_);
-        	if (nextnode) next_hop = nextnode->nodeid(); 
+        	if (nextnode) next_hop = nextnode->nodeid();
 
 		node_->getLoc(&x, &y, &z);
 
@@ -164,7 +202,7 @@
 
 	// Use new ns trace format to replace the old cmu trace format)
 	if (newtrace_) {
-	    
+
 	    node_->getLoc(&x, &y, &z);
 	    // consistence
 	    if ( op == DROP ) { op = 'd';}
@@ -189,13 +227,13 @@
 
 	    offset = strlen(pt_->buffer());
 
-	    sprintf(pt_->buffer() + offset, 
+	    sprintf(pt_->buffer() + offset,
 		    "-Ma %x -Md %x -Ms %x -Mt %x ",
 		    mh->dh_duration,
 		    ETHER_ADDR(mh->dh_da),
 		    ETHER_ADDR(mh->dh_sa),
 		    GET_ETHER_TYPE(mh->dh_body));
-		    
+
 	     return;
 	}
 
@@ -220,16 +258,16 @@
 #endif
 		tracename,
 		why,
-		
+
                 ch->uid(),                      // identifier for this event
-		
+
 		((ch->ptype() == PT_MAC) ? (
 		  (mh->dh_fc.fc_subtype == MAC_Subtype_RTS) ? "RTS"  :
 		  (mh->dh_fc.fc_subtype == MAC_Subtype_CTS) ? "CTS"  :
 		  (mh->dh_fc.fc_subtype == MAC_Subtype_ACK) ? "ACK"  :
 		  "UNKN"
 		  ) : packet_info.name(ch->ptype())),
-		
+
 		ch->size(),
 
 		//*((u_int16_t*) &mh->dh_fc),
@@ -249,12 +287,81 @@
         }
 }
 
+// P.M. & P.B. modifications
+void
+CMUTrace::format_phy(Packet *p, const char *why, int offset)
+{
+	struct hdr_cmn *ch = HDR_CMN(p);
+	struct hdr_ip *ih = HDR_IP(p);
+	struct hdr_phy *ph = HDR_PHY_UMTS(p);
+	double x = 0.0, y = 0.0, z = 0.0;
+
+	char op = (char) type_;
+	Node* thisnode = Node::get_node_by_address(src_);
+	double energy = -1;
+	if (thisnode) {
+	    if (thisnode->energy_model()) {
+		    energy = thisnode->energy_model()->energy();
+	    }
+	}
+
+	// hack the IP address to convert pkt format to hostid format
+	// for now until port ids are removed from IP address. -Padma.
+
+	int src = Address::instance().get_nodeaddr(ih->saddr());
+
+	if(tracetype == TR_ROUTER && type_ == SEND) {
+		if(src_ != src)
+			op = FWRD;
+	}
+
+	// Use new ns trace format to replace the old cmu trace format)
+	if (newtrace_) {
+
+	    node_->getLoc(&x, &y, &z);
+	    // consistence
+	    if ( op == DROP ) { op = 'd';}
+
+	    // basic trace infomation + basic exenstion
+
+	    sprintf(pt_->buffer() + offset,
+		   "%c -t %.9f -Hs %d -Hd %d -Ni %d -Nx %.2f -Ny %.2f -Nz %.2f -Ne %f -Nl %3s -Nw %s ",
+		    op,                       // event type
+		    Scheduler::instance().clock(),  // time
+		    src_,                           // this node
+                ch->next_hop_,                  // next hop
+		    src_,                           // this node
+		    x,                              // x coordinate
+		    y,                              // y coordinate
+		    z,                              // z coordinate
+		    energy,                         // energy, -1 = not existing
+		    tracename,                      // trace level
+                why);                            // reason
+
+	    // phy layer extension
+
+	    offset = strlen(pt_->buffer());
+
+	    sprintf(pt_->buffer() + offset,
+		    "-Phs %d -Phd %d -Phc %d -Php %e ",
+		    ph->sa_,
+		    ph->da_,
+		    ch->channel_t(),
+		    ph->rx_power_);
+
+	     return;
+	}
+	return;
+}
+
+
+
 void
 CMUTrace::format_ip(Packet *p, int offset)
 {
         struct hdr_cmn *ch = HDR_CMN(p);
 	struct hdr_ip *ih = HDR_IP(p);
-	
+
 	// hack the IP address to convert pkt format to hostid format
 	// for now until port ids are removed from IP address. -Padma.
 	int src = Address::instance().get_nodeaddr(ih->saddr());
@@ -352,7 +459,7 @@
 		    srh->down_links()[srh->num_route_errors() - 1].to_addr);
 	    return;
 	} else if (newtrace_) {
-	    sprintf(pt_->buffer() + offset, 
+	    sprintf(pt_->buffer() + offset,
 		"-P dsr -Ph %d -Pq %d -Ps %d -Pp %d -Pn %d -Pl %d -Pe %d->%d -Pw %d -Pm %d -Pc %d -Pb %d->%d ",
 		    srh->num_addrs(),                   // how many nodes travered
 
@@ -374,7 +481,7 @@
 
 	   return;
 	}
-	sprintf(pt_->buffer() + offset, 
+	sprintf(pt_->buffer() + offset,
 		"%d [%d %d] [%d %d %d %d->%d] [%d %d %d %d->%d]",
 		srh->num_addrs(),
 
@@ -405,7 +512,7 @@
 {
 	struct hdr_cmn *ch = HDR_CMN(p);
 	struct hdr_tcp *th = HDR_TCP(p);
-	
+
 	if (pt_->tagged()) {
 	    sprintf(pt_->buffer() + offset,
 		    "-tcp:s %d -tcp:a %d -tcp:f %d -tcp:o %d ",
@@ -439,12 +546,12 @@
 	struct hdr_ip *ih = HDR_IP(p);
         Node* thisnode = Node::get_node_by_address(src_);
 
-	//hacking, needs to change later, 
+	//hacking, needs to change later,
         int dst = Address::instance().get_nodeaddr(ih->daddr());
-	
+
 	if (dst == src_){
 		// I just received a cbr data packet
-		if (thisnode->energy_model() && 
+		if (thisnode->energy_model() &&
 		    thisnode->energy_model()->powersavingflag()) {
 			thisnode->energy_model()->set_node_state(EnergyModel::INROUTE);
 		}
@@ -578,7 +685,7 @@
                             ch->tc_tau,
                             ch->tc_oid);
 		} else if (newtrace_) {
-		    sprintf(pt_->buffer() + offset, 
+		    sprintf(pt_->buffer() + offset,
 			"-P tora -Pt 0x%x -Pd %d -Pa %f -Po %d -Pc CLEAR ",
                         ch->tc_type,
                         ch->tc_dst,
@@ -648,7 +755,7 @@
         case AODVTYPE_RREP:
         case AODVTYPE_HELLO:
 	case AODVTYPE_RERR:
-		
+
 		if (pt_->tagged()) {
 		    sprintf(pt_->buffer() + offset,
 			    "-aodv:t %x -aodv:h %d -aodv:d %d -adov:ds %d "
@@ -662,7 +769,7 @@
 			    (rp->rp_type == AODVTYPE_RERR ? "ERROR" :
 			     "HELLO"));
 		} else if (newtrace_) {
-			
+
 			sprintf(pt_->buffer() + offset,
 			    "-P aodv -Pt 0x%x -Ph %d -Pd %d -Pds %d -Pl %f -Pc %s ",
 				rp->rp_type,
@@ -674,7 +781,7 @@
 				(rp->rp_type == AODVTYPE_RERR ? "ERROR" :
 				 "HELLO"));
 	        } else {
-			
+
 			sprintf(pt_->buffer() + offset,
 				"[0x%x %d [%d %d] %f] (%s)",
 				rp->rp_type,
@@ -687,7 +794,7 @@
 				 "HELLO"));
 		}
                 break;
-		
+
         default:
 #ifdef WIN32
                 fprintf(stderr,
@@ -712,30 +819,45 @@
 	char colors[32];
 	int next_hop = -1 ;
 
-        int dst = Address::instance().get_nodeaddr(ih->daddr());
+	  int dst = Address::instance().get_nodeaddr(ih->daddr());
 
 	nextnode = Node::get_node_by_address(ch->next_hop_);
-        if (nextnode) next_hop = nextnode->nodeid(); 
+        if (nextnode) next_hop = nextnode->nodeid();
 
 	srcnode = Node::get_node_by_address(src_);
 	dstnode = Node::get_node_by_address(ch->next_hop_);
 
 	double distance = 0;
 
-        if ((srcnode) && (dstnode)) {
+
+	if ((srcnode) && (dstnode)) {
 	   MobileNode* tmnode = (MobileNode*)srcnode;
 	   MobileNode* rmnode = (MobileNode*)dstnode;
 
+	  	// P.M. & P.B. modifications
+		Tcl& tcl1 = Tcl::instance();
+		tcl1.evalf("%s nodetype", tmnode->name());
+		char* ni1 = tcl1.result();
+		if (atoi(ni1) == 0)
+			goto GO;
+
+		tcl1.evalf("%s nodetype", rmnode->name());
+		ni1 = tcl1.result();
+		if (atoi(ni1) == 0)
+			goto GO;
+
 	   distance = tmnode->propdelay(rmnode) * 300000000 ;
 	}
 
+GO:
+
 	double energy = -1;
 	double initenergy = -1;
 
 	//default value for changing node color with respect to energy depletion
-	double l1 = 0.5; 
+	double l1 = 0.5;
 	double l2 = 0.2;
-	
+
 	if (srcnode) {
 	    if (srcnode->energy_model()) {
 		    energy = srcnode->energy_model()->energy();
@@ -748,17 +870,17 @@
         int energyLevel = 0 ;
         double energyLeft = (double)(energy/initenergy) ;
 
-        if ((energyLeft <= 1 ) && (energyLeft >= l1 )) energyLevel = 3;	
-        if ((energyLeft >= l2 ) && (energyLeft < l1 )) energyLevel = 2;	
-        if ((energyLeft > 0 ) && (energyLeft < l2 )) energyLevel = 1;	
+        if ((energyLeft <= 1 ) && (energyLeft >= l1 )) energyLevel = 3;
+        if ((energyLeft >= l2 ) && (energyLeft < l1 )) energyLevel = 2;
+        if ((energyLeft > 0 ) && (energyLeft < l2 )) energyLevel = 1;
 
-	if (energyLevel == 0) 
+	if (energyLevel == 0)
 		strcpy(colors,"-c black -o red");
-        else if (energyLevel == 1) 
+        else if (energyLevel == 1)
 		strcpy(colors,"-c red -o yellow");
-        else if (energyLevel == 2) 
+        else if (energyLevel == 2)
 		strcpy(colors,"-c yellow -o green");
-        else if (energyLevel == 3) 
+        else if (energyLevel == 3)
 		strcpy(colors,"-c green -o black");
 
 	// A simple hack for scadds demo (fernandez's visit) -- Chalermek
@@ -769,7 +891,19 @@
 			pkt_color = 1;
 		}
 	}
-	// convert to nam format 
+	// P.M. & P.B. modifications
+	if (ch->ptype() == PT_ACK)
+		pkt_color = ih->flowid();
+	else pkt_color = 0;
+
+	// P.M. & P.B. modifications, for better visualisation
+	int temp = ch->size_;
+	if (ch->ptype() == PT_ACK)
+		ch->size_=100;
+	else
+		ch->size_=320;
+
+	// convert to nam format
 	if (op == 's') op = 'h' ;
 	if (op == 'D') op = 'd' ;
 	if (op == 'h') {
@@ -780,12 +914,13 @@
 		next_hop,
 		packet_info.name(ch->ptype()),
 		ch->size(),
-		pkt_color,   
+		pkt_color,
 		ch->uid(),
 		tracename);
 
 	   offset = strlen(pt_->nbuffer());
 	   pt_->namdump();
+
 	   sprintf(pt_->nbuffer() ,
 		"- -t %.9f -s %d -d %d -p %s -e %d -c 2 -a %d -i %d -k %3s",
 		Scheduler::instance().clock(),
@@ -804,7 +939,7 @@
         // if nodes are too far from each other
 	// nam won't dump SEND event 'cuz it's
 	// gonna be dropped later anyway
-	// this value 250 is pre-calculated by using 
+	// this value 250 is pre-calculated by using
 	// two-ray ground refelction model with fixed
 	// transmission power 3.652e-10
 //	if ((type_ == SEND)  && (distance > 250 )) return ;
@@ -813,8 +948,9 @@
 	if(type_ == RECV && dst == -1 )dst = src_ ; //broadcasting event
 
         if (energy != -1) { //energy model being turned on
-	   if (nodeColor[src_] != energyLevel ) { //only dump it when node  
-	       sprintf(pt_->nbuffer() ,                    //color change
+	   if (nodeColor[src_] != energyLevel ) { //only dump it when node
+
+		 sprintf(pt_->nbuffer() ,                    //color change
 	          "n -t %.9f -s %d -S COLOR %s",
 	           Scheduler::instance().clock(),
 	           src_,                           // this node
@@ -822,7 +958,7 @@
                offset = strlen(pt_->nbuffer());
                pt_->namdump();
 	       nodeColor[src_] = energyLevel ;
-	    }   
+	    }
         }
 
 	sprintf(pt_->nbuffer() ,
@@ -839,6 +975,9 @@
 
 	offset = strlen(pt_->nbuffer());
 	pt_->namdump();
+
+	// P.M. & P.B. modifications
+	ch->size_= temp;
 }
 
 void CMUTrace::format(Packet* p, const char *why)
@@ -846,12 +985,23 @@
 	hdr_cmn *ch = HDR_CMN(p);
 	int offset = 0;
 
+      // P.M. & P.B. modifications
+	if (ch->next_hop() == -2) {
+		return;
+	}
+
+	// P.M. & P.B. modifications
+	/*
+	 * Log the PHY Header
+	 */
+	format_phy(p, why, offset);
+
 	/*
 	 * Log the MAC Header
 	 */
-	format_mac(p, why, offset);
+//	format_mac(p, why, offset);
 
-	if (pt_->namchannel()) 
+	if (pt_->namchannel())
 		nam_format(p, offset);
 	offset = strlen(pt_->buffer());
 	switch(ch->ptype()) {
@@ -889,8 +1039,19 @@
 			break;
 	        case PT_DIFF:
 			break;
+		// P.M. & P.B. modifications
+		case PT_RTPROTO_DV:
+			break;
+		case PT_EXP:
+ 			format_rtp(p, offset);
+ 			break;
 		case PT_GAF:
 			break;
+		// P.M. & P.B. modifications
+		case PT_PREAMBLE:
+			break;
+		case PT_RRC_FAILURE:
+			break;
 		default:
 			fprintf(stderr, "%s - invalid packet type (%s).\n",
 				__PRETTY_FUNCTION__, packet_info.name(ch->ptype()));
@@ -902,7 +1063,7 @@
 int
 CMUTrace::command(int argc, const char*const* argv)
 {
-	
+
         if(argc == 3) {
                 if(strcmp(argv[1], "node") == 0) {
                         node_ = (MobileNode*) TclObject::lookup(argv[2]);
@@ -927,7 +1088,8 @@
 		return;
 	}
         assert(initialized());
-        /*
+
+	  /*
          * Agent Trace "stamp" the packet with the optimal route on
          * sending.
          */
@@ -956,7 +1118,7 @@
 void
 CMUTrace::recv(Packet *p, const char* why)
 {
-        assert(initialized() && type_ == DROP);
+	  assert(initialized() && type_ == DROP);
 	if (!node_energy()) {
 		Packet::free(p);
 		return;
@@ -985,7 +1147,7 @@
 		if (thisnode->energy_model()) {
 			energy = thisnode->energy_model()->energy();
 		}
-	} 
+	}
 	if (energy > 0) return 1;
 	return 0;
 }
diff -ur trace/cmu-trace.h ns-umts-extensions/code/cmu-trace.h
--- trace/cmu-trace.h	2002-09-17 18:27:02.000000000 +0000
+++ ns-umts-extensions/code/cmu-trace.h	2003-06-01 20:10:45.000000000 +0000
@@ -1,5 +1,36 @@
-/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-
+/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+
+/* Modified and extended by Pablo Martin and Paula Ballester,
+ * Strathclyde University, Glasgow.
+ * June, 2003.
+*/
+
+/* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code and binary code must contain
+ * the above copyright notice, this list of conditions and the following
+ * disclaimer.
  *
+ * 2. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Strathclyde University of
+ * Glasgow, Scotland.
+ *
+ * 3. The name of the University may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS
+ * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE
+ * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software
+ * is provided "as is" without express or implied warranty of any kind.
+*/
+
+/*
  * Copyright (c) 1997 Regents of the University of California.
  * All rights reserved.
  *
@@ -58,6 +89,8 @@
 #define TR_MAC		0x02
 #define TR_IFQ		0x04
 #define TR_AGENT	0x08
+// P.M. & P.B. modifications
+#define TR_PHY 0x10
 
 #define DROP_END_OF_SIMULATION		"END"
 #define	DROP_MAC_COLLISION		"COL"
@@ -107,6 +140,8 @@
         void    nam_format(Packet *p, int offset);
 
 	void	format_mac(Packet *p, const char *why, int offset);
+	// P.M. & P.B. modifications
+	void	format_phy(Packet *p, const char *why, int offset);
 	void	format_ip(Packet *p, int offset);
 
 	void	format_arp(Packet *p, int offset);
