Index: pjproject/branches/projects/sipit24/pjnath/src/pjnath-test/ice_test.c
===================================================================
--- pjproject/branches/projects/sipit24/pjnath/src/pjnath-test/ice_test.c	(revision 2709)
+++ pjproject/branches/projects/sipit24/pjnath/src/pjnath-test/ice_test.c	(revision 2710)
@@ -65,4 +65,6 @@
 
     struct test_result expected;/* Expected result		*/
+
+    pj_bool_t   nom_regular;	/* Use regular nomination?	*/
 };
 
Index: pjproject/branches/projects/sipit24/pjsip/include/pjsip/sip_config.h
===================================================================
--- pjproject/branches/projects/sipit24/pjsip/include/pjsip/sip_config.h	(revision 2709)
+++ pjproject/branches/projects/sipit24/pjsip/include/pjsip/sip_config.h	(revision 2710)
@@ -228,4 +228,19 @@
 
 /**
+ * RFC 3261 section 18.1.1:
+ * If a request is within 200 bytes of the path MTU, or if it is larger
+ * than 1300 bytes and the path MTU is unknown, the request MUST be sent
+ * using an RFC 2914 [43] congestion controlled transport protocol, such
+ * as TCP.
+ *
+ * This setting controls the threshold of the UDP packet, which if it's
+ * larger than this value the request will be sent with TCP. Default is
+ * 1300 bytes.
+ */
+#ifndef PJSIP_UDP_SIZE_THRESHOLD
+#   define PJSIP_UDP_SIZE_THRESHOLD	1300
+#endif
+
+/**
  * Encode SIP headers in their short forms to reduce size. By default,
  * SIP headers in outgoing messages will be encoded in their full names. 
Index: pjproject/branches/projects/sipit24/pjsip/include/pjsip/sip_transport.h
===================================================================
--- pjproject/branches/projects/sipit24/pjsip/include/pjsip/sip_transport.h	(revision 2709)
+++ pjproject/branches/projects/sipit24/pjsip/include/pjsip/sip_transport.h	(revision 2710)
@@ -579,4 +579,15 @@
  */
 PJ_DECL(pj_status_t) pjsip_tx_data_dec_ref( pjsip_tx_data *tdata );
+
+/**
+ * Print the SIP message to transmit data buffer's internal buffer. This
+ * may allocate memory for the buffer, if the buffer has not been allocated
+ * yet, and encode the SIP message to that buffer.
+ *
+ * @param tdata	    The transmit buffer.
+ *
+ * @return	    PJ_SUCCESS on success of the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjsip_tx_data_encode(pjsip_tx_data *tdata);
 
 /**
Index: pjproject/branches/projects/sipit24/pjsip/src/pjsip/sip_transaction.c
===================================================================
--- pjproject/branches/projects/sipit24/pjsip/src/pjsip/sip_transaction.c	(revision 2709)
+++ pjproject/branches/projects/sipit24/pjsip/src/pjsip/sip_transaction.c	(revision 2710)
@@ -1726,4 +1726,17 @@
 		      pjsip_tx_data_get_info(send_state->tdata), -sent,
 		      pj_strerror(-sent, errmsg, sizeof(errmsg)).ptr));
+
+	    /* Reset retransmission count */
+	    tsx->retransmit_count = 0;
+
+	    /* And reset timeout timer */
+	    if (tsx->timeout_timer.id) {
+		pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer);
+		tsx->timeout_timer.id = TIMER_INACTIVE;
+
+		tsx->timeout_timer.id = TIMER_ACTIVE;
+		pjsip_endpt_schedule_timer( tsx->endpt, &tsx->timeout_timer, 
+					    &timeout_timer_val);
+	    }
 	}
     }
Index: pjproject/branches/projects/sipit24/pjsip/src/pjsip/sip_transport.c
===================================================================
--- pjproject/branches/projects/sipit24/pjsip/src/pjsip/sip_transport.c	(revision 2709)
+++ pjproject/branches/projects/sipit24/pjsip/src/pjsip/sip_transport.c	(revision 2710)
@@ -435,4 +435,43 @@
 }
 
+/*
+ * Print the SIP message to transmit data buffer's internal buffer.
+ */
+PJ_DEF(pj_status_t) pjsip_tx_data_encode(pjsip_tx_data *tdata)
+{
+    /* Allocate buffer if necessary. */
+    if (tdata->buf.start == NULL) {
+	PJ_USE_EXCEPTION;
+
+	PJ_TRY {
+	    tdata->buf.start = (char*) 
+			       pj_pool_alloc(tdata->pool, PJSIP_MAX_PKT_LEN);
+	}
+	PJ_CATCH_ANY {
+	    return PJ_ENOMEM;
+	}
+	PJ_END
+
+	tdata->buf.cur = tdata->buf.start;
+	tdata->buf.end = tdata->buf.start + PJSIP_MAX_PKT_LEN;
+    }
+
+    /* Do we need to reprint? */
+    if (!pjsip_tx_data_is_valid(tdata)) {
+	pj_ssize_t size;
+
+	size = pjsip_msg_print( tdata->msg, tdata->buf.start, 
+			        tdata->buf.end - tdata->buf.start);
+	if (size < 0) {
+	    return PJSIP_EMSGTOOLONG;
+	}
+	pj_assert(size != 0);
+	tdata->buf.cur[size] = '\0';
+	tdata->buf.cur += size;
+    }
+
+    return PJ_SUCCESS;
+}
+
 PJ_DEF(pj_bool_t) pjsip_tx_data_is_valid( pjsip_tx_data *tdata )
 {
@@ -568,36 +607,5 @@
 static pj_status_t mod_on_tx_msg(pjsip_tx_data *tdata)
 {
-    /* Allocate buffer if necessary. */
-    if (tdata->buf.start == NULL) {
-	PJ_USE_EXCEPTION;
-
-	PJ_TRY {
-	    tdata->buf.start = (char*) 
-			       pj_pool_alloc(tdata->pool, PJSIP_MAX_PKT_LEN);
-	}
-	PJ_CATCH_ANY {
-	    return PJ_ENOMEM;
-	}
-	PJ_END
-
-	tdata->buf.cur = tdata->buf.start;
-	tdata->buf.end = tdata->buf.start + PJSIP_MAX_PKT_LEN;
-    }
-
-    /* Do we need to reprint? */
-    if (!pjsip_tx_data_is_valid(tdata)) {
-	pj_ssize_t size;
-
-	size = pjsip_msg_print( tdata->msg, tdata->buf.start, 
-			        tdata->buf.end - tdata->buf.start);
-	if (size < 0) {
-	    return PJSIP_EMSGTOOLONG;
-	}
-	pj_assert(size != 0);
-	tdata->buf.cur[size] = '\0';
-	tdata->buf.cur += size;
-    }
-
-    return PJ_SUCCESS;
+    return pjsip_tx_data_encode(tdata);
 }
 
Index: pjproject/branches/projects/sipit24/pjsip/src/pjsip/sip_util.c
===================================================================
--- pjproject/branches/projects/sipit24/pjsip/src/pjsip/sip_util.c	(revision 2709)
+++ pjproject/branches/projects/sipit24/pjsip/src/pjsip/sip_util.c	(revision 2710)
@@ -1136,4 +1136,6 @@
 	via->rport_param = 0;
 
+	pjsip_tx_data_invalidate_msg(tdata);
+
 	/* Send message using this transport. */
 	status = pjsip_transport_send( stateless_data->cur_transport,
@@ -1192,10 +1194,21 @@
 	addr->entry[0].type == PJSIP_TRANSPORT_UDP)
     {
-	char buf[1500];
 	int len;
 
+	/* Encode the request */
+	status = pjsip_tx_data_encode(stateless_data->tdata);
+	if (status != PJ_SUCCESS) {
+	    if (stateless_data->app_cb) {
+		pj_bool_t cont = PJ_FALSE;
+		(*stateless_data->app_cb)(stateless_data, -status, &cont);
+	    }
+	    pjsip_tx_data_dec_ref(stateless_data->tdata);
+	    return;
+	}
+
 	/* Check if request message is larger than 1300 bytes. */
-	len = pjsip_msg_print(stateless_data->tdata->msg, buf, 1300);
-	if (len < 0) {
+	len = stateless_data->tdata->buf.end - 
+		stateless_data->tdata->buf.start;
+	if (len >= PJSIP_UDP_SIZE_THRESHOLD) {
 	    int i;
 	    int count = stateless_data->addr.count;
