diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
new file mode 100644
index 0000000..0f9b709
--- /dev/null
+++ b/src/vnet/tcp/tcp.c
@@ -0,0 +1,708 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/tcp/tcp.h>
+#include <vnet/session/session.h>
+#include <vnet/fib/fib.h>
+#include <math.h>
+
+tcp_main_t tcp_main;
+
+static u32
+tcp_connection_bind (vlib_main_t * vm, u32 session_index, ip46_address_t * ip,
+		     u16 port_host_byte_order, u8 is_ip4)
+{
+  tcp_main_t *tm = &tcp_main;
+  tcp_connection_t *listener;
+
+  pool_get (tm->listener_pool, listener);
+  memset (listener, 0, sizeof (*listener));
+
+  listener->c_c_index = listener - tm->listener_pool;
+  listener->c_lcl_port = clib_host_to_net_u16 (port_host_byte_order);
+
+  if (is_ip4)
+    listener->c_lcl_ip4.as_u32 = ip->ip4.as_u32;
+  else
+    clib_memcpy (&listener->c_lcl_ip6, &ip->ip6, sizeof (ip6_address_t));
+
+  listener->c_s_index = session_index;
+  listener->c_proto = SESSION_TYPE_IP4_TCP;
+  listener->state = TCP_STATE_LISTEN;
+  listener->c_is_ip4 = 1;
+
+  return listener->c_c_index;
+}
+
+u32
+tcp_session_bind_ip4 (vlib_main_t * vm, u32 session_index,
+		      ip46_address_t * ip, u16 port_host_byte_order)
+{
+  return tcp_connection_bind (vm, session_index, ip, port_host_byte_order, 1);
+}
+
+u32
+tcp_session_bind_ip6 (vlib_main_t * vm, u32 session_index,
+		      ip46_address_t * ip, u16 port_host_byte_order)
+{
+  return tcp_connection_bind (vm, session_index, ip, port_host_byte_order, 0);
+
+}
+
+static void
+tcp_session_unbind (u32 listener_index)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  pool_put_index (tm->listener_pool, listener_index);
+}
+
+u32
+tcp_session_unbind_ip4 (vlib_main_t * vm, u32 listener_index)
+{
+  tcp_session_unbind (listener_index);
+  return 0;
+}
+
+u32
+tcp_session_unbind_ip6 (vlib_main_t * vm, u32 listener_index)
+{
+  tcp_session_unbind (listener_index);
+  return 0;
+}
+
+transport_connection_t *
+tcp_session_get_listener (u32 listener_index)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  tcp_connection_t *tc;
+  tc = pool_elt_at_index (tm->listener_pool, listener_index);
+  return &tc->connection;
+}
+
+/**
+ * Cleans up connection state.
+ *
+ * No notifications.
+ */
+void
+tcp_connection_cleanup (tcp_connection_t * tc)
+{
+  tcp_main_t *tm = &tcp_main;
+  u32 tepi;
+  transport_endpoint_t *tep;
+
+  /* Cleanup local endpoint if this was an active connect */
+  tepi = transport_endpoint_lookup (&tm->local_endpoints_table, &tc->c_lcl_ip,
+				    tc->c_lcl_port);
+
+  /*XXX lock */
+  if (tepi != TRANSPORT_ENDPOINT_INVALID_INDEX)
+    {
+      tep = pool_elt_at_index (tm->local_endpoints, tepi);
+      transport_endpoint_table_del (&tm->local_endpoints_table, tep);
+      pool_put (tm->local_endpoints, tep);
+    }
+
+  /* Make sure all timers are cleared */
+  tcp_connection_timers_reset (tc);
+
+  /* Check if half-open */
+  if (tc->state == TCP_STATE_SYN_SENT)
+    pool_put (tm->half_open_connections, tc);
+  else
+    pool_put (tm->connections[tc->c_thread_index], tc);
+}
+
+/**
+ * Connection removal.
+ *
+ * This should be called only once connection enters CLOSED state. Note
+ * that it notifies the session of the removal event, so if the goal is to
+ * just remove the connection, call tcp_connection_cleanup instead.
+ */
+void
+tcp_connection_del (tcp_connection_t * tc)
+{
+  stream_session_delete_notify (&tc->connection);
+  tcp_connection_cleanup (tc);
+}
+
+/**
+ * Begin connection closing procedure.
+ *
+ * If at the end the connection is not in CLOSED state, it is not removed.
+ * Instead, we rely on on TCP to advance through state machine to either
+ * 1) LAST_ACK (passive close) whereby when the last ACK is received
+ * tcp_connection_del is called. This notifies session of the delete and
+ * calls cleanup.
+ * 2) TIME_WAIT (active close) whereby after 2MSL the 2MSL timer triggers
+ * and cleanup is called.
+ */
+void
+tcp_connection_close (tcp_connection_t * tc)
+{
+  /* Send FIN if needed */
+  if (tc->state == TCP_STATE_ESTABLISHED || tc->state == TCP_STATE_SYN_RCVD
+      || tc->state == TCP_STATE_CLOSE_WAIT)
+    tcp_send_fin (tc);
+
+  /* Switch state */
+  if (tc->state == TCP_STATE_ESTABLISHED || tc->state == TCP_STATE_SYN_RCVD)
+    tc->state = TCP_STATE_FIN_WAIT_1;
+  else if (tc->state == TCP_STATE_SYN_SENT)
+    tc->state = TCP_STATE_CLOSED;
+  else if (tc->state == TCP_STATE_CLOSE_WAIT)
+    tc->state = TCP_STATE_LAST_ACK;
+
+  /* Half-close connections are not supported XXX */
+
+  if (tc->state == TCP_STATE_CLOSED)
+    tcp_connection_del (tc);
+}
+
+void
+tcp_session_close (u32 conn_index, u32 thread_index)
+{
+  tcp_connection_t *tc;
+  tc = tcp_connection_get (conn_index, thread_index);
+  tcp_connection_close (tc);
+}
+
+void
+tcp_session_cleanup (u32 conn_index, u32 thread_index)
+{
+  tcp_connection_t *tc;
+  tc = tcp_connection_get (conn_index, thread_index);
+  tcp_connection_cleanup (tc);
+}
+
+void *
+ip_interface_get_first_ip (u32 sw_if_index, u8 is_ip4)
+{
+  ip_lookup_main_t *lm4 = &ip4_main.lookup_main;
+  ip_lookup_main_t *lm6 = &ip6_main.lookup_main;
+  ip_interface_address_t *ia = 0;
+
+  if (is_ip4)
+    {
+      /* *INDENT-OFF* */
+      foreach_ip_interface_address (lm4, ia, sw_if_index, 1 /* unnumbered */ ,
+      ({
+        return ip_interface_address_get_address (lm4, ia);
+      }));
+      /* *INDENT-ON* */
+    }
+  else
+    {
+      /* *INDENT-OFF* */
+      foreach_ip_interface_address (lm6, ia, sw_if_index, 1 /* unnumbered */ ,
+      ({
+        return ip_interface_address_get_address (lm6, ia);
+      }));
+      /* *INDENT-ON* */
+    }
+
+  return 0;
+}
+
+/**
+ * Allocate local port and add if successful add entry to local endpoint
+ * table to mark the pair as used.
+ */
+u16
+tcp_allocate_local_port (tcp_main_t * tm, ip46_address_t * ip)
+{
+  u8 unique = 0;
+  transport_endpoint_t *tep;
+  u32 time_now, tei;
+  u16 min = 1024, max = 65535, tries;	/* XXX configurable ? */
+
+  tries = max - min;
+  time_now = tcp_time_now ();
+
+  /* Start at random point or max */
+  pool_get (tm->local_endpoints, tep);
+  clib_memcpy (&tep->ip, ip, sizeof (*ip));
+  tep->port = random_u32 (&time_now) << 16;
+  tep->port = tep->port < min ? max : tep->port;
+
+  /* Search for first free slot */
+  while (tries)
+    {
+      tei = transport_endpoint_lookup (&tm->local_endpoints_table, &tep->ip,
+				       tep->port);
+      if (tei == TRANSPORT_ENDPOINT_INVALID_INDEX)
+	{
+	  unique = 1;
+	  break;
+	}
+
+      tep->port--;
+
+      if (tep->port < min)
+	tep->port = max;
+
+      tries--;
+    }
+
+  if (unique)
+    {
+      transport_endpoint_table_add (&tm->local_endpoints_table, tep,
+				    tep - tm->local_endpoints);
+
+      return tep->port;
+    }
+
+  /* Failed */
+  pool_put (tm->local_endpoints, tep);
+  return -1;
+}
+
+/**
+ * Initialize all connection timers as invalid
+ */
+void
+tcp_connection_timers_init (tcp_connection_t * tc)
+{
+  int i;
+
+  /* Set all to invalid */
+  for (i = 0; i < TCP_N_TIMERS; i++)
+    {
+      tc->timers[i] = TCP_TIMER_HANDLE_INVALID;
+    }
+
+  tc->rto = TCP_RTO_INIT;
+}
+
+/**
+ * Stop all connection timers
+ */
+void
+tcp_connection_timers_reset (tcp_connection_t * tc)
+{
+  int i;
+  for (i = 0; i < TCP_N_TIMERS; i++)
+    {
+      tcp_timer_reset (tc, i);
+    }
+}
+
+/** Initialize tcp connection variables
+ *
+ * Should be called after having received a msg from the peer, i.e., a SYN or
+ * a SYNACK, such that connection options have already been exchanged. */
+void
+tcp_connection_init_vars (tcp_connection_t * tc)
+{
+  tcp_connection_timers_init (tc);
+  tcp_set_snd_mss (tc);
+  tc->sack_sb.head = TCP_INVALID_SACK_HOLE_INDEX;
+  tcp_cc_init (tc);
+}
+
+int
+tcp_connection_open (ip46_address_t * rmt_addr, u16 rmt_port, u8 is_ip4)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  tcp_connection_t *tc;
+  fib_prefix_t prefix;
+  u32 fei, sw_if_index;
+  ip46_address_t lcl_addr;
+  u16 lcl_port;
+
+  /*
+   * Find the local address and allocate port
+   */
+  memset (&lcl_addr, 0, sizeof (lcl_addr));
+
+  /* Find a FIB path to the destination */
+  clib_memcpy (&prefix.fp_addr, rmt_addr, sizeof (*rmt_addr));
+  prefix.fp_proto = is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
+  prefix.fp_len = is_ip4 ? 32 : 128;
+
+  fei = fib_table_lookup (0, &prefix);
+
+  /* Couldn't find route to destination. Bail out. */
+  if (fei == FIB_NODE_INDEX_INVALID)
+    return -1;
+
+  sw_if_index = fib_entry_get_resolving_interface (fei);
+
+  if (sw_if_index == (u32) ~ 0)
+    return -1;
+
+  if (is_ip4)
+    {
+      ip4_address_t *ip4;
+      ip4 = ip_interface_get_first_ip (sw_if_index, 1);
+      lcl_addr.ip4.as_u32 = ip4->as_u32;
+    }
+  else
+    {
+      ip6_address_t *ip6;
+      ip6 = ip_interface_get_first_ip (sw_if_index, 0);
+      clib_memcpy (&lcl_addr.ip6, ip6, sizeof (*ip6));
+    }
+
+  /* Allocate source port */
+  lcl_port = tcp_allocate_local_port (tm, &lcl_addr);
+  if (lcl_port < 1)
+    return -1;
+
+  /*
+   * Create connection and send SYN
+   */
+
+  pool_get (tm->half_open_connections, tc);
+  memset (tc, 0, sizeof (*tc));
+
+  clib_memcpy (&tc->c_rmt_ip, rmt_addr, sizeof (ip46_address_t));
+  clib_memcpy (&tc->c_lcl_ip, &lcl_addr, sizeof (ip46_address_t));
+  tc->c_rmt_port = clib_host_to_net_u16 (rmt_port);
+  tc->c_lcl_port = clib_host_to_net_u16 (lcl_port);
+  tc->c_c_index = tc - tm->half_open_connections;
+  tc->c_is_ip4 = is_ip4;
+
+  /* The other connection vars will be initialized after SYN ACK */
+  tcp_connection_timers_init (tc);
+
+  tcp_send_syn (tc);
+
+  tc->state = TCP_STATE_SYN_SENT;
+
+  return tc->c_c_index;
+}
+
+int
+tcp_session_open_ip4 (ip46_address_t * addr, u16 port)
+{
+  return tcp_connection_open (addr, port, 1);
+}
+
+int
+tcp_session_open_ip6 (ip46_address_t * addr, u16 port)
+{
+  return tcp_connection_open (addr, port, 0);
+}
+
+u8 *
+format_tcp_session_ip4 (u8 * s, va_list * args)
+{
+  u32 tci = va_arg (*args, u32);
+  u32 thread_index = va_arg (*args, u32);
+  tcp_connection_t *tc;
+
+  tc = tcp_connection_get (tci, thread_index);
+
+  s = format (s, "[%s] %U:%d->%U:%d", "tcp", format_ip4_address,
+	      &tc->c_lcl_ip4, clib_net_to_host_u16 (tc->c_lcl_port),
+	      format_ip4_address, &tc->c_rmt_ip4,
+	      clib_net_to_host_u16 (tc->c_rmt_port));
+
+  return s;
+}
+
+u8 *
+format_tcp_session_ip6 (u8 * s, va_list * args)
+{
+  u32 tci = va_arg (*args, u32);
+  u32 thread_index = va_arg (*args, u32);
+  tcp_connection_t *tc = tcp_connection_get (tci, thread_index);
+  s = format (s, "[%s] %U:%d->%U:%d", "tcp", format_ip6_address,
+	      &tc->c_lcl_ip6, clib_net_to_host_u16 (tc->c_lcl_port),
+	      format_ip6_address, &tc->c_rmt_ip6,
+	      clib_net_to_host_u16 (tc->c_rmt_port));
+  return s;
+}
+
+u8 *
+format_tcp_listener_session_ip4 (u8 * s, va_list * args)
+{
+  u32 tci = va_arg (*args, u32);
+  tcp_connection_t *tc = tcp_listener_get (tci);
+  s = format (s, "[%s] %U:%d->%U:%d", "tcp", format_ip4_address,
+	      &tc->c_lcl_ip4, clib_net_to_host_u16 (tc->c_lcl_port),
+	      format_ip4_address, &tc->c_rmt_ip4,
+	      clib_net_to_host_u16 (tc->c_rmt_port));
+  return s;
+}
+
+u8 *
+format_tcp_listener_session_ip6 (u8 * s, va_list * args)
+{
+  u32 tci = va_arg (*args, u32);
+  tcp_connection_t *tc = tcp_listener_get (tci);
+  s = format (s, "[%s] %U:%d->%U:%d", "tcp", format_ip6_address,
+	      &tc->c_lcl_ip6, clib_net_to_host_u16 (tc->c_lcl_port),
+	      format_ip6_address, &tc->c_rmt_ip6,
+	      clib_net_to_host_u16 (tc->c_rmt_port));
+  return s;
+}
+
+u8 *
+format_tcp_half_open_session_ip4 (u8 * s, va_list * args)
+{
+  u32 tci = va_arg (*args, u32);
+  tcp_connection_t *tc = tcp_half_open_connection_get (tci);
+  s = format (s, "[%s] %U:%d->%U:%d", "tcp", format_ip4_address,
+	      &tc->c_lcl_ip4, clib_net_to_host_u16 (tc->c_lcl_port),
+	      format_ip4_address, &tc->c_rmt_ip4,
+	      clib_net_to_host_u16 (tc->c_rmt_port));
+  return s;
+}
+
+u8 *
+format_tcp_half_open_session_ip6 (u8 * s, va_list * args)
+{
+  u32 tci = va_arg (*args, u32);
+  tcp_connection_t *tc = tcp_half_open_connection_get (tci);
+  s = format (s, "[%s] %U:%d->%U:%d", "tcp", format_ip6_address,
+	      &tc->c_lcl_ip6, clib_net_to_host_u16 (tc->c_lcl_port),
+	      format_ip6_address, &tc->c_rmt_ip6,
+	      clib_net_to_host_u16 (tc->c_rmt_port));
+  return s;
+}
+
+transport_connection_t *
+tcp_session_get_transport (u32 conn_index, u32 thread_index)
+{
+  tcp_connection_t *tc = tcp_connection_get (conn_index, thread_index);
+  return &tc->connection;
+}
+
+transport_connection_t *
+tcp_half_open_session_get_transport (u32 conn_index)
+{
+  tcp_connection_t *tc = tcp_half_open_connection_get (conn_index);
+  return &tc->connection;
+}
+
+u16
+tcp_session_send_mss (transport_connection_t * trans_conn)
+{
+  tcp_connection_t *tc = (tcp_connection_t *) trans_conn;
+  return tc->snd_mss;
+}
+
+u32
+tcp_session_send_space (transport_connection_t * trans_conn)
+{
+  tcp_connection_t *tc = (tcp_connection_t *) trans_conn;
+  return tcp_available_snd_space (tc);
+}
+
+u32
+tcp_session_rx_fifo_offset (transport_connection_t * trans_conn)
+{
+  tcp_connection_t *tc = (tcp_connection_t *) trans_conn;
+  return (tc->snd_una_max - tc->snd_una);
+}
+
+/* *INDENT-OFF* */
+const static transport_proto_vft_t tcp4_proto = {
+  .bind = tcp_session_bind_ip4,
+  .unbind = tcp_session_unbind_ip4,
+  .push_header = tcp_push_header,
+  .get_connection = tcp_session_get_transport,
+  .get_listener = tcp_session_get_listener,
+  .get_half_open = tcp_half_open_session_get_transport,
+  .open = tcp_session_open_ip4,
+  .close = tcp_session_close,
+  .cleanup = tcp_session_cleanup,
+  .send_mss = tcp_session_send_mss,
+  .send_space = tcp_session_send_space,
+  .rx_fifo_offset = tcp_session_rx_fifo_offset,
+  .format_connection = format_tcp_session_ip4,
+  .format_listener = format_tcp_listener_session_ip4,
+  .format_half_open = format_tcp_half_open_session_ip4
+};
+
+const static transport_proto_vft_t tcp6_proto = {
+  .bind = tcp_session_bind_ip6,
+  .unbind = tcp_session_unbind_ip6,
+  .push_header = tcp_push_header,
+  .get_connection = tcp_session_get_transport,
+  .get_listener = tcp_session_get_listener,
+  .get_half_open = tcp_half_open_session_get_transport,
+  .open = tcp_session_open_ip6,
+  .close = tcp_session_close,
+  .cleanup = tcp_session_cleanup,
+  .send_mss = tcp_session_send_mss,
+  .send_space = tcp_session_send_space,
+  .rx_fifo_offset = tcp_session_rx_fifo_offset,
+  .format_connection = format_tcp_session_ip6,
+  .format_listener = format_tcp_listener_session_ip6,
+  .format_half_open = format_tcp_half_open_session_ip6
+};
+/* *INDENT-ON* */
+
+void
+tcp_timer_keep_handler (u32 conn_index)
+{
+  u32 cpu_index = os_get_cpu_number ();
+  tcp_connection_t *tc;
+
+  tc = tcp_connection_get (conn_index, cpu_index);
+  tc->timers[TCP_TIMER_KEEP] = TCP_TIMER_HANDLE_INVALID;
+
+  tcp_connection_close (tc);
+}
+
+void
+tcp_timer_establish_handler (u32 conn_index)
+{
+  tcp_connection_t *tc;
+  u8 sst;
+
+  tc = tcp_half_open_connection_get (conn_index);
+  tc->timers[TCP_TIMER_ESTABLISH] = TCP_TIMER_HANDLE_INVALID;
+
+  ASSERT (tc->state == TCP_STATE_SYN_SENT);
+
+  sst = tc->c_is_ip4 ? SESSION_TYPE_IP4_TCP : SESSION_TYPE_IP6_TCP;
+  stream_session_connect_notify (&tc->connection, sst, 1 /* fail */ );
+
+  tcp_connection_cleanup (tc);
+}
+
+void
+tcp_timer_2msl_handler (u32 conn_index)
+{
+  u32 cpu_index = os_get_cpu_number ();
+  tcp_connection_t *tc;
+
+  tc = tcp_connection_get (conn_index, cpu_index);
+  tc->timers[TCP_TIMER_2MSL] = TCP_TIMER_HANDLE_INVALID;
+
+  tcp_connection_del (tc);
+}
+
+/* *INDENT-OFF* */
+static timer_expiration_handler *timer_expiration_handlers[TCP_N_TIMERS] =
+{
+    tcp_timer_retransmit_handler,
+    tcp_timer_delack_handler,
+    0,
+    tcp_timer_keep_handler,
+    tcp_timer_2msl_handler,
+    tcp_timer_retransmit_syn_handler,
+    tcp_timer_establish_handler
+};
+/* *INDENT-ON* */
+
+static void
+tcp_expired_timers_dispatch (u32 * expired_timers)
+{
+  int i;
+  u32 connection_index, timer_id;
+
+  for (i = 0; i < vec_len (expired_timers); i++)
+    {
+      /* Get session index and timer id */
+      connection_index = expired_timers[i] & 0x0FFFFFFF;
+      timer_id = expired_timers[i] >> 28;
+
+      /* Handle expiration */
+      (*timer_expiration_handlers[timer_id]) (connection_index);
+    }
+}
+
+void
+tcp_initialize_timer_wheels (tcp_main_t * tm)
+{
+  tw_timer_wheel_16t_2w_512sl_t *tw;
+  vec_foreach (tw, tm->timer_wheels)
+  {
+    tw_timer_wheel_init_16t_2w_512sl (tw, tcp_expired_timers_dispatch,
+				      100e-3 /* timer period 100ms */ , ~0);
+    tw->last_run_time = vlib_time_now (tm->vlib_main);
+  }
+}
+
+clib_error_t *
+tcp_init (vlib_main_t * vm)
+{
+  ip_main_t *im = &ip_main;
+  ip_protocol_info_t *pi;
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  vlib_thread_main_t *vtm = vlib_get_thread_main ();
+  clib_error_t *error = 0;
+  u32 num_threads;
+
+  tm->vlib_main = vm;
+  tm->vnet_main = vnet_get_main ();
+
+  if ((error = vlib_call_init_function (vm, ip_main_init)))
+    return error;
+  if ((error = vlib_call_init_function (vm, ip4_lookup_init)))
+    return error;
+  if ((error = vlib_call_init_function (vm, ip6_lookup_init)))
+    return error;
+
+  /*
+   * Registrations
+   */
+
+  /* Register with IP */
+  pi = ip_get_protocol_info (im, IP_PROTOCOL_TCP);
+  if (pi == 0)
+    return clib_error_return (0, "TCP protocol info AWOL");
+  pi->format_header = format_tcp_header;
+  pi->unformat_pg_edit = unformat_pg_tcp_header;
+
+  ip4_register_protocol (IP_PROTOCOL_TCP, tcp4_input_node.index);
+
+  /* Register as transport with URI */
+  session_register_transport (SESSION_TYPE_IP4_TCP, &tcp4_proto);
+  session_register_transport (SESSION_TYPE_IP6_TCP, &tcp6_proto);
+
+  /*
+   * Initialize data structures
+   */
+
+  num_threads = 1 /* main thread */  + vtm->n_threads;
+  vec_validate (tm->connections, num_threads - 1);
+
+  /* Initialize per worker thread tx buffers (used for control messages) */
+  vec_validate (tm->tx_buffers, num_threads - 1);
+
+  /* Initialize timer wheels */
+  vec_validate (tm->timer_wheels, num_threads - 1);
+  tcp_initialize_timer_wheels (tm);
+
+  vec_validate (tm->delack_connections, num_threads - 1);
+
+  /* Initialize clocks per tick for TCP timestamp. Used to compute
+   * monotonically increasing timestamps. */
+  tm->tstamp_ticks_per_clock = vm->clib_time.seconds_per_clock
+    / TCP_TSTAMP_RESOLUTION;
+
+  clib_bihash_init_24_8 (&tm->local_endpoints_table, "local endpoint table",
+			 200000 /* $$$$ config parameter nbuckets */ ,
+			 (64 << 20) /*$$$ config parameter table size */ );
+
+  return error;
+}
+
+VLIB_INIT_FUNCTION (tcp_init);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/tcp/tcp.h b/src/vnet/tcp/tcp.h
new file mode 100644
index 0000000..22f00a6
--- /dev/null
+++ b/src/vnet/tcp/tcp.h
@@ -0,0 +1,624 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _vnet_tcp_h_
+#define _vnet_tcp_h_
+
+#include <vnet/vnet.h>
+#include <vnet/ip/ip.h>
+#include <vnet/tcp/tcp_packet.h>
+#include <vnet/tcp/tcp_timer.h>
+#include <vnet/session/transport.h>
+#include <vnet/session/session.h>
+
+#define TCP_TICK 10e-3			/**< TCP tick period (s) */
+#define THZ 1/TCP_TICK			/**< TCP tick frequency */
+#define TCP_TSTAMP_RESOLUTION TCP_TICK	/**< Time stamp resolution */
+#define TCP_PAWS_IDLE 24 * 24 * 60 * 60 * THZ /**< 24 days */
+#define TCP_MAX_OPTION_SPACE 40
+
+#define TCP_DUPACK_THRESHOLD 3
+#define TCP_DEFAULT_RX_FIFO_SIZE 64 << 10
+
+/** TCP FSM state definitions as per RFC793. */
+#define foreach_tcp_fsm_state   \
+  _(CLOSED, "CLOSED")           \
+  _(LISTEN, "LISTEN")           \
+  _(SYN_SENT, "SYN_SENT")       \
+  _(SYN_RCVD, "SYN_RCVD")       \
+  _(ESTABLISHED, "ESTABLISHED") \
+  _(CLOSE_WAIT, "CLOSE_WAIT")   \
+  _(FIN_WAIT_1, "FIN_WAIT_1")   \
+  _(LAST_ACK, "LAST_ACK")       \
+  _(CLOSING, "CLOSING")         \
+  _(FIN_WAIT_2, "FIN_WAIT_2")   \
+  _(TIME_WAIT, "TIME_WAIT")
+
+typedef enum _tcp_state
+{
+#define _(sym, str) TCP_STATE_##sym,
+  foreach_tcp_fsm_state
+#undef _
+  TCP_N_STATES
+} tcp_state_t;
+
+format_function_t format_tcp_state;
+
+/** TCP timers */
+#define foreach_tcp_timer               \
+  _(RETRANSMIT, "RETRANSMIT")           \
+  _(DELACK, "DELAYED ACK")              \
+  _(PERSIST, "PERSIST")                 \
+  _(KEEP, "KEEP")                       \
+  _(2MSL, "2MSL")                       \
+  _(RETRANSMIT_SYN, "RETRANSMIT_SYN")   \
+  _(ESTABLISH, "ESTABLISH")
+
+typedef enum _tcp_timers
+{
+#define _(sym, str) TCP_TIMER_##sym,
+  foreach_tcp_timer
+#undef _
+  TCP_N_TIMERS
+} tcp_timers_e;
+
+typedef void (timer_expiration_handler) (u32 index);
+
+extern timer_expiration_handler tcp_timer_delack_handler;
+extern timer_expiration_handler tcp_timer_retransmit_handler;
+extern timer_expiration_handler tcp_timer_retransmit_syn_handler;
+
+#define TCP_TIMER_HANDLE_INVALID ((u32) ~0)
+
+/* Timer delays as multiples of 100ms */
+#define TCP_TO_TIMER_TICK       TCP_TICK*10	/* Period for converting from TCP
+						 * ticks to timer units */
+#define TCP_DELACK_TIME         1	/* 0.1s */
+#define TCP_ESTABLISH_TIME      750	/* 75s */
+#define TCP_2MSL_TIME           300	/* 30s */
+
+#define TCP_RTO_MAX 60 * THZ	/* Min max RTO (60s) as per RFC6298 */
+#define TCP_RTT_MAX 30 * THZ	/* 30s (probably too much) */
+#define TCP_RTO_SYN_RETRIES 3	/* SYN retries without doubling RTO */
+#define TCP_RTO_INIT 1 * THZ	/* Initial retransmit timer */
+
+void tcp_update_time (f64 now, u32 thread_index);
+
+/** TCP connection flags */
+#define foreach_tcp_connection_flag             \
+  _(DELACK, "Delay ACK")                        \
+  _(SNDACK, "Send ACK")                         \
+  _(BURSTACK, "Burst ACK set")                  \
+  _(SENT_RCV_WND0, "Sent 0 receive window")     \
+  _(RECOVERY, "Recovery on")                    \
+  _(FAST_RECOVERY, "Fast Recovery on")
+
+typedef enum _tcp_connection_flag_bits
+{
+#define _(sym, str) TCP_CONN_##sym##_BIT,
+  foreach_tcp_connection_flag
+#undef _
+  TCP_CONN_N_FLAG_BITS
+} tcp_connection_flag_bits_e;
+
+typedef enum _tcp_connection_flag
+{
+#define _(sym, str) TCP_CONN_##sym = 1 << TCP_CONN_##sym##_BIT,
+  foreach_tcp_connection_flag
+#undef _
+  TCP_CONN_N_FLAGS
+} tcp_connection_flags_e;
+
+/** TCP buffer flags */
+#define foreach_tcp_buf_flag                            \
+  _ (ACK)       /**< Sending ACK. */                    \
+  _ (DUPACK)    /**< Sending DUPACK. */                 \
+
+enum
+{
+#define _(f) TCP_BUF_BIT_##f,
+  foreach_tcp_buf_flag
+#undef _
+    TCP_N_BUF_BITS,
+};
+
+enum
+{
+#define _(f) TCP_BUF_FLAG_##f = 1 << TCP_BUF_BIT_##f,
+  foreach_tcp_buf_flag
+#undef _
+};
+
+#define TCP_MAX_SACK_BLOCKS 5	/**< Max number of SACK blocks stored */
+#define TCP_INVALID_SACK_HOLE_INDEX ((u32)~0)
+
+typedef struct _sack_scoreboard_hole
+{
+  u32 next;		/**< Index for next entry in linked list */
+  u32 prev;		/**< Index for previous entry in linked list */
+  u32 start;		/**< Start sequence number */
+  u32 end;		/**< End sequence number */
+} sack_scoreboard_hole_t;
+
+typedef struct _sack_scoreboard
+{
+  sack_scoreboard_hole_t *holes;	/**< Pool of holes */
+  u32 head;				/**< Index to first entry */
+  u32 sacked_bytes;			/**< Number of bytes sacked in sb */
+} sack_scoreboard_t;
+
+typedef enum _tcp_cc_algorithm_type
+{
+  TCP_CC_NEWRENO,
+} tcp_cc_algorithm_type_e;
+
+typedef struct _tcp_cc_algorithm tcp_cc_algorithm_t;
+
+typedef enum _tcp_cc_ack_t
+{
+  TCP_CC_ACK,
+  TCP_CC_DUPACK,
+  TCP_CC_PARTIALACK
+} tcp_cc_ack_t;
+
+typedef struct _tcp_connection
+{
+  transport_connection_t connection;  /**< Common transport data. First! */
+
+  u8 state;			/**< TCP state as per tcp_state_t */
+  u16 flags;			/**< Connection flags (see tcp_conn_flags_e) */
+  u32 timers[TCP_N_TIMERS];	/**< Timer handles into timer wheel */
+
+  /* TODO RFC4898 */
+
+  /** Send sequence variables RFC793 */
+  u32 snd_una;		/**< oldest unacknowledged sequence number */
+  u32 snd_una_max;	/**< newest unacknowledged sequence number + 1*/
+  u32 snd_wnd;		/**< send window */
+  u32 snd_wl1;		/**< seq number used for last snd.wnd update */
+  u32 snd_wl2;		/**< ack number used for last snd.wnd update */
+  u32 snd_nxt;		/**< next seq number to be sent */
+
+  /** Receive sequence variables RFC793 */
+  u32 rcv_nxt;		/**< next sequence number expected */
+  u32 rcv_wnd;		/**< receive window we expect */
+
+  u32 rcv_las;		/**< rcv_nxt at last ack sent/rcv_wnd update */
+  u32 iss;		/**< initial sent sequence */
+  u32 irs;		/**< initial remote sequence */
+
+  /* Options */
+  tcp_options_t opt;	/**< TCP connection options parsed */
+  u8 rcv_wscale;	/**< Window scale to advertise to peer */
+  u8 snd_wscale;	/**< Window scale to use when sending */
+  u32 tsval_recent;	/**< Last timestamp received */
+  u32 tsval_recent_age;	/**< When last updated tstamp_recent*/
+
+  sack_block_t *snd_sacks;	/**< Vector of SACKs to send. XXX Fixed size? */
+  sack_scoreboard_t sack_sb;	/**< SACK "scoreboard" that tracks holes */
+
+  u8 rcv_dupacks;	/**< Number of DUPACKs received */
+  u8 snt_dupacks;	/**< Number of DUPACKs sent in a burst */
+
+  /* Congestion control */
+  u32 cwnd;		/**< Congestion window */
+  u32 ssthresh;		/**< Slow-start threshold */
+  u32 prev_ssthresh;	/**< ssthresh before congestion */
+  u32 bytes_acked;	/**< Bytes acknowledged by current segment */
+  u32 rtx_bytes;	/**< Retransmitted bytes */
+  u32 tsecr_last_ack;	/**< Timestamp echoed to us in last health ACK */
+  tcp_cc_algorithm_t *cc_algo;	/**< Congestion control algorithm */
+
+  /* RTT and RTO */
+  u32 rto;		/**< Retransmission timeout */
+  u32 rto_boff;		/**< Index for RTO backoff */
+  u32 srtt;		/**< Smoothed RTT */
+  u32 rttvar;		/**< Smoothed mean RTT difference. Approximates variance */
+  u32 rtt_ts;		/**< Timestamp for tracked ACK */
+  u32 rtt_seq;		/**< Sequence number for tracked ACK */
+
+  u16 snd_mss;		/**< Send MSS */
+} tcp_connection_t;
+
+struct _tcp_cc_algorithm
+{
+  void (*rcv_ack) (tcp_connection_t * tc);
+  void (*rcv_cong_ack) (tcp_connection_t * tc, tcp_cc_ack_t ack);
+  void (*congestion) (tcp_connection_t * tc);
+  void (*recovered) (tcp_connection_t * tc);
+  void (*init) (tcp_connection_t * tc);
+};
+
+#define tcp_fastrecovery_on(tc) (tc)->flags |= TCP_CONN_FAST_RECOVERY
+#define tcp_fastrecovery_off(tc) (tc)->flags &= ~TCP_CONN_FAST_RECOVERY
+#define tcp_in_fastrecovery(tc) ((tc)->flags & TCP_CONN_FAST_RECOVERY)
+#define tcp_in_recovery(tc) ((tc)->flags & (TCP_CONN_FAST_RECOVERY | TCP_CONN_RECOVERY))
+#define tcp_recovery_off(tc) ((tc)->flags &= ~(TCP_CONN_FAST_RECOVERY | TCP_CONN_RECOVERY))
+#define tcp_in_slowstart(tc) (tc->cwnd < tc->ssthresh)
+
+typedef enum
+{
+  TCP_IP4,
+  TCP_IP6,
+  TCP_N_AF,
+} tcp_af_t;
+
+typedef enum _tcp_error
+{
+#define tcp_error(n,s) TCP_ERROR_##n,
+#include <vnet/tcp/tcp_error.def>
+#undef tcp_error
+  TCP_N_ERROR,
+} tcp_error_t;
+
+typedef struct _tcp_lookup_dispatch
+{
+  u8 next, error;
+} tcp_lookup_dispatch_t;
+
+typedef struct _tcp_main
+{
+  /* Per-worker thread tcp connection pools */
+  tcp_connection_t **connections;
+
+  /* Pool of listeners. */
+  tcp_connection_t *listener_pool;
+
+  /** Dispatch table by state and flags */
+  tcp_lookup_dispatch_t dispatch_table[TCP_N_STATES][64];
+
+  u8 log2_tstamp_clocks_per_tick;
+  f64 tstamp_ticks_per_clock;
+
+  /** per-worker tx buffer free lists */
+  u32 **tx_buffers;
+
+  /* Per worker-thread timer wheel for connections timers */
+  tw_timer_wheel_16t_2w_512sl_t *timer_wheels;
+
+  /* Convenience per worker-thread vector of connections to DELACK */
+  u32 **delack_connections;
+
+  /* Pool of half-open connections on which we've sent a SYN */
+  tcp_connection_t *half_open_connections;
+
+  /* Pool of local TCP endpoints */
+  transport_endpoint_t *local_endpoints;
+
+  /* Local endpoints lookup table */
+  transport_endpoint_table_t local_endpoints_table;
+
+  /* Congestion control algorithms registered */
+  tcp_cc_algorithm_t *cc_algos;
+
+  /* convenience */
+  vlib_main_t *vlib_main;
+  vnet_main_t *vnet_main;
+  ip4_main_t *ip4_main;
+  ip6_main_t *ip6_main;
+} tcp_main_t;
+
+extern tcp_main_t tcp_main;
+extern vlib_node_registration_t tcp4_input_node;
+extern vlib_node_registration_t tcp6_input_node;
+extern vlib_node_registration_t tcp4_output_node;
+extern vlib_node_registration_t tcp6_output_node;
+
+always_inline tcp_main_t *
+vnet_get_tcp_main ()
+{
+  return &tcp_main;
+}
+
+always_inline tcp_connection_t *
+tcp_connection_get (u32 conn_index, u32 thread_index)
+{
+  return pool_elt_at_index (tcp_main.connections[thread_index], conn_index);
+}
+
+always_inline tcp_connection_t *
+tcp_connection_get_if_valid (u32 conn_index, u32 thread_index)
+{
+  if (tcp_main.connections[thread_index] == 0)
+    return 0;
+  if (pool_is_free_index (tcp_main.connections[thread_index], conn_index))
+    return 0;
+  return pool_elt_at_index (tcp_main.connections[thread_index], conn_index);
+}
+
+void tcp_connection_close (tcp_connection_t * tc);
+void tcp_connection_cleanup (tcp_connection_t * tc);
+void tcp_connection_del (tcp_connection_t * tc);
+
+always_inline tcp_connection_t *
+tcp_listener_get (u32 tli)
+{
+  return pool_elt_at_index (tcp_main.listener_pool, tli);
+}
+
+always_inline tcp_connection_t *
+tcp_half_open_connection_get (u32 conn_index)
+{
+  return pool_elt_at_index (tcp_main.half_open_connections, conn_index);
+}
+
+void tcp_make_ack (tcp_connection_t * ts, vlib_buffer_t * b);
+void tcp_make_finack (tcp_connection_t * tc, vlib_buffer_t * b);
+void tcp_make_synack (tcp_connection_t * ts, vlib_buffer_t * b);
+void tcp_send_reset (vlib_buffer_t * pkt, u8 is_ip4);
+void tcp_send_syn (tcp_connection_t * tc);
+void tcp_send_fin (tcp_connection_t * tc);
+void tcp_set_snd_mss (tcp_connection_t * tc);
+
+always_inline u32
+tcp_end_seq (tcp_header_t * th, u32 len)
+{
+  return th->seq_number + tcp_is_syn (th) + tcp_is_fin (th) + len;
+}
+
+/* Modulo arithmetic for TCP sequence numbers */
+#define seq_lt(_s1, _s2) ((i32)((_s1)-(_s2)) < 0)
+#define seq_leq(_s1, _s2) ((i32)((_s1)-(_s2)) <= 0)
+#define seq_gt(_s1, _s2) ((i32)((_s1)-(_s2)) > 0)
+#define seq_geq(_s1, _s2) ((i32)((_s1)-(_s2)) >= 0)
+
+/* Modulo arithmetic for timestamps */
+#define timestamp_lt(_t1, _t2) ((i32)((_t1)-(_t2)) < 0)
+#define timestamp_leq(_t1, _t2) ((i32)((_t1)-(_t2)) <= 0)
+
+always_inline u32
+tcp_flight_size (const tcp_connection_t * tc)
+{
+  return tc->snd_una_max - tc->snd_una - tc->sack_sb.sacked_bytes
+    + tc->rtx_bytes;
+}
+
+/**
+ * Initial cwnd as per RFC5681
+ */
+always_inline u32
+tcp_initial_cwnd (const tcp_connection_t * tc)
+{
+  if (tc->snd_mss > 2190)
+    return 2 * tc->snd_mss;
+  else if (tc->snd_mss > 1095)
+    return 3 * tc->snd_mss;
+  else
+    return 4 * tc->snd_mss;
+}
+
+always_inline u32
+tcp_loss_wnd (const tcp_connection_t * tc)
+{
+  return tc->snd_mss;
+}
+
+always_inline u32
+tcp_available_wnd (const tcp_connection_t * tc)
+{
+  return clib_min (tc->cwnd, tc->snd_wnd);
+}
+
+always_inline u32
+tcp_available_snd_space (const tcp_connection_t * tc)
+{
+  u32 available_wnd = tcp_available_wnd (tc);
+  u32 flight_size = tcp_flight_size (tc);
+
+  if (available_wnd <= flight_size)
+    return 0;
+
+  return available_wnd - flight_size;
+}
+
+void tcp_retransmit_first_unacked (tcp_connection_t * tc);
+
+void tcp_fast_retransmit (tcp_connection_t * tc);
+
+always_inline u32
+tcp_time_now (void)
+{
+  return clib_cpu_time_now () * tcp_main.tstamp_ticks_per_clock;
+}
+
+u32 tcp_push_header (transport_connection_t * tconn, vlib_buffer_t * b);
+
+u32
+tcp_prepare_retransmit_segment (tcp_connection_t * tc, vlib_buffer_t * b,
+				u32 max_bytes);
+
+void tcp_connection_timers_init (tcp_connection_t * tc);
+void tcp_connection_timers_reset (tcp_connection_t * tc);
+
+void tcp_connection_init_vars (tcp_connection_t * tc);
+
+always_inline void
+tcp_connection_force_ack (tcp_connection_t * tc, vlib_buffer_t * b)
+{
+  /* Reset flags, make sure ack is sent */
+  tc->flags = TCP_CONN_SNDACK;
+  vnet_buffer (b)->tcp.flags &= ~TCP_BUF_FLAG_DUPACK;
+}
+
+always_inline void
+tcp_timer_set (tcp_connection_t * tc, u8 timer_id, u32 interval)
+{
+  tc->timers[timer_id]
+    = tw_timer_start_16t_2w_512sl (&tcp_main.timer_wheels[tc->c_thread_index],
+				   tc->c_c_index, timer_id, interval);
+}
+
+always_inline void
+tcp_retransmit_timer_set (tcp_main_t * tm, tcp_connection_t * tc)
+{
+  /* XXX Switch to faster TW */
+  tcp_timer_set (tc, TCP_TIMER_RETRANSMIT,
+		 clib_max (tc->rto * TCP_TO_TIMER_TICK, 1));
+}
+
+always_inline void
+tcp_timer_reset (tcp_connection_t * tc, u8 timer_id)
+{
+  if (tc->timers[timer_id] == TCP_TIMER_HANDLE_INVALID)
+    return;
+
+  tw_timer_stop_16t_2w_512sl (&tcp_main.timer_wheels[tc->c_thread_index],
+			      tc->timers[timer_id]);
+  tc->timers[timer_id] = TCP_TIMER_HANDLE_INVALID;
+}
+
+always_inline void
+tcp_timer_update (tcp_connection_t * tc, u8 timer_id, u32 interval)
+{
+  if (tc->timers[timer_id] != TCP_TIMER_HANDLE_INVALID)
+    tw_timer_stop_16t_2w_512sl (&tcp_main.timer_wheels[tc->c_thread_index],
+				tc->timers[timer_id]);
+  tc->timers[timer_id] =
+    tw_timer_start_16t_2w_512sl (&tcp_main.timer_wheels[tc->c_thread_index],
+				 tc->c_c_index, timer_id, interval);
+}
+
+always_inline u8
+tcp_timer_is_active (tcp_connection_t * tc, tcp_timers_e timer)
+{
+  return tc->timers[timer] != TCP_TIMER_HANDLE_INVALID;
+}
+
+void
+scoreboard_remove_hole (sack_scoreboard_t * sb,
+			sack_scoreboard_hole_t * hole);
+
+always_inline sack_scoreboard_hole_t *
+scoreboard_next_hole (sack_scoreboard_t * sb, sack_scoreboard_hole_t * hole)
+{
+  if (hole->next != TCP_INVALID_SACK_HOLE_INDEX)
+    return pool_elt_at_index (sb->holes, hole->next);
+  return 0;
+}
+
+always_inline sack_scoreboard_hole_t *
+scoreboard_first_hole (sack_scoreboard_t * sb)
+{
+  if (sb->head != TCP_INVALID_SACK_HOLE_INDEX)
+    return pool_elt_at_index (sb->holes, sb->head);
+  return 0;
+}
+
+always_inline void
+scoreboard_clear (sack_scoreboard_t * sb)
+{
+  sack_scoreboard_hole_t *hole = scoreboard_first_hole (sb);
+  while ((hole = scoreboard_first_hole (sb)))
+    {
+      scoreboard_remove_hole (sb, hole);
+    }
+}
+
+always_inline u32
+scoreboard_hole_bytes (sack_scoreboard_hole_t * hole)
+{
+  return hole->end - hole->start;
+}
+
+always_inline void
+tcp_cc_algo_register (tcp_cc_algorithm_type_e type,
+		      const tcp_cc_algorithm_t * vft)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  vec_validate (tm->cc_algos, type);
+
+  tm->cc_algos[type] = *vft;
+}
+
+always_inline tcp_cc_algorithm_t *
+tcp_cc_algo_get (tcp_cc_algorithm_type_e type)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  return &tm->cc_algos[type];
+}
+
+void tcp_cc_init (tcp_connection_t * tc);
+
+/**
+ * Push TCP header to buffer
+ *
+ * @param vm - vlib_main
+ * @param b - buffer to write the header to
+ * @param sp_net - source port net order
+ * @param dp_net - destination port net order
+ * @param seq - sequence number net order
+ * @param ack - ack number net order
+ * @param tcp_hdr_opts_len - header and options length in bytes
+ * @param flags - header flags
+ * @param wnd - window size
+ *
+ * @return - pointer to start of TCP header
+ */
+always_inline void *
+vlib_buffer_push_tcp_net_order (vlib_buffer_t * b, u16 sp, u16 dp, u32 seq,
+				u32 ack, u8 tcp_hdr_opts_len, u8 flags,
+				u16 wnd)
+{
+  tcp_header_t *th;
+
+  th = vlib_buffer_push_uninit (b, tcp_hdr_opts_len);
+
+  th->src_port = sp;
+  th->dst_port = dp;
+  th->seq_number = seq;
+  th->ack_number = ack;
+  th->data_offset_and_reserved = (tcp_hdr_opts_len >> 2) << 4;
+  th->flags = flags;
+  th->window = wnd;
+  th->checksum = 0;
+  th->urgent_pointer = 0;
+  return th;
+}
+
+/**
+ * Push TCP header to buffer
+ *
+ * @param vm - vlib_main
+ * @param b - buffer to write the header to
+ * @param sp_net - source port net order
+ * @param dp_net - destination port net order
+ * @param seq - sequence number host order
+ * @param ack - ack number host order
+ * @param tcp_hdr_opts_len - header and options length in bytes
+ * @param flags - header flags
+ * @param wnd - window size
+ *
+ * @return - pointer to start of TCP header
+ */
+always_inline void *
+vlib_buffer_push_tcp (vlib_buffer_t * b, u16 sp_net, u16 dp_net, u32 seq,
+		      u32 ack, u8 tcp_hdr_opts_len, u8 flags, u16 wnd)
+{
+  return vlib_buffer_push_tcp_net_order (b, sp_net, dp_net,
+					 clib_host_to_net_u32 (seq),
+					 clib_host_to_net_u32 (ack),
+					 tcp_hdr_opts_len, flags,
+					 clib_host_to_net_u16 (wnd));
+}
+
+#endif /* _vnet_tcp_h_ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/tcp/tcp_error.def b/src/vnet/tcp/tcp_error.def
new file mode 100644
index 0000000..cff5ec1
--- /dev/null
+++ b/src/vnet/tcp/tcp_error.def
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+tcp_error (NONE, "no error")
+tcp_error (NO_LISTENER, "no listener for dst port")
+tcp_error (LOOKUP_DROPS, "lookup drops")
+tcp_error (DISPATCH, "Dispatch error")
+tcp_error (ENQUEUED, "Packets pushed into rx fifo")                              
+tcp_error (PURE_ACK, "Pure acks")
+tcp_error (SYNS_RCVD, "SYNs received")
+tcp_error (SYN_ACKS_RCVD, "SYN-ACKs received")
+tcp_error (NOT_READY, "Session not ready for packets")                               
+tcp_error (FIFO_FULL, "Packets dropped for lack of rx fifo space")               
+tcp_error (EVENT_FIFO_FULL, "Events not sent for lack of event fifo space")      
+tcp_error (API_QUEUE_FULL, "Sessions not created for lack of API queue space")
+tcp_error (CREATE_SESSION_FAIL, "Sessions couldn't be allocated")
+tcp_error (SEGMENT_INVALID, "Invalid segment")
+tcp_error (ACK_INVALID, "Invalid ACK")
+tcp_error (ACK_DUP, "Duplicate ACK")
+tcp_error (ACK_OLD, "Old ACK")
+tcp_error (PKTS_SENT, "Packets sent")
+tcp_error (FILTERED_DUPACKS, "Filtered duplicate ACKs")
+tcp_error (RST_SENT, "Resets sent")
\ No newline at end of file
diff --git a/src/vnet/tcp/tcp_format.c b/src/vnet/tcp/tcp_format.c
new file mode 100644
index 0000000..7136741
--- /dev/null
+++ b/src/vnet/tcp/tcp_format.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * tcp/tcp_format.c: tcp formatting
+ *
+ * Copyright (c) 2008 Eliot Dresselhaus
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <vnet/ip/ip.h>
+#include <vnet/tcp/tcp.h>
+
+static u8 *
+format_tcp_flags (u8 * s, va_list * args)
+{
+  int flags = va_arg (*args, int);
+
+#define _(f) if (flags & TCP_FLAG_##f) s = format (s, "%s, ", #f);
+  foreach_tcp_flag
+#undef _
+    return s;
+}
+
+/* Format TCP header. */
+u8 *
+format_tcp_header (u8 * s, va_list * args)
+{
+  tcp_header_t *tcp = va_arg (*args, tcp_header_t *);
+  u32 max_header_bytes = va_arg (*args, u32);
+  u32 header_bytes;
+  uword indent;
+
+  /* Nothing to do. */
+  if (max_header_bytes < sizeof (tcp[0]))
+    return format (s, "TCP header truncated");
+
+  indent = format_get_indent (s);
+  indent += 2;
+  header_bytes = tcp_header_bytes (tcp);
+
+  s = format (s, "TCP: %d -> %d", clib_net_to_host_u16 (tcp->src),
+	      clib_net_to_host_u16 (tcp->dst));
+
+  s = format (s, "\n%Useq. 0x%08x ack 0x%08x", format_white_space, indent,
+	      clib_net_to_host_u32 (tcp->seq_number),
+	      clib_net_to_host_u32 (tcp->ack_number));
+
+  s = format (s, "\n%Uflags %U, tcp header: %d bytes", format_white_space,
+	      indent, format_tcp_flags, tcp->flags, header_bytes);
+
+  s = format (s, "\n%Uwindow %d, checksum 0x%04x", format_white_space, indent,
+	      clib_net_to_host_u16 (tcp->window),
+	      clib_net_to_host_u16 (tcp->checksum));
+
+
+#if 0
+  /* Format TCP options. */
+  {
+    u8 *o;
+    u8 *option_start = (void *) (tcp + 1);
+    u8 *option_end = (void *) tcp + header_bytes;
+
+    for (o = option_start; o < option_end;)
+      {
+	u32 length = o[1];
+	switch (o[0])
+	  {
+	  case TCP_OPTION_END:
+	    length = 1;
+	    o = option_end;
+	    break;
+
+	  case TCP_OPTION_NOOP:
+	    length = 1;
+	    break;
+
+	  }
+      }
+  }
+#endif
+
+  /* Recurse into next protocol layer. */
+  if (max_header_bytes != 0 && header_bytes < max_header_bytes)
+    {
+      ip_main_t *im = &ip_main;
+      tcp_udp_port_info_t *pi;
+
+      pi = ip_get_tcp_udp_port_info (im, tcp->dst);
+
+      if (pi && pi->format_header)
+	s = format (s, "\n%U%U", format_white_space, indent - 2,
+		    pi->format_header,
+		    /* next protocol header */ (void *) tcp + header_bytes,
+		    max_header_bytes - header_bytes);
+    }
+
+  return s;
+}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c
new file mode 100644
index 0000000..daa0683
--- /dev/null
+++ b/src/vnet/tcp/tcp_input.c
@@ -0,0 +1,2316 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vppinfra/sparse_vec.h>
+#include <vnet/tcp/tcp_packet.h>
+#include <vnet/tcp/tcp.h>
+#include <vnet/session/session.h>
+#include <math.h>
+
+static char *tcp_error_strings[] = {
+#define tcp_error(n,s) s,
+#include <vnet/tcp/tcp_error.def>
+#undef tcp_error
+};
+
+/* All TCP nodes have the same outgoing arcs */
+#define foreach_tcp_state_next                  \
+  _ (DROP, "error-drop")                        \
+  _ (TCP4_OUTPUT, "tcp4-output")                \
+  _ (TCP6_OUTPUT, "tcp6-output")
+
+typedef enum _tcp_established_next
+{
+#define _(s,n) TCP_ESTABLISHED_NEXT_##s,
+  foreach_tcp_state_next
+#undef _
+    TCP_ESTABLISHED_N_NEXT,
+} tcp_established_next_t;
+
+typedef enum _tcp_rcv_process_next
+{
+#define _(s,n) TCP_RCV_PROCESS_NEXT_##s,
+  foreach_tcp_state_next
+#undef _
+    TCP_RCV_PROCESS_N_NEXT,
+} tcp_rcv_process_next_t;
+
+typedef enum _tcp_syn_sent_next
+{
+#define _(s,n) TCP_SYN_SENT_NEXT_##s,
+  foreach_tcp_state_next
+#undef _
+    TCP_SYN_SENT_N_NEXT,
+} tcp_syn_sent_next_t;
+
+typedef enum _tcp_listen_next
+{
+#define _(s,n) TCP_LISTEN_NEXT_##s,
+  foreach_tcp_state_next
+#undef _
+    TCP_LISTEN_N_NEXT,
+} tcp_listen_next_t;
+
+/* Generic, state independent indices */
+typedef enum _tcp_state_next
+{
+#define _(s,n) TCP_NEXT_##s,
+  foreach_tcp_state_next
+#undef _
+    TCP_STATE_N_NEXT,
+} tcp_state_next_t;
+
+#define tcp_next_output(is_ip4) (is_ip4 ? TCP_NEXT_TCP4_OUTPUT          \
+                                        : TCP_NEXT_TCP6_OUTPUT)
+
+vlib_node_registration_t tcp4_established_node;
+vlib_node_registration_t tcp6_established_node;
+
+/**
+ * Validate segment sequence number. As per RFC793:
+ *
+ * Segment Receive Test
+ *      Length  Window
+ *      ------- -------  -------------------------------------------
+ *      0       0       SEG.SEQ = RCV.NXT
+ *      0       >0      RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND
+ *      >0      0       not acceptable
+ *      >0      >0      RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND
+ *                      or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND
+ *
+ * This ultimately consists in checking if segment falls within the window.
+ * The one important difference compared to RFC793 is that we use rcv_las,
+ * or the rcv_nxt at last ack sent instead of rcv_nxt since that's the
+ * peer's reference when computing our receive window.
+ *
+ * This accepts only segments within the window.
+ */
+always_inline u8
+tcp_segment_in_rcv_wnd (tcp_connection_t * tc, u32 seq, u32 end_seq)
+{
+  return seq_leq (end_seq, tc->rcv_las + tc->rcv_wnd)
+    && seq_geq (seq, tc->rcv_nxt);
+}
+
+void
+tcp_options_parse (tcp_header_t * th, tcp_options_t * to)
+{
+  const u8 *data;
+  u8 opt_len, opts_len, kind;
+  int j;
+  sack_block_t b;
+
+  opts_len = (tcp_doff (th) << 2) - sizeof (tcp_header_t);
+  data = (const u8 *) (th + 1);
+
+  /* Zero out all flags but those set in SYN */
+  to->flags &= (TCP_OPTS_FLAG_SACK_PERMITTED | TCP_OPTS_FLAG_WSCALE);
+
+  for (; opts_len > 0; opts_len -= opt_len, data += opt_len)
+    {
+      kind = data[0];
+
+      /* Get options length */
+      if (kind == TCP_OPTION_EOL)
+	break;
+      else if (kind == TCP_OPTION_NOOP)
+	opt_len = 1;
+      else
+	{
+	  /* broken options */
+	  if (opts_len < 2)
+	    break;
+	  opt_len = data[1];
+
+	  /* weird option length */
+	  if (opt_len < 2 || opt_len > opts_len)
+	    break;
+	}
+
+      /* Parse options */
+      switch (kind)
+	{
+	case TCP_OPTION_MSS:
+	  if ((opt_len == TCP_OPTION_LEN_MSS) && tcp_syn (th))
+	    {
+	      to->flags |= TCP_OPTS_FLAG_MSS;
+	      to->mss = clib_net_to_host_u16 (*(u16 *) (data + 2));
+	    }
+	  break;
+	case TCP_OPTION_WINDOW_SCALE:
+	  if ((opt_len == TCP_OPTION_LEN_WINDOW_SCALE) && tcp_syn (th))
+	    {
+	      to->flags |= TCP_OPTS_FLAG_WSCALE;
+	      to->wscale = data[2];
+	      if (to->wscale > TCP_MAX_WND_SCALE)
+		{
+		  clib_warning ("Illegal window scaling value: %d",
+				to->wscale);
+		  to->wscale = TCP_MAX_WND_SCALE;
+		}
+	    }
+	  break;
+	case TCP_OPTION_TIMESTAMP:
+	  if (opt_len == TCP_OPTION_LEN_TIMESTAMP)
+	    {
+	      to->flags |= TCP_OPTS_FLAG_TSTAMP;
+	      to->tsval = clib_net_to_host_u32 (*(u32 *) (data + 2));
+	      to->tsecr = clib_net_to_host_u32 (*(u32 *) (data + 6));
+	    }
+	  break;
+	case TCP_OPTION_SACK_PERMITTED:
+	  if (opt_len == TCP_OPTION_LEN_SACK_PERMITTED && tcp_syn (th))
+	    to->flags |= TCP_OPTS_FLAG_SACK_PERMITTED;
+	  break;
+	case TCP_OPTION_SACK_BLOCK:
+	  /* If SACK permitted was not advertised or a SYN, break */
+	  if ((to->flags & TCP_OPTS_FLAG_SACK_PERMITTED) == 0 || tcp_syn (th))
+	    break;
+
+	  /* If too short or not correctly formatted, break */
+	  if (opt_len < 10 || ((opt_len - 2) % TCP_OPTION_LEN_SACK_BLOCK))
+	    break;
+
+	  to->flags |= TCP_OPTS_FLAG_SACK;
+	  to->n_sack_blocks = (opt_len - 2) / TCP_OPTION_LEN_SACK_BLOCK;
+	  vec_reset_length (to->sacks);
+	  for (j = 0; j < to->n_sack_blocks; j++)
+	    {
+	      b.start = clib_net_to_host_u32 (*(u32 *) (data + 2 + 4 * j));
+	      b.end = clib_net_to_host_u32 (*(u32 *) (data + 6 + 4 * j));
+	      vec_add1 (to->sacks, b);
+	    }
+	  break;
+	default:
+	  /* Nothing to see here */
+	  continue;
+	}
+    }
+}
+
+always_inline int
+tcp_segment_check_paws (tcp_connection_t * tc)
+{
+  /* XXX normally test for timestamp should be lt instead of leq, but for
+   * local testing this is not enough */
+  return tcp_opts_tstamp (&tc->opt) && tc->tsval_recent
+    && timestamp_lt (tc->opt.tsval, tc->tsval_recent);
+}
+
+/**
+ * Validate incoming segment as per RFC793 p. 69 and RFC1323 p. 19
+ *
+ * It first verifies if segment has a wrapped sequence number (PAWS) and then
+ * does the processing associated to the first four steps (ignoring security
+ * and precedence): sequence number, rst bit and syn bit checks.
+ *
+ * @return 0 if segments passes validation.
+ */
+static int
+tcp_segment_validate (vlib_main_t * vm, tcp_connection_t * tc0,
+		      vlib_buffer_t * b0, tcp_header_t * th0, u32 * next0)
+{
+  u8 paws_failed;
+
+  if (PREDICT_FALSE (!tcp_ack (th0) && !tcp_rst (th0) && !tcp_syn (th0)))
+    return -1;
+
+  tcp_options_parse (th0, &tc0->opt);
+
+  /* RFC1323: Check against wrapped sequence numbers (PAWS). If we have
+   * timestamp to echo and it's less than tsval_recent, drop segment
+   * but still send an ACK in order to retain TCP's mechanism for detecting
+   * and recovering from half-open connections */
+  paws_failed = tcp_segment_check_paws (tc0);
+  if (paws_failed)
+    {
+      clib_warning ("paws failed");
+
+      /* If it just so happens that a segment updates tsval_recent for a
+       * segment over 24 days old, invalidate tsval_recent. */
+      if (timestamp_lt (tc0->tsval_recent_age + TCP_PAWS_IDLE,
+			tcp_time_now ()))
+	{
+	  /* Age isn't reset until we get a valid tsval (bsd inspired) */
+	  tc0->tsval_recent = 0;
+	}
+      else
+	{
+	  /* Drop after ack if not rst */
+	  if (!tcp_rst (th0))
+	    {
+	      tcp_make_ack (tc0, b0);
+	      *next0 = tcp_next_output (tc0->c_is_ip4);
+	      return -1;
+	    }
+	}
+    }
+
+  /* 1st: check sequence number */
+  if (!tcp_segment_in_rcv_wnd (tc0, vnet_buffer (b0)->tcp.seq_number,
+			       vnet_buffer (b0)->tcp.seq_end))
+    {
+      if (!tcp_rst (th0))
+	{
+	  /* Send dup ack */
+	  tcp_make_ack (tc0, b0);
+	  *next0 = tcp_next_output (tc0->c_is_ip4);
+	}
+      return -1;
+    }
+
+  /* 2nd: check the RST bit */
+  if (tcp_rst (th0))
+    {
+      /* Notify session that connection has been reset. Switch
+       * state to closed and await for session to do the cleanup. */
+      stream_session_reset_notify (&tc0->connection);
+      tc0->state = TCP_STATE_CLOSED;
+      return -1;
+    }
+
+  /* 3rd: check security and precedence (skip) */
+
+  /* 4th: check the SYN bit */
+  if (tcp_syn (th0))
+    {
+      tcp_send_reset (b0, tc0->c_is_ip4);
+      return -1;
+    }
+
+  /* If PAWS passed and segment in window, save timestamp */
+  if (!paws_failed)
+    {
+      tc0->tsval_recent = tc0->opt.tsval;
+      tc0->tsval_recent_age = tcp_time_now ();
+    }
+
+  return 0;
+}
+
+always_inline int
+tcp_rcv_ack_is_acceptable (tcp_connection_t * tc0, vlib_buffer_t * tb0)
+{
+  /* SND.UNA =< SEG.ACK =< SND.NXT */
+  return (seq_leq (tc0->snd_una, vnet_buffer (tb0)->tcp.ack_number)
+	  && seq_leq (vnet_buffer (tb0)->tcp.ack_number, tc0->snd_nxt));
+}
+
+/**
+ * Compute smoothed RTT as per VJ's '88 SIGCOMM and RFC6298
+ *
+ * Note that although the original article, srtt and rttvar are scaled
+ * to minimize round-off errors, here we don't. Instead, we rely on
+ * better precision time measurements.
+ *
+ * TODO support us rtt resolution
+ */
+static void
+tcp_estimate_rtt (tcp_connection_t * tc, u32 mrtt)
+{
+  int err;
+
+  if (tc->srtt != 0)
+    {
+      err = mrtt - tc->srtt;
+      tc->srtt += err >> 3;
+
+      /* XXX Drop in RTT results in RTTVAR increase and bigger RTO.
+       * The increase should be bound */
+      tc->rttvar += (clib_abs (err) - tc->rttvar) >> 2;
+    }
+  else
+    {
+      /* First measurement. */
+      tc->srtt = mrtt;
+      tc->rttvar = mrtt << 1;
+    }
+}
+
+/** Update RTT estimate and RTO timer
+ *
+ * Measure RTT: We have two sources of RTT measurements: TSOPT and ACK
+ * timing. Middle boxes are known to fiddle with TCP options so we
+ * should give higher priority to ACK timing.
+ *
+ * return 1 if valid rtt 0 otherwise
+ */
+static int
+tcp_update_rtt (tcp_connection_t * tc, u32 ack)
+{
+  u32 mrtt = 0;
+
+  /* Karn's rule, part 1. Don't use retransmitted segments to estimate
+   * RTT because they're ambiguous. */
+  if (tc->rtt_seq && seq_gt (ack, tc->rtt_seq) && !tc->rto_boff)
+    {
+      mrtt = tcp_time_now () - tc->rtt_ts;
+      tc->rtt_seq = 0;
+    }
+
+  /* As per RFC7323 TSecr can be used for RTTM only if the segment advances
+   * snd_una, i.e., the left side of the send window:
+   * seq_lt (tc->snd_una, ack). Note: last condition could be dropped, we don't
+   * try to update rtt for dupacks */
+  else if (tcp_opts_tstamp (&tc->opt) && tc->opt.tsecr && tc->bytes_acked)
+    {
+      mrtt = tcp_time_now () - tc->opt.tsecr;
+    }
+
+  /* Ignore dubious measurements */
+  if (mrtt == 0 || mrtt > TCP_RTT_MAX)
+    return 0;
+
+  tcp_estimate_rtt (tc, mrtt);
+
+  tc->rto = clib_min (tc->srtt + (tc->rttvar << 2), TCP_RTO_MAX);
+
+  return 1;
+}
+
+/**
+ * Dequeue bytes that have been acked and while at it update RTT estimates.
+ */
+static void
+tcp_dequeue_acked (tcp_connection_t * tc, u32 ack)
+{
+  /* Dequeue the newly ACKed bytes */
+  stream_session_dequeue_drop (&tc->connection, tc->bytes_acked);
+
+  /* Update rtt and rto */
+  if (tcp_update_rtt (tc, ack))
+    {
+      /* Good ACK received and valid RTT, make sure retransmit backoff is 0 */
+      tc->rto_boff = 0;
+    }
+}
+
+/** Check if dupack as per RFC5681 Sec. 2 */
+always_inline u8
+tcp_ack_is_dupack (tcp_connection_t * tc, vlib_buffer_t * b, u32 new_snd_wnd)
+{
+  return ((vnet_buffer (b)->tcp.ack_number == tc->snd_una)
+	  && seq_gt (tc->snd_una_max, tc->snd_una)
+	  && (vnet_buffer (b)->tcp.seq_end == vnet_buffer (b)->tcp.seq_number)
+	  && (new_snd_wnd == tc->snd_wnd));
+}
+
+void
+scoreboard_remove_hole (sack_scoreboard_t * sb, sack_scoreboard_hole_t * hole)
+{
+  sack_scoreboard_hole_t *next, *prev;
+
+  if (hole->next != TCP_INVALID_SACK_HOLE_INDEX)
+    {
+      next = pool_elt_at_index (sb->holes, hole->next);
+      next->prev = hole->prev;
+    }
+
+  if (hole->prev != TCP_INVALID_SACK_HOLE_INDEX)
+    {
+      prev = pool_elt_at_index (sb->holes, hole->prev);
+      prev->next = hole->next;
+    }
+  else
+    {
+      sb->head = hole->next;
+    }
+
+  pool_put (sb->holes, hole);
+}
+
+sack_scoreboard_hole_t *
+scoreboard_insert_hole (sack_scoreboard_t * sb, sack_scoreboard_hole_t * prev,
+			u32 start, u32 end)
+{
+  sack_scoreboard_hole_t *hole, *next;
+  u32 hole_index;
+
+  pool_get (sb->holes, hole);
+  memset (hole, 0, sizeof (*hole));
+
+  hole->start = start;
+  hole->end = end;
+  hole_index = hole - sb->holes;
+
+  if (prev)
+    {
+      hole->prev = prev - sb->holes;
+      hole->next = prev->next;
+
+      if ((next = scoreboard_next_hole (sb, hole)))
+	next->prev = hole_index;
+
+      prev->next = hole_index;
+    }
+  else
+    {
+      sb->head = hole_index;
+      hole->prev = TCP_INVALID_SACK_HOLE_INDEX;
+      hole->next = TCP_INVALID_SACK_HOLE_INDEX;
+    }
+
+  return hole;
+}
+
+static void
+tcp_rcv_sacks (tcp_connection_t * tc, u32 ack)
+{
+  sack_scoreboard_t *sb = &tc->sack_sb;
+  sack_block_t *blk, tmp;
+  sack_scoreboard_hole_t *hole, *next_hole;
+  u32 blk_index = 0;
+  int i, j;
+
+  if (!tcp_opts_sack (tc) && sb->head == TCP_INVALID_SACK_HOLE_INDEX)
+    return;
+
+  /* Remove invalid blocks */
+  vec_foreach (blk, tc->opt.sacks)
+  {
+    if (seq_lt (blk->start, blk->end)
+	&& seq_gt (blk->start, tc->snd_una)
+	&& seq_gt (blk->start, ack) && seq_lt (blk->end, tc->snd_nxt))
+      continue;
+
+    vec_del1 (tc->opt.sacks, blk - tc->opt.sacks);
+  }
+
+  /* Add block for cumulative ack */
+  if (seq_gt (ack, tc->snd_una))
+    {
+      tmp.start = tc->snd_una;
+      tmp.end = ack;
+      vec_add1 (tc->opt.sacks, tmp);
+    }
+
+  if (vec_len (tc->opt.sacks) == 0)
+    return;
+
+  /* Make sure blocks are ordered */
+  for (i = 0; i < vec_len (tc->opt.sacks); i++)
+    for (j = i; j < vec_len (tc->opt.sacks); j++)
+      if (seq_lt (tc->opt.sacks[j].start, tc->opt.sacks[i].start))
+	{
+	  tmp = tc->opt.sacks[i];
+	  tc->opt.sacks[i] = tc->opt.sacks[j];
+	  tc->opt.sacks[j] = tmp;
+	}
+
+  /* If no holes, insert the first that covers all outstanding bytes */
+  if (sb->head == TCP_INVALID_SACK_HOLE_INDEX)
+    {
+      scoreboard_insert_hole (sb, 0, tc->snd_una, tc->snd_una_max);
+    }
+
+  /* Walk the holes with the SACK blocks */
+  hole = pool_elt_at_index (sb->holes, sb->head);
+  while (hole && blk_index < vec_len (tc->opt.sacks))
+    {
+      blk = &tc->opt.sacks[blk_index];
+
+      if (seq_leq (blk->start, hole->start))
+	{
+	  /* Block covers hole. Remove hole */
+	  if (seq_geq (blk->end, hole->end))
+	    {
+	      next_hole = scoreboard_next_hole (sb, hole);
+
+	      /* Byte accounting */
+	      if (seq_lt (hole->end, ack))
+		{
+		  /* Bytes lost because snd wnd left edge advances */
+		  if (seq_lt (next_hole->start, ack))
+		    sb->sacked_bytes -= next_hole->start - hole->end;
+		  else
+		    sb->sacked_bytes -= ack - hole->end;
+		}
+	      else
+		{
+		  sb->sacked_bytes += scoreboard_hole_bytes (hole);
+		}
+
+	      scoreboard_remove_hole (sb, hole);
+	      hole = next_hole;
+	    }
+	  /* Partial overlap */
+	  else
+	    {
+	      sb->sacked_bytes += blk->end - hole->start;
+	      hole->start = blk->end;
+	      blk_index++;
+	    }
+	}
+      else
+	{
+	  /* Hole must be split */
+	  if (seq_leq (blk->end, hole->end))
+	    {
+	      sb->sacked_bytes += blk->end - blk->start;
+	      scoreboard_insert_hole (sb, hole, blk->end, hole->end);
+	      hole->end = blk->start - 1;
+	      blk_index++;
+	    }
+	  else
+	    {
+	      sb->sacked_bytes += hole->end - blk->start + 1;
+	      hole->end = blk->start - 1;
+	      hole = scoreboard_next_hole (sb, hole);
+	    }
+	}
+    }
+}
+
+/** Update snd_wnd
+ *
+ * If (SND.WL1 < SEG.SEQ or (SND.WL1 = SEG.SEQ and SND.WL2 =< SEG.ACK)), set
+ * SND.WND <- SEG.WND, set SND.WL1 <- SEG.SEQ, and set SND.WL2 <- SEG.ACK */
+static void
+tcp_update_snd_wnd (tcp_connection_t * tc, u32 seq, u32 ack, u32 snd_wnd)
+{
+  if (tc->snd_wl1 < seq || (tc->snd_wl1 == seq && tc->snd_wl2 <= ack))
+    {
+      tc->snd_wnd = snd_wnd;
+      tc->snd_wl1 = seq;
+      tc->snd_wl2 = ack;
+    }
+}
+
+static void
+tcp_cc_congestion (tcp_connection_t * tc)
+{
+  tc->cc_algo->congestion (tc);
+}
+
+static void
+tcp_cc_recover (tcp_connection_t * tc)
+{
+  if (tcp_in_fastrecovery (tc))
+    {
+      tc->cc_algo->recovered (tc);
+      tcp_recovery_off (tc);
+    }
+  else if (tcp_in_recovery (tc))
+    {
+      tcp_recovery_off (tc);
+      tc->cwnd = tcp_loss_wnd (tc);
+    }
+}
+
+static void
+tcp_cc_rcv_ack (tcp_connection_t * tc)
+{
+  u8 partial_ack;
+
+  if (tcp_in_recovery (tc))
+    {
+      partial_ack = seq_lt (tc->snd_una, tc->snd_una_max);
+      if (!partial_ack)
+	{
+	  /* Clear retransmitted bytes. */
+	  tc->rtx_bytes = 0;
+	  tcp_cc_recover (tc);
+	}
+      else
+	{
+	  /* Clear retransmitted bytes. XXX should we clear all? */
+	  tc->rtx_bytes = 0;
+	  tc->cc_algo->rcv_cong_ack (tc, TCP_CC_PARTIALACK);
+
+	  /* Retransmit first unacked segment */
+	  tcp_retransmit_first_unacked (tc);
+	}
+    }
+  else
+    {
+      tc->cc_algo->rcv_ack (tc);
+    }
+
+  tc->rcv_dupacks = 0;
+  tc->tsecr_last_ack = tc->opt.tsecr;
+}
+
+static void
+tcp_cc_rcv_dupack (tcp_connection_t * tc, u32 ack)
+{
+  ASSERT (tc->snd_una == ack);
+
+  tc->rcv_dupacks++;
+  if (tc->rcv_dupacks == TCP_DUPACK_THRESHOLD)
+    {
+      /* RFC6582 NewReno heuristic to avoid multiple fast retransmits */
+      if (tc->opt.tsecr != tc->tsecr_last_ack)
+	{
+	  tc->rcv_dupacks = 0;
+	  return;
+	}
+
+      tcp_fastrecovery_on (tc);
+
+      /* Handle congestion and dupack */
+      tcp_cc_congestion (tc);
+      tc->cc_algo->rcv_cong_ack (tc, TCP_CC_DUPACK);
+
+      tcp_fast_retransmit (tc);
+
+      /* Post retransmit update cwnd to ssthresh and account for the
+       * three segments that have left the network and should've been
+       * buffered at the receiver */
+      tc->cwnd = tc->ssthresh + TCP_DUPACK_THRESHOLD * tc->snd_mss;
+    }
+  else if (tc->rcv_dupacks > TCP_DUPACK_THRESHOLD)
+    {
+      ASSERT (tcp_in_fastrecovery (tc));
+
+      tc->cc_algo->rcv_cong_ack (tc, TCP_CC_DUPACK);
+    }
+}
+
+void
+tcp_cc_init (tcp_connection_t * tc)
+{
+  tc->cc_algo = tcp_cc_algo_get (TCP_CC_NEWRENO);
+  tc->cc_algo->init (tc);
+}
+
+static int
+tcp_rcv_ack (tcp_connection_t * tc, vlib_buffer_t * b,
+	     tcp_header_t * th, u32 * next, u32 * error)
+{
+  u32 new_snd_wnd;
+
+  /* If the ACK acks something not yet sent (SEG.ACK > SND.NXT) then send an
+   * ACK, drop the segment, and return  */
+  if (seq_gt (vnet_buffer (b)->tcp.ack_number, tc->snd_nxt))
+    {
+      tcp_make_ack (tc, b);
+      *next = tcp_next_output (tc->c_is_ip4);
+      *error = TCP_ERROR_ACK_INVALID;
+      return -1;
+    }
+
+  /* If old ACK, discard */
+  if (seq_lt (vnet_buffer (b)->tcp.ack_number, tc->snd_una))
+    {
+      *error = TCP_ERROR_ACK_OLD;
+      return -1;
+    }
+
+  if (tcp_opts_sack_permitted (&tc->opt))
+    tcp_rcv_sacks (tc, vnet_buffer (b)->tcp.ack_number);
+
+  new_snd_wnd = clib_net_to_host_u32 (th->window) << tc->snd_wscale;
+
+  if (tcp_ack_is_dupack (tc, b, new_snd_wnd))
+    {
+      tcp_cc_rcv_dupack (tc, vnet_buffer (b)->tcp.ack_number);
+      *error = TCP_ERROR_ACK_DUP;
+      return -1;
+    }
+
+  /* Valid ACK */
+  tc->bytes_acked = vnet_buffer (b)->tcp.ack_number - tc->snd_una;
+  tc->snd_una = vnet_buffer (b)->tcp.ack_number;
+
+  /* Dequeue ACKed packet and update RTT */
+  tcp_dequeue_acked (tc, vnet_buffer (b)->tcp.ack_number);
+
+  tcp_update_snd_wnd (tc, vnet_buffer (b)->tcp.seq_number,
+		      vnet_buffer (b)->tcp.ack_number, new_snd_wnd);
+
+  /* Updates congestion control (slow start/congestion avoidance) */
+  tcp_cc_rcv_ack (tc);
+
+  /* If everything has been acked, stop retransmit timer
+   * otherwise update */
+  if (tc->snd_una == tc->snd_una_max)
+    tcp_timer_reset (tc, TCP_TIMER_RETRANSMIT);
+  else
+    tcp_timer_update (tc, TCP_TIMER_RETRANSMIT, tc->rto);
+
+  return 0;
+}
+
+/**
+ * Build SACK list as per RFC2018.
+ *
+ * Makes sure the first block contains the segment that generated the current
+ * ACK and the following ones are the ones most recently reported in SACK
+ * blocks.
+ *
+ * @param tc TCP connection for which the SACK list is updated
+ * @param start Start sequence number of the newest SACK block
+ * @param end End sequence of the newest SACK block
+ */
+static void
+tcp_update_sack_list (tcp_connection_t * tc, u32 start, u32 end)
+{
+  sack_block_t *new_list = 0, block;
+  u32 n_elts;
+  int i;
+  u8 new_head = 0;
+
+  /* If the first segment is ooo add it to the list. Last write might've moved
+   * rcv_nxt over the first segment. */
+  if (seq_lt (tc->rcv_nxt, start))
+    {
+      block.start = start;
+      block.end = end;
+      vec_add1 (new_list, block);
+      new_head = 1;
+    }
+
+  /* Find the blocks still worth keeping. */
+  for (i = 0; i < vec_len (tc->snd_sacks); i++)
+    {
+      /* Discard if:
+       * 1) rcv_nxt advanced beyond current block OR
+       * 2) Segment overlapped by the first segment, i.e., it has been merged
+       *    into it.*/
+      if (seq_leq (tc->snd_sacks[i].start, tc->rcv_nxt)
+	  || seq_leq (tc->snd_sacks[i].start, end))
+	continue;
+
+      /* Save subsequent segments to new SACK list. */
+      n_elts = clib_min (vec_len (tc->snd_sacks) - i,
+			 TCP_MAX_SACK_BLOCKS - new_head);
+      vec_insert_elts (new_list, &tc->snd_sacks[i], n_elts, new_head);
+      break;
+    }
+
+  /* Replace old vector with new one */
+  vec_free (tc->snd_sacks);
+  tc->snd_sacks = new_list;
+}
+
+/** Enqueue data for delivery to application */
+always_inline u32
+tcp_session_enqueue_data (tcp_connection_t * tc, vlib_buffer_t * b,
+			  u16 data_len)
+{
+  int written;
+
+  /* Pure ACK. Update rcv_nxt and be done. */
+  if (PREDICT_FALSE (data_len == 0))
+    {
+      tc->rcv_nxt = vnet_buffer (b)->tcp.seq_end;
+      return TCP_ERROR_PURE_ACK;
+    }
+
+  written = stream_session_enqueue_data (&tc->connection,
+					 vlib_buffer_get_current (b),
+					 data_len, 1 /* queue event */ );
+
+  /* Update rcv_nxt */
+  if (PREDICT_TRUE (written == data_len))
+    {
+      tc->rcv_nxt = vnet_buffer (b)->tcp.seq_end;
+    }
+  /* If more data written than expected, account for out-of-order bytes. */
+  else if (written > data_len)
+    {
+      tc->rcv_nxt = vnet_buffer (b)->tcp.seq_end + written - data_len;
+
+      /* Send ACK confirming the update */
+      tc->flags |= TCP_CONN_SNDACK;
+
+      /* Update SACK list if need be */
+      if (tcp_opts_sack_permitted (&tc->opt))
+	{
+	  /* Remove SACK blocks that have been delivered */
+	  tcp_update_sack_list (tc, tc->rcv_nxt, tc->rcv_nxt);
+	}
+    }
+  else
+    {
+      ASSERT (0);
+      return TCP_ERROR_FIFO_FULL;
+    }
+
+  return TCP_ERROR_ENQUEUED;
+}
+
+/** Enqueue out-of-order data */
+always_inline u32
+tcp_session_enqueue_ooo (tcp_connection_t * tc, vlib_buffer_t * b,
+			 u16 data_len)
+{
+  stream_session_t *s0;
+  u32 offset, seq;
+
+  s0 = stream_session_get (tc->c_s_index, tc->c_thread_index);
+  seq = vnet_buffer (b)->tcp.seq_number;
+  offset = seq - tc->rcv_nxt;
+
+  if (svm_fifo_enqueue_with_offset (s0->server_rx_fifo, s0->pid, offset,
+				    data_len, vlib_buffer_get_current (b)))
+    return TCP_ERROR_FIFO_FULL;
+
+  /* Update SACK list if in use */
+  if (tcp_opts_sack_permitted (&tc->opt))
+    {
+      ooo_segment_t *newest;
+      u32 start, end;
+
+      /* Get the newest segment from the fifo */
+      newest = svm_fifo_newest_ooo_segment (s0->server_rx_fifo);
+      start = tc->rcv_nxt + ooo_segment_offset (s0->server_rx_fifo, newest);
+      end = tc->rcv_nxt + ooo_segment_end_offset (s0->server_rx_fifo, newest);
+
+      tcp_update_sack_list (tc, start, end);
+    }
+
+  return TCP_ERROR_ENQUEUED;
+}
+
+/**
+ * Check if ACK could be delayed. DELACK timer is set only after frame is
+ * processed so this can return true for a full bursts of packets.
+ */
+always_inline int
+tcp_can_delack (tcp_connection_t * tc)
+{
+  /* If there's no DELACK timer set and the last window sent wasn't 0 we
+   * can safely delay. */
+  if (!tcp_timer_is_active (tc, TCP_TIMER_DELACK)
+      && (tc->flags & TCP_CONN_SENT_RCV_WND0) == 0
+      && (tc->flags & TCP_CONN_SNDACK) == 0)
+    return 1;
+
+  return 0;
+}
+
+static int
+tcp_segment_rcv (tcp_main_t * tm, tcp_connection_t * tc, vlib_buffer_t * b,
+		 u16 n_data_bytes, u32 * next0)
+{
+  u32 error = 0;
+
+  /* Handle out-of-order data */
+  if (PREDICT_FALSE (vnet_buffer (b)->tcp.seq_number != tc->rcv_nxt))
+    {
+      error = tcp_session_enqueue_ooo (tc, b, n_data_bytes);
+
+      /* Don't send more than 3 dupacks per burst
+       * XXX decide if this is good */
+      if (tc->snt_dupacks < 3)
+	{
+	  /* RFC2581: Send DUPACK for fast retransmit */
+	  tcp_make_ack (tc, b);
+	  *next0 = tcp_next_output (tc->c_is_ip4);
+
+	  /* Mark as DUPACK. We may filter these in output if
+	   * the burst fills the holes. */
+	  vnet_buffer (b)->tcp.flags = TCP_BUF_FLAG_DUPACK;
+
+	  tc->snt_dupacks++;
+	}
+
+      goto done;
+    }
+
+  /* In order data, enqueue. Fifo figures out by itself if any out-of-order
+   * segments can be enqueued after fifo tail offset changes. */
+  error = tcp_session_enqueue_data (tc, b, n_data_bytes);
+
+  /* Check if ACK can be delayed */
+  if (tcp_can_delack (tc))
+    {
+      /* Nothing to do for pure ACKs */
+      if (n_data_bytes == 0)
+	goto done;
+
+      /* If connection has not been previously marked for delay ack
+       * add it to the list and flag it */
+      if (!tc->flags & TCP_CONN_DELACK)
+	{
+	  vec_add1 (tm->delack_connections[tc->c_thread_index],
+		    tc->c_c_index);
+	  tc->flags |= TCP_CONN_DELACK;
+	}
+    }
+  else
+    {
+      /* Check if a packet has already been enqueued to output for burst.
+       * If yes, then drop this one, otherwise, let it pass through to
+       * output */
+      if ((tc->flags & TCP_CONN_BURSTACK) == 0)
+	{
+	  *next0 = tcp_next_output (tc->c_is_ip4);
+	  tcp_make_ack (tc, b);
+	  error = TCP_ERROR_ENQUEUED;
+
+	  /* TODO: maybe add counter to ensure N acks will be sent/burst */
+	  tc->flags |= TCP_CONN_BURSTACK;
+	}
+    }
+
+done:
+  return error;
+}
+
+void
+delack_timers_init (tcp_main_t * tm, u32 thread_index)
+{
+  tcp_connection_t *tc;
+  u32 i, *conns;
+  tw_timer_wheel_16t_2w_512sl_t *tw;
+
+  tw = &tm->timer_wheels[thread_index];
+  conns = tm->delack_connections[thread_index];
+  for (i = 0; i < vec_len (conns); i++)
+    {
+      tc = pool_elt_at_index (tm->connections[thread_index], conns[i]);
+      ASSERT (0 != tc);
+
+      tc->timers[TCP_TIMER_DELACK]
+	= tw_timer_start_16t_2w_512sl (tw, conns[i],
+				       TCP_TIMER_DELACK, TCP_DELACK_TIME);
+    }
+  vec_reset_length (tm->delack_connections[thread_index]);
+}
+
+always_inline uword
+tcp46_established_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
+			  vlib_frame_t * from_frame, int is_ip4)
+{
+  u32 n_left_from, next_index, *from, *to_next;
+  u32 my_thread_index = vm->cpu_index, errors = 0;
+  tcp_main_t *tm = vnet_get_tcp_main ();
+
+  from = vlib_frame_vector_args (from_frame);
+  n_left_from = from_frame->n_vectors;
+
+  next_index = node->cached_next_index;
+
+  while (n_left_from > 0)
+    {
+      u32 n_left_to_next;
+
+      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+      while (n_left_from > 0 && n_left_to_next > 0)
+	{
+	  u32 bi0;
+	  vlib_buffer_t *b0;
+	  tcp_header_t *th0 = 0;
+	  tcp_connection_t *tc0;
+	  ip4_header_t *ip40;
+	  ip6_header_t *ip60;
+	  u32 n_advance_bytes0, n_data_bytes0;
+	  u32 next0 = TCP_ESTABLISHED_NEXT_DROP, error0 = TCP_ERROR_ENQUEUED;
+
+	  bi0 = from[0];
+	  to_next[0] = bi0;
+	  from += 1;
+	  to_next += 1;
+	  n_left_from -= 1;
+	  n_left_to_next -= 1;
+
+	  b0 = vlib_get_buffer (vm, bi0);
+	  tc0 = tcp_connection_get (vnet_buffer (b0)->tcp.connection_index,
+				    my_thread_index);
+
+	  /* Checksum computed by ipx_local no need to compute again */
+
+	  if (is_ip4)
+	    {
+	      ip40 = vlib_buffer_get_current (b0);
+	      th0 = ip4_next_header (ip40);
+	      n_advance_bytes0 = (ip4_header_bytes (ip40)
+				  + tcp_header_bytes (th0));
+	      n_data_bytes0 = clib_net_to_host_u16 (ip40->length)
+		- n_advance_bytes0;
+	    }
+	  else
+	    {
+	      ip60 = vlib_buffer_get_current (b0);
+	      th0 = ip6_next_header (ip60);
+	      n_advance_bytes0 = tcp_header_bytes (th0);
+	      n_data_bytes0 = clib_net_to_host_u16 (ip60->payload_length)
+		- n_advance_bytes0;
+	      n_advance_bytes0 += sizeof (ip60[0]);
+	    }
+
+	  /* SYNs, FINs and data consume sequence numbers */
+	  vnet_buffer (b0)->tcp.seq_end = vnet_buffer (b0)->tcp.seq_number
+	    + tcp_is_syn (th0) + tcp_is_fin (th0) + n_data_bytes0;
+
+	  /* TODO header prediction fast path */
+
+	  /* 1-4: check SEQ, RST, SYN */
+	  if (PREDICT_FALSE (tcp_segment_validate (vm, tc0, b0, th0, &next0)))
+	    {
+	      error0 = TCP_ERROR_SEGMENT_INVALID;
+	      goto drop;
+	    }
+
+	  /* 5: check the ACK field  */
+	  if (tcp_rcv_ack (tc0, b0, th0, &next0, &error0))
+	    {
+	      goto drop;
+	    }
+
+	  /* 6: check the URG bit TODO */
+
+	  /* 7: process the segment text */
+	  vlib_buffer_advance (b0, n_advance_bytes0);
+	  error0 = tcp_segment_rcv (tm, tc0, b0, n_data_bytes0, &next0);
+
+	  /* 8: check the FIN bit */
+	  if (tcp_fin (th0))
+	    {
+	      /* Send ACK and enter CLOSE-WAIT */
+	      tcp_make_ack (tc0, b0);
+	      tcp_connection_force_ack (tc0, b0);
+	      next0 = tcp_next_output (tc0->c_is_ip4);
+	      tc0->state = TCP_STATE_CLOSE_WAIT;
+	      stream_session_disconnect_notify (&tc0->connection);
+	    }
+
+	drop:
+	  b0->error = node->errors[error0];
+	  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+	    {
+
+	    }
+
+	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+					   n_left_to_next, bi0, next0);
+	}
+
+      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+    }
+
+  errors = session_manager_flush_enqueue_events (my_thread_index);
+  if (errors)
+    {
+      if (is_ip4)
+	vlib_node_increment_counter (vm, tcp4_established_node.index,
+				     TCP_ERROR_EVENT_FIFO_FULL, errors);
+      else
+	vlib_node_increment_counter (vm, tcp6_established_node.index,
+				     TCP_ERROR_EVENT_FIFO_FULL, errors);
+    }
+
+  delack_timers_init (tm, my_thread_index);
+
+  return from_frame->n_vectors;
+}
+
+static uword
+tcp4_established (vlib_main_t * vm, vlib_node_runtime_t * node,
+		  vlib_frame_t * from_frame)
+{
+  return tcp46_established_inline (vm, node, from_frame, 1 /* is_ip4 */ );
+}
+
+static uword
+tcp6_established (vlib_main_t * vm, vlib_node_runtime_t * node,
+		  vlib_frame_t * from_frame)
+{
+  return tcp46_established_inline (vm, node, from_frame, 0 /* is_ip4 */ );
+}
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (tcp4_established_node) =
+{
+  .function = tcp4_established,
+  .name = "tcp4-established",
+  /* Takes a vector of packets. */
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,.error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_ESTABLISHED_N_NEXT,
+  .next_nodes =
+  {
+#define _(s,n) [TCP_ESTABLISHED_NEXT_##s] = n,
+    foreach_tcp_state_next
+#undef _
+  },
+};
+/* *INDENT-ON* */
+
+VLIB_NODE_FUNCTION_MULTIARCH (tcp4_established_node, tcp4_established);
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (tcp6_established_node) =
+{
+  .function = tcp6_established,
+  .name = "tcp6-established",
+  /* Takes a vector of packets. */
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,
+  .error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_ESTABLISHED_N_NEXT,
+  .next_nodes =
+  {
+#define _(s,n) [TCP_ESTABLISHED_NEXT_##s] = n,
+    foreach_tcp_state_next
+#undef _
+  },
+};
+/* *INDENT-ON* */
+
+
+VLIB_NODE_FUNCTION_MULTIARCH (tcp6_established_node, tcp6_established);
+
+vlib_node_registration_t tcp4_syn_sent_node;
+vlib_node_registration_t tcp6_syn_sent_node;
+
+always_inline uword
+tcp46_syn_sent_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
+		       vlib_frame_t * from_frame, int is_ip4)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  u32 n_left_from, next_index, *from, *to_next;
+  u32 my_thread_index = vm->cpu_index, errors = 0;
+  u8 sst = is_ip4 ? SESSION_TYPE_IP4_TCP : SESSION_TYPE_IP6_TCP;
+
+  from = vlib_frame_vector_args (from_frame);
+  n_left_from = from_frame->n_vectors;
+
+  next_index = node->cached_next_index;
+
+  while (n_left_from > 0)
+    {
+      u32 n_left_to_next;
+
+      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+      while (n_left_from > 0 && n_left_to_next > 0)
+	{
+	  u32 bi0, ack0, seq0;
+	  vlib_buffer_t *b0;
+	  tcp_header_t *tcp0 = 0;
+	  tcp_connection_t *tc0;
+	  ip4_header_t *ip40;
+	  ip6_header_t *ip60;
+	  u32 n_advance_bytes0, n_data_bytes0;
+	  tcp_connection_t *new_tc0;
+	  u32 next0 = TCP_SYN_SENT_NEXT_DROP, error0 = TCP_ERROR_ENQUEUED;
+
+	  bi0 = from[0];
+	  to_next[0] = bi0;
+	  from += 1;
+	  to_next += 1;
+	  n_left_from -= 1;
+	  n_left_to_next -= 1;
+
+	  b0 = vlib_get_buffer (vm, bi0);
+	  tc0 =
+	    tcp_half_open_connection_get (vnet_buffer (b0)->
+					  tcp.connection_index);
+
+	  ack0 = vnet_buffer (b0)->tcp.ack_number;
+	  seq0 = vnet_buffer (b0)->tcp.seq_number;
+
+	  /* Checksum computed by ipx_local no need to compute again */
+
+	  if (is_ip4)
+	    {
+	      ip40 = vlib_buffer_get_current (b0);
+	      tcp0 = ip4_next_header (ip40);
+	      n_advance_bytes0 = (ip4_header_bytes (ip40)
+				  + tcp_header_bytes (tcp0));
+	      n_data_bytes0 = clib_net_to_host_u16 (ip40->length)
+		- n_advance_bytes0;
+	    }
+	  else
+	    {
+	      ip60 = vlib_buffer_get_current (b0);
+	      tcp0 = ip6_next_header (ip60);
+	      n_advance_bytes0 = tcp_header_bytes (tcp0);
+	      n_data_bytes0 = clib_net_to_host_u16 (ip60->payload_length)
+		- n_advance_bytes0;
+	      n_advance_bytes0 += sizeof (ip60[0]);
+	    }
+
+	  if (PREDICT_FALSE
+	      (!tcp_ack (tcp0) && !tcp_rst (tcp0) && !tcp_syn (tcp0)))
+	    goto drop;
+
+	  /* SYNs, FINs and data consume sequence numbers */
+	  vnet_buffer (b0)->tcp.seq_end = seq0 + tcp_is_syn (tcp0)
+	    + tcp_is_fin (tcp0) + n_data_bytes0;
+
+	  /*
+	   *  1. check the ACK bit
+	   */
+
+	  /*
+	   *   If the ACK bit is set
+	   *     If SEG.ACK =< ISS, or SEG.ACK > SND.NXT, send a reset (unless
+	   *     the RST bit is set, if so drop the segment and return)
+	   *       <SEQ=SEG.ACK><CTL=RST>
+	   *     and discard the segment.  Return.
+	   *     If SND.UNA =< SEG.ACK =< SND.NXT then the ACK is acceptable.
+	   */
+	  if (tcp_ack (tcp0))
+	    {
+	      if (ack0 <= tc0->iss || ack0 > tc0->snd_nxt)
+		{
+		  if (!tcp_rst (tcp0))
+		    tcp_send_reset (b0, is_ip4);
+
+		  goto drop;
+		}
+
+	      /* Make sure ACK is valid */
+	      if (tc0->snd_una > ack0)
+		goto drop;
+	    }
+
+	  /*
+	   * 2. check the RST bit
+	   */
+
+	  if (tcp_rst (tcp0))
+	    {
+	      /* If ACK is acceptable, signal client that peer is not
+	       * willing to accept connection and drop connection*/
+	      if (tcp_ack (tcp0))
+		{
+		  stream_session_connect_notify (&tc0->connection, sst,
+						 1 /* fail */ );
+		  tcp_connection_cleanup (tc0);
+		}
+	      goto drop;
+	    }
+
+	  /*
+	   * 3. check the security and precedence (skipped)
+	   */
+
+	  /*
+	   * 4. check the SYN bit
+	   */
+
+	  /* No SYN flag. Drop. */
+	  if (!tcp_syn (tcp0))
+	    goto drop;
+
+	  /* Stop connection establishment and retransmit timers */
+	  tcp_timer_reset (tc0, TCP_TIMER_ESTABLISH);
+	  tcp_timer_reset (tc0, TCP_TIMER_RETRANSMIT_SYN);
+
+	  /* Valid SYN or SYN-ACK. Move connection from half-open pool to
+	   * current thread pool. */
+	  pool_get (tm->connections[my_thread_index], new_tc0);
+	  clib_memcpy (new_tc0, tc0, sizeof (*new_tc0));
+
+	  new_tc0->c_thread_index = my_thread_index;
+
+	  /* Cleanup half-open connection XXX lock */
+	  pool_put (tm->half_open_connections, tc0);
+
+	  new_tc0->rcv_nxt = vnet_buffer (b0)->tcp.seq_end;
+	  new_tc0->irs = seq0;
+
+	  /* Parse options */
+	  tcp_options_parse (tcp0, &new_tc0->opt);
+	  tcp_connection_init_vars (new_tc0);
+
+	  if (tcp_opts_tstamp (&new_tc0->opt))
+	    {
+	      new_tc0->tsval_recent = new_tc0->opt.tsval;
+	      new_tc0->tsval_recent_age = tcp_time_now ();
+	    }
+
+	  if (tcp_opts_wscale (&new_tc0->opt))
+	    new_tc0->snd_wscale = new_tc0->opt.wscale;
+
+	  new_tc0->snd_wnd = clib_net_to_host_u32 (tcp0->window)
+	    << new_tc0->snd_wscale;
+	  new_tc0->snd_wl1 = seq0;
+	  new_tc0->snd_wl2 = ack0;
+
+	  /* SYN-ACK: See if we can switch to ESTABLISHED state */
+	  if (tcp_ack (tcp0))
+	    {
+	      /* Our SYN is ACKed: we have iss < ack = snd_una */
+
+	      /* TODO Dequeue acknowledged segments if we support Fast Open */
+	      new_tc0->snd_una = ack0;
+	      new_tc0->state = TCP_STATE_ESTABLISHED;
+
+	      /* Notify app that we have connection */
+	      stream_session_connect_notify (&new_tc0->connection, sst, 0);
+
+	      /* Make sure after data segment processing ACK is sent */
+	      new_tc0->flags |= TCP_CONN_SNDACK;
+	    }
+	  /* SYN: Simultaneous open. Change state to SYN-RCVD and send SYN-ACK */
+	  else
+	    {
+	      new_tc0->state = TCP_STATE_SYN_RCVD;
+
+	      /* Notify app that we have connection XXX */
+	      stream_session_connect_notify (&new_tc0->connection, sst, 0);
+
+	      tcp_make_synack (new_tc0, b0);
+	      next0 = tcp_next_output (is_ip4);
+
+	      goto drop;
+	    }
+
+	  /* Read data, if any */
+	  if (n_data_bytes0)
+	    {
+	      error0 =
+		tcp_segment_rcv (tm, new_tc0, b0, n_data_bytes0, &next0);
+	      if (error0 == TCP_ERROR_PURE_ACK)
+		error0 = TCP_ERROR_SYN_ACKS_RCVD;
+	    }
+	  else
+	    {
+	      tcp_make_ack (new_tc0, b0);
+	      next0 = tcp_next_output (new_tc0->c_is_ip4);
+	    }
+
+	drop:
+
+	  b0->error = error0 ? node->errors[error0] : 0;
+	  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+	    {
+
+	    }
+
+	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+					   n_left_to_next, bi0, next0);
+	}
+
+      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+    }
+
+  errors = session_manager_flush_enqueue_events (my_thread_index);
+  if (errors)
+    {
+      if (is_ip4)
+	vlib_node_increment_counter (vm, tcp4_established_node.index,
+				     TCP_ERROR_EVENT_FIFO_FULL, errors);
+      else
+	vlib_node_increment_counter (vm, tcp6_established_node.index,
+				     TCP_ERROR_EVENT_FIFO_FULL, errors);
+    }
+
+  return from_frame->n_vectors;
+}
+
+static uword
+tcp4_syn_sent (vlib_main_t * vm, vlib_node_runtime_t * node,
+	       vlib_frame_t * from_frame)
+{
+  return tcp46_syn_sent_inline (vm, node, from_frame, 1 /* is_ip4 */ );
+}
+
+static uword
+tcp6_syn_sent_rcv (vlib_main_t * vm, vlib_node_runtime_t * node,
+		   vlib_frame_t * from_frame)
+{
+  return tcp46_syn_sent_inline (vm, node, from_frame, 0 /* is_ip4 */ );
+}
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (tcp4_syn_sent_node) =
+{
+  .function = tcp4_syn_sent,
+  .name = "tcp4-syn-sent",
+  /* Takes a vector of packets. */
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,
+  .error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_SYN_SENT_N_NEXT,
+  .next_nodes =
+  {
+#define _(s,n) [TCP_SYN_SENT_NEXT_##s] = n,
+    foreach_tcp_state_next
+#undef _
+  },
+};
+/* *INDENT-ON* */
+
+VLIB_NODE_FUNCTION_MULTIARCH (tcp4_syn_sent_node, tcp4_syn_sent);
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (tcp6_syn_sent_node) =
+{
+  .function = tcp6_syn_sent_rcv,
+  .name = "tcp6-syn-sent",
+  /* Takes a vector of packets. */
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,
+  .error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_SYN_SENT_N_NEXT,
+  .next_nodes =
+  {
+#define _(s,n) [TCP_SYN_SENT_NEXT_##s] = n,
+    foreach_tcp_state_next
+#undef _
+  }
+,};
+/* *INDENT-ON* */
+
+VLIB_NODE_FUNCTION_MULTIARCH (tcp6_syn_sent_node, tcp6_syn_sent_rcv);
+/**
+ * Handles reception for all states except LISTEN, SYN-SEND and ESTABLISHED
+ * as per RFC793 p. 64
+ */
+always_inline uword
+tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
+			  vlib_frame_t * from_frame, int is_ip4)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  u32 n_left_from, next_index, *from, *to_next;
+  u32 my_thread_index = vm->cpu_index, errors = 0;
+
+  from = vlib_frame_vector_args (from_frame);
+  n_left_from = from_frame->n_vectors;
+
+  next_index = node->cached_next_index;
+
+  while (n_left_from > 0)
+    {
+      u32 n_left_to_next;
+
+      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+      while (n_left_from > 0 && n_left_to_next > 0)
+	{
+	  u32 bi0;
+	  vlib_buffer_t *b0;
+	  tcp_header_t *tcp0 = 0;
+	  tcp_connection_t *tc0;
+	  ip4_header_t *ip40;
+	  ip6_header_t *ip60;
+	  u32 n_advance_bytes0, n_data_bytes0;
+	  u32 next0 = TCP_RCV_PROCESS_NEXT_DROP, error0 = TCP_ERROR_ENQUEUED;
+
+	  bi0 = from[0];
+	  to_next[0] = bi0;
+	  from += 1;
+	  to_next += 1;
+	  n_left_from -= 1;
+	  n_left_to_next -= 1;
+
+	  b0 = vlib_get_buffer (vm, bi0);
+	  tc0 = tcp_connection_get (vnet_buffer (b0)->tcp.connection_index,
+				    my_thread_index);
+
+	  /* Checksum computed by ipx_local no need to compute again */
+
+	  if (is_ip4)
+	    {
+	      ip40 = vlib_buffer_get_current (b0);
+	      tcp0 = ip4_next_header (ip40);
+	      n_advance_bytes0 = (ip4_header_bytes (ip40)
+				  + tcp_header_bytes (tcp0));
+	      n_data_bytes0 = clib_net_to_host_u16 (ip40->length)
+		- n_advance_bytes0;
+	    }
+	  else
+	    {
+	      ip60 = vlib_buffer_get_current (b0);
+	      tcp0 = ip6_next_header (ip60);
+	      n_advance_bytes0 = tcp_header_bytes (tcp0);
+	      n_data_bytes0 = clib_net_to_host_u16 (ip60->payload_length)
+		- n_advance_bytes0;
+	      n_advance_bytes0 += sizeof (ip60[0]);
+	    }
+
+	  /* SYNs, FINs and data consume sequence numbers */
+	  vnet_buffer (b0)->tcp.seq_end = vnet_buffer (b0)->tcp.seq_number
+	    + tcp_is_syn (tcp0) + tcp_is_fin (tcp0) + n_data_bytes0;
+
+	  /*
+	   * Special treatment for CLOSED
+	   */
+	  switch (tc0->state)
+	    {
+	    case TCP_STATE_CLOSED:
+	      goto drop;
+	      break;
+	    }
+
+	  /*
+	   * For all other states (except LISTEN)
+	   */
+
+	  /* 1-4: check SEQ, RST, SYN */
+	  if (PREDICT_FALSE
+	      (tcp_segment_validate (vm, tc0, b0, tcp0, &next0)))
+	    {
+	      error0 = TCP_ERROR_SEGMENT_INVALID;
+	      goto drop;
+	    }
+
+	  /* 5: check the ACK field  */
+	  switch (tc0->state)
+	    {
+	    case TCP_STATE_SYN_RCVD:
+	      /*
+	       * If the segment acknowledgment is not acceptable, form a
+	       * reset segment,
+	       *  <SEQ=SEG.ACK><CTL=RST>
+	       * and send it.
+	       */
+	      if (!tcp_rcv_ack_is_acceptable (tc0, b0))
+		{
+		  tcp_send_reset (b0, is_ip4);
+		  goto drop;
+		}
+	      /* Switch state to ESTABLISHED */
+	      tc0->state = TCP_STATE_ESTABLISHED;
+
+	      /* Initialize session variables */
+	      tc0->snd_una = vnet_buffer (b0)->tcp.ack_number;
+	      tc0->snd_wnd = clib_net_to_host_u32 (tcp0->window)
+		<< tc0->opt.wscale;
+	      tc0->snd_wl1 = vnet_buffer (b0)->tcp.seq_number;
+	      tc0->snd_wl2 = vnet_buffer (b0)->tcp.ack_number;
+
+	      /* Shoulder tap the server */
+	      stream_session_accept_notify (&tc0->connection);
+
+	      tcp_timer_reset (tc0, TCP_TIMER_RETRANSMIT_SYN);
+	      break;
+	    case TCP_STATE_ESTABLISHED:
+	      /* We can get packets in established state here because they
+	       * were enqueued before state change */
+	      if (tcp_rcv_ack (tc0, b0, tcp0, &next0, &error0))
+		goto drop;
+
+	      break;
+	    case TCP_STATE_FIN_WAIT_1:
+	      /* In addition to the processing for the ESTABLISHED state, if
+	       * our FIN is now acknowledged then enter FIN-WAIT-2 and
+	       * continue processing in that state. */
+	      if (tcp_rcv_ack (tc0, b0, tcp0, &next0, &error0))
+		goto drop;
+	      tc0->state = TCP_STATE_FIN_WAIT_2;
+	      /* Stop all timers, 2MSL will be set lower */
+	      tcp_connection_timers_reset (tc0);
+	      break;
+	    case TCP_STATE_FIN_WAIT_2:
+	      /* In addition to the processing for the ESTABLISHED state, if
+	       * the retransmission queue is empty, the user's CLOSE can be
+	       * acknowledged ("ok") but do not delete the TCB. */
+	      if (tcp_rcv_ack (tc0, b0, tcp0, &next0, &error0))
+		goto drop;
+	      /* check if rtx queue is empty and ack CLOSE TODO */
+	      break;
+	    case TCP_STATE_CLOSE_WAIT:
+	      /* Do the same processing as for the ESTABLISHED state. */
+	      if (tcp_rcv_ack (tc0, b0, tcp0, &next0, &error0))
+		goto drop;
+	      break;
+	    case TCP_STATE_CLOSING:
+	      /* In addition to the processing for the ESTABLISHED state, if
+	       * the ACK acknowledges our FIN then enter the TIME-WAIT state,
+	       * otherwise ignore the segment. */
+	      if (tcp_rcv_ack (tc0, b0, tcp0, &next0, &error0))
+		goto drop;
+
+	      /* XXX test that send queue empty */
+	      tc0->state = TCP_STATE_TIME_WAIT;
+	      goto drop;
+
+	      break;
+	    case TCP_STATE_LAST_ACK:
+	      /* The only thing that can arrive in this state is an
+	       * acknowledgment of our FIN. If our FIN is now acknowledged,
+	       * delete the TCB, enter the CLOSED state, and return. */
+
+	      if (!tcp_rcv_ack_is_acceptable (tc0, b0))
+		goto drop;
+
+	      tcp_connection_del (tc0);
+	      goto drop;
+
+	      break;
+	    case TCP_STATE_TIME_WAIT:
+	      /* The only thing that can arrive in this state is a
+	       * retransmission of the remote FIN. Acknowledge it, and restart
+	       * the 2 MSL timeout. */
+
+	      /* TODO */
+	      goto drop;
+	      break;
+	    default:
+	      ASSERT (0);
+	    }
+
+	  /* 6: check the URG bit TODO */
+
+	  /* 7: process the segment text */
+	  switch (tc0->state)
+	    {
+	    case TCP_STATE_ESTABLISHED:
+	    case TCP_STATE_FIN_WAIT_1:
+	    case TCP_STATE_FIN_WAIT_2:
+	      error0 = tcp_segment_rcv (tm, tc0, b0, n_data_bytes0, &next0);
+	      break;
+	    case TCP_STATE_CLOSE_WAIT:
+	    case TCP_STATE_CLOSING:
+	    case TCP_STATE_LAST_ACK:
+	    case TCP_STATE_TIME_WAIT:
+	      /* This should not occur, since a FIN has been received from the
+	       * remote side.  Ignore the segment text. */
+	      break;
+	    }
+
+	  /* 8: check the FIN bit */
+	  if (!tcp_fin (tcp0))
+	    goto drop;
+
+	  switch (tc0->state)
+	    {
+	    case TCP_STATE_ESTABLISHED:
+	    case TCP_STATE_SYN_RCVD:
+	      /* Send FIN-ACK notify app and enter CLOSE-WAIT */
+	      tcp_connection_timers_reset (tc0);
+	      tcp_make_finack (tc0, b0);
+	      next0 = tcp_next_output (tc0->c_is_ip4);
+	      stream_session_disconnect_notify (&tc0->connection);
+	      tc0->state = TCP_STATE_CLOSE_WAIT;
+	      break;
+	    case TCP_STATE_CLOSE_WAIT:
+	    case TCP_STATE_CLOSING:
+	    case TCP_STATE_LAST_ACK:
+	      /* move along .. */
+	      break;
+	    case TCP_STATE_FIN_WAIT_1:
+	      tc0->state = TCP_STATE_TIME_WAIT;
+	      tcp_connection_timers_reset (tc0);
+	      tcp_timer_set (tc0, TCP_TIMER_2MSL, TCP_2MSL_TIME);
+	      break;
+	    case TCP_STATE_FIN_WAIT_2:
+	      /* Got FIN, send ACK! */
+	      tc0->state = TCP_STATE_TIME_WAIT;
+	      tcp_timer_set (tc0, TCP_TIMER_2MSL, TCP_2MSL_TIME);
+	      tcp_make_ack (tc0, b0);
+	      next0 = tcp_next_output (is_ip4);
+	      break;
+	    case TCP_STATE_TIME_WAIT:
+	      /* Remain in the TIME-WAIT state. Restart the 2 MSL time-wait
+	       * timeout.
+	       */
+	      tcp_timer_update (tc0, TCP_TIMER_2MSL, TCP_2MSL_TIME);
+	      break;
+	    }
+
+	  b0->error = error0 ? node->errors[error0] : 0;
+
+	drop:
+	  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+	    {
+
+	    }
+
+	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+					   n_left_to_next, bi0, next0);
+	}
+
+      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+    }
+
+  errors = session_manager_flush_enqueue_events (my_thread_index);
+  if (errors)
+    {
+      if (is_ip4)
+	vlib_node_increment_counter (vm, tcp4_established_node.index,
+				     TCP_ERROR_EVENT_FIFO_FULL, errors);
+      else
+	vlib_node_increment_counter (vm, tcp6_established_node.index,
+				     TCP_ERROR_EVENT_FIFO_FULL, errors);
+    }
+
+  return from_frame->n_vectors;
+}
+
+static uword
+tcp4_rcv_process (vlib_main_t * vm, vlib_node_runtime_t * node,
+		  vlib_frame_t * from_frame)
+{
+  return tcp46_rcv_process_inline (vm, node, from_frame, 1 /* is_ip4 */ );
+}
+
+static uword
+tcp6_rcv_process (vlib_main_t * vm, vlib_node_runtime_t * node,
+		  vlib_frame_t * from_frame)
+{
+  return tcp46_rcv_process_inline (vm, node, from_frame, 0 /* is_ip4 */ );
+}
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (tcp4_rcv_process_node) =
+{
+  .function = tcp4_rcv_process,
+  .name = "tcp4-rcv-process",
+  /* Takes a vector of packets. */
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,
+  .error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_RCV_PROCESS_N_NEXT,
+  .next_nodes =
+  {
+#define _(s,n) [TCP_RCV_PROCESS_NEXT_##s] = n,
+    foreach_tcp_state_next
+#undef _
+  },
+};
+/* *INDENT-ON* */
+
+VLIB_NODE_FUNCTION_MULTIARCH (tcp4_rcv_process_node, tcp4_rcv_process);
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (tcp6_rcv_process_node) =
+{
+  .function = tcp6_rcv_process,
+  .name = "tcp6-rcv-process",
+  /* Takes a vector of packets. */
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,
+  .error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_RCV_PROCESS_N_NEXT,
+  .next_nodes =
+  {
+#define _(s,n) [TCP_RCV_PROCESS_NEXT_##s] = n,
+    foreach_tcp_state_next
+#undef _
+  },
+};
+/* *INDENT-ON* */
+
+VLIB_NODE_FUNCTION_MULTIARCH (tcp6_rcv_process_node, tcp6_rcv_process);
+
+vlib_node_registration_t tcp4_listen_node;
+vlib_node_registration_t tcp6_listen_node;
+
+/**
+ * LISTEN state processing as per RFC 793 p. 65
+ */
+always_inline uword
+tcp46_listen_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
+		     vlib_frame_t * from_frame, int is_ip4)
+{
+  u32 n_left_from, next_index, *from, *to_next;
+  u32 my_thread_index = vm->cpu_index;
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  u8 sst = is_ip4 ? SESSION_TYPE_IP4_TCP : SESSION_TYPE_IP6_TCP;
+
+  from = vlib_frame_vector_args (from_frame);
+  n_left_from = from_frame->n_vectors;
+
+  next_index = node->cached_next_index;
+
+  while (n_left_from > 0)
+    {
+      u32 n_left_to_next;
+
+      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+      while (n_left_from > 0 && n_left_to_next > 0)
+	{
+	  u32 bi0;
+	  vlib_buffer_t *b0;
+	  tcp_header_t *th0 = 0;
+	  tcp_connection_t *lc0;
+	  ip4_header_t *ip40;
+	  ip6_header_t *ip60;
+	  tcp_connection_t *child0;
+	  u32 error0 = TCP_ERROR_SYNS_RCVD, next0 = TCP_LISTEN_NEXT_DROP;
+
+	  bi0 = from[0];
+	  to_next[0] = bi0;
+	  from += 1;
+	  to_next += 1;
+	  n_left_from -= 1;
+	  n_left_to_next -= 1;
+
+	  b0 = vlib_get_buffer (vm, bi0);
+	  lc0 = tcp_listener_get (vnet_buffer (b0)->tcp.connection_index);
+
+	  if (is_ip4)
+	    {
+	      ip40 = vlib_buffer_get_current (b0);
+	      th0 = ip4_next_header (ip40);
+	    }
+	  else
+	    {
+	      ip60 = vlib_buffer_get_current (b0);
+	      th0 = ip6_next_header (ip60);
+	    }
+
+	  /* Create child session. For syn-flood protection use filter */
+
+	  /* 1. first check for an RST */
+	  if (tcp_rst (th0))
+	    goto drop;
+
+	  /* 2. second check for an ACK */
+	  if (tcp_ack (th0))
+	    {
+	      tcp_send_reset (b0, is_ip4);
+	      goto drop;
+	    }
+
+	  /* 3. check for a SYN (did that already) */
+
+	  /* Create child session and send SYN-ACK */
+	  pool_get (tm->connections[my_thread_index], child0);
+	  memset (child0, 0, sizeof (*child0));
+
+	  child0->c_c_index = child0 - tm->connections[my_thread_index];
+	  child0->c_lcl_port = lc0->c_lcl_port;
+	  child0->c_rmt_port = th0->src_port;
+	  child0->c_is_ip4 = is_ip4;
+	  child0->c_thread_index = my_thread_index;
+
+	  if (is_ip4)
+	    {
+	      child0->c_lcl_ip4.as_u32 = ip40->dst_address.as_u32;
+	      child0->c_rmt_ip4.as_u32 = ip40->src_address.as_u32;
+	    }
+	  else
+	    {
+	      clib_memcpy (&child0->c_lcl_ip6, &ip60->dst_address,
+			   sizeof (ip6_address_t));
+	      clib_memcpy (&child0->c_rmt_ip6, &ip60->src_address,
+			   sizeof (ip6_address_t));
+	    }
+
+	  if (stream_session_accept (&child0->connection, lc0->c_s_index, sst,
+				     0 /* notify */ ))
+	    {
+	      error0 = TCP_ERROR_CREATE_SESSION_FAIL;
+	      goto drop;
+	    }
+
+	  tcp_options_parse (th0, &child0->opt);
+	  tcp_connection_init_vars (child0);
+
+	  child0->irs = vnet_buffer (b0)->tcp.seq_number;
+	  child0->rcv_nxt = vnet_buffer (b0)->tcp.seq_number + 1;
+	  child0->state = TCP_STATE_SYN_RCVD;
+
+	  /* RFC1323: TSval timestamps sent on {SYN} and {SYN,ACK}
+	   * segments are used to initialize PAWS. */
+	  if (tcp_opts_tstamp (&child0->opt))
+	    {
+	      child0->tsval_recent = child0->opt.tsval;
+	      child0->tsval_recent_age = tcp_time_now ();
+	    }
+
+	  /* Reuse buffer to make syn-ack and send */
+	  tcp_make_synack (child0, b0);
+	  next0 = tcp_next_output (is_ip4);
+
+	drop:
+	  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+	    {
+
+	    }
+
+	  b0->error = error0 ? node->errors[error0] : 0;
+
+	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+					   n_left_to_next, bi0, next0);
+	}
+
+      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+    }
+  return from_frame->n_vectors;
+}
+
+static uword
+tcp4_listen (vlib_main_t * vm, vlib_node_runtime_t * node,
+	     vlib_frame_t * from_frame)
+{
+  return tcp46_listen_inline (vm, node, from_frame, 1 /* is_ip4 */ );
+}
+
+static uword
+tcp6_listen (vlib_main_t * vm, vlib_node_runtime_t * node,
+	     vlib_frame_t * from_frame)
+{
+  return tcp46_listen_inline (vm, node, from_frame, 0 /* is_ip4 */ );
+}
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (tcp4_listen_node) =
+{
+  .function = tcp4_listen,
+  .name = "tcp4-listen",
+  /* Takes a vector of packets. */
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,
+  .error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_LISTEN_N_NEXT,
+  .next_nodes =
+  {
+#define _(s,n) [TCP_LISTEN_NEXT_##s] = n,
+    foreach_tcp_state_next
+#undef _
+  },
+};
+/* *INDENT-ON* */
+
+VLIB_NODE_FUNCTION_MULTIARCH (tcp4_listen_node, tcp4_listen);
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (tcp6_listen_node) =
+{
+  .function = tcp6_listen,
+  .name = "tcp6-listen",
+  /* Takes a vector of packets. */
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,
+  .error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_LISTEN_N_NEXT,
+  .next_nodes =
+  {
+#define _(s,n) [TCP_LISTEN_NEXT_##s] = n,
+    foreach_tcp_state_next
+#undef _
+  },
+};
+/* *INDENT-ON* */
+
+VLIB_NODE_FUNCTION_MULTIARCH (tcp6_listen_node, tcp6_listen);
+
+vlib_node_registration_t tcp4_input_node;
+vlib_node_registration_t tcp6_input_node;
+
+typedef enum _tcp_input_next
+{
+  TCP_INPUT_NEXT_DROP,
+  TCP_INPUT_NEXT_LISTEN,
+  TCP_INPUT_NEXT_RCV_PROCESS,
+  TCP_INPUT_NEXT_SYN_SENT,
+  TCP_INPUT_NEXT_ESTABLISHED,
+  TCP_INPUT_NEXT_RESET,
+  TCP_INPUT_N_NEXT
+} tcp_input_next_t;
+
+#define foreach_tcp4_input_next                 \
+  _ (DROP, "error-drop")                        \
+  _ (LISTEN, "tcp4-listen")                     \
+  _ (RCV_PROCESS, "tcp4-rcv-process")           \
+  _ (SYN_SENT, "tcp4-syn-sent")                 \
+  _ (ESTABLISHED, "tcp4-established")		\
+  _ (RESET, "tcp4-reset")
+
+#define foreach_tcp6_input_next                 \
+  _ (DROP, "error-drop")                        \
+  _ (LISTEN, "tcp6-listen")                     \
+  _ (RCV_PROCESS, "tcp6-rcv-process")           \
+  _ (SYN_SENT, "tcp6-syn-sent")                 \
+  _ (ESTABLISHED, "tcp6-established")		\
+  _ (RESET, "tcp6-reset")
+
+typedef struct
+{
+  u16 src_port;
+  u16 dst_port;
+  u8 state;
+} tcp_rx_trace_t;
+
+const char *tcp_fsm_states[] = {
+#define _(sym, str) str,
+  foreach_tcp_fsm_state
+#undef _
+};
+
+u8 *
+format_tcp_state (u8 * s, va_list * args)
+{
+  tcp_state_t *state = va_arg (*args, tcp_state_t *);
+
+  if (state[0] < TCP_N_STATES)
+    s = format (s, "%s", tcp_fsm_states[state[0]]);
+  else
+    s = format (s, "UNKNOWN");
+
+  return s;
+}
+
+u8 *
+format_tcp_rx_trace (u8 * s, va_list * args)
+{
+  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+  tcp_rx_trace_t *t = va_arg (*args, tcp_rx_trace_t *);
+
+  s = format (s, "TCP: src-port %d dst-port %U%s\n",
+	      clib_net_to_host_u16 (t->src_port),
+	      clib_net_to_host_u16 (t->dst_port), format_tcp_state, t->state);
+
+  return s;
+}
+
+#define filter_flags (TCP_FLAG_SYN|TCP_FLAG_ACK|TCP_FLAG_RST|TCP_FLAG_FIN)
+
+always_inline uword
+tcp46_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
+		    vlib_frame_t * from_frame, int is_ip4)
+{
+  u32 n_left_from, next_index, *from, *to_next;
+  u32 my_thread_index = vm->cpu_index;
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  session_manager_main_t *ssm = vnet_get_session_manager_main ();
+
+  from = vlib_frame_vector_args (from_frame);
+  n_left_from = from_frame->n_vectors;
+
+  next_index = node->cached_next_index;
+
+  while (n_left_from > 0)
+    {
+      u32 n_left_to_next;
+
+      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+      while (n_left_from > 0 && n_left_to_next > 0)
+	{
+	  u32 bi0;
+	  vlib_buffer_t *b0;
+	  tcp_header_t *tcp0 = 0;
+	  tcp_connection_t *tc0;
+	  ip4_header_t *ip40;
+	  ip6_header_t *ip60;
+	  u32 error0 = TCP_ERROR_NO_LISTENER, next0 = TCP_INPUT_NEXT_DROP;
+	  u8 flags0;
+
+	  bi0 = from[0];
+	  to_next[0] = bi0;
+	  from += 1;
+	  to_next += 1;
+	  n_left_from -= 1;
+	  n_left_to_next -= 1;
+
+	  b0 = vlib_get_buffer (vm, bi0);
+
+	  if (is_ip4)
+	    {
+	      ip40 = vlib_buffer_get_current (b0);
+	      tcp0 = ip4_next_header (ip40);
+
+	      /* lookup session */
+	      tc0 =
+		(tcp_connection_t *) stream_session_lookup_transport4 (ssm,
+								       &ip40->dst_address,
+								       &ip40->src_address,
+								       tcp0->dst_port,
+								       tcp0->src_port,
+								       SESSION_TYPE_IP4_TCP,
+								       my_thread_index);
+	    }
+	  else
+	    {
+	      ip60 = vlib_buffer_get_current (b0);
+	      tcp0 = ip6_next_header (ip60);
+	      tc0 =
+		(tcp_connection_t *) stream_session_lookup_transport6 (ssm,
+								       &ip60->src_address,
+								       &ip60->dst_address,
+								       tcp0->src_port,
+								       tcp0->dst_port,
+								       SESSION_TYPE_IP6_TCP,
+								       my_thread_index);
+	    }
+
+	  /* Session exists */
+	  if (PREDICT_TRUE (0 != tc0))
+	    {
+	      /* Save connection index */
+	      vnet_buffer (b0)->tcp.connection_index = tc0->c_c_index;
+	      vnet_buffer (b0)->tcp.seq_number =
+		clib_net_to_host_u32 (tcp0->seq_number);
+	      vnet_buffer (b0)->tcp.ack_number =
+		clib_net_to_host_u32 (tcp0->ack_number);
+
+	      flags0 = tcp0->flags & filter_flags;
+	      next0 = tm->dispatch_table[tc0->state][flags0].next;
+	      error0 = tm->dispatch_table[tc0->state][flags0].error;
+
+	      if (PREDICT_FALSE (error0 == TCP_ERROR_DISPATCH))
+		{
+		  /* Overload tcp flags to store state */
+		  vnet_buffer (b0)->tcp.flags = tc0->state;
+		}
+	    }
+	  else
+	    {
+	      /* Send reset */
+	      next0 = TCP_INPUT_NEXT_RESET;
+	      error0 = TCP_ERROR_NO_LISTENER;
+	      vnet_buffer (b0)->tcp.flags = 0;
+	    }
+
+	  b0->error = error0 ? node->errors[error0] : 0;
+
+	  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+	    {
+
+	    }
+
+	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+					   n_left_to_next, bi0, next0);
+	}
+
+      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+    }
+
+  return from_frame->n_vectors;
+}
+
+static uword
+tcp4_input (vlib_main_t * vm, vlib_node_runtime_t * node,
+	    vlib_frame_t * from_frame)
+{
+  return tcp46_input_inline (vm, node, from_frame, 1 /* is_ip4 */ );
+}
+
+static uword
+tcp6_input (vlib_main_t * vm, vlib_node_runtime_t * node,
+	    vlib_frame_t * from_frame)
+{
+  return tcp46_input_inline (vm, node, from_frame, 0 /* is_ip4 */ );
+}
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (tcp4_input_node) =
+{
+  .function = tcp4_input,
+  .name = "tcp4-input",
+  /* Takes a vector of packets. */
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,
+  .error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_INPUT_N_NEXT,
+  .next_nodes =
+  {
+#define _(s,n) [TCP_INPUT_NEXT_##s] = n,
+    foreach_tcp4_input_next
+#undef _
+  },
+  .format_buffer = format_tcp_header,
+  .format_trace = format_tcp_rx_trace,
+};
+/* *INDENT-ON* */
+
+VLIB_NODE_FUNCTION_MULTIARCH (tcp4_input_node, tcp4_input);
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (tcp6_input_node) =
+{
+  .function = tcp6_input,
+  .name = "tcp6-input",
+  /* Takes a vector of packets. */
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,
+  .error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_INPUT_N_NEXT,
+  .next_nodes =
+  {
+#define _(s,n) [TCP_INPUT_NEXT_##s] = n,
+    foreach_tcp6_input_next
+#undef _
+  },
+  .format_buffer = format_tcp_header,
+  .format_trace = format_tcp_rx_trace,
+};
+/* *INDENT-ON* */
+
+VLIB_NODE_FUNCTION_MULTIARCH (tcp6_input_node, tcp6_input);
+void
+tcp_update_time (f64 now, u32 thread_index)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  tw_timer_expire_timers_16t_2w_512sl (&tm->timer_wheels[thread_index], now);
+}
+
+static void
+tcp_dispatch_table_init (tcp_main_t * tm)
+{
+  int i, j;
+  for (i = 0; i < ARRAY_LEN (tm->dispatch_table); i++)
+    for (j = 0; j < ARRAY_LEN (tm->dispatch_table[i]); j++)
+      {
+	tm->dispatch_table[i][j].next = TCP_INPUT_NEXT_DROP;
+	tm->dispatch_table[i][j].error = TCP_ERROR_DISPATCH;
+      }
+
+#define _(t,f,n,e)                                           	\
+do {                                                       	\
+    tm->dispatch_table[TCP_STATE_##t][f].next = (n);         	\
+    tm->dispatch_table[TCP_STATE_##t][f].error = (e);        	\
+} while (0)
+
+  /* SYNs for new connections -> tcp-listen. */
+  _(LISTEN, TCP_FLAG_SYN, TCP_INPUT_NEXT_LISTEN, TCP_ERROR_NONE);
+  /* ACK for for a SYN-ACK -> tcp-rcv-process. */
+  _(SYN_RCVD, TCP_FLAG_ACK, TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
+  /* SYN-ACK for a SYN */
+  _(SYN_SENT, TCP_FLAG_SYN | TCP_FLAG_ACK, TCP_INPUT_NEXT_SYN_SENT,
+    TCP_ERROR_NONE);
+  _(SYN_SENT, TCP_FLAG_ACK, TCP_INPUT_NEXT_SYN_SENT, TCP_ERROR_NONE);
+  _(SYN_SENT, TCP_FLAG_RST, TCP_INPUT_NEXT_SYN_SENT, TCP_ERROR_NONE);
+  _(SYN_SENT, TCP_FLAG_RST | TCP_FLAG_ACK, TCP_INPUT_NEXT_SYN_SENT,
+    TCP_ERROR_NONE);
+  /* ACK for for established connection -> tcp-established. */
+  _(ESTABLISHED, TCP_FLAG_ACK, TCP_INPUT_NEXT_ESTABLISHED, TCP_ERROR_NONE);
+  /* FIN for for established connection -> tcp-established. */
+  _(ESTABLISHED, TCP_FLAG_FIN, TCP_INPUT_NEXT_ESTABLISHED, TCP_ERROR_NONE);
+  _(ESTABLISHED, TCP_FLAG_FIN | TCP_FLAG_ACK, TCP_INPUT_NEXT_ESTABLISHED,
+    TCP_ERROR_NONE);
+  /* ACK or FIN-ACK to our FIN */
+  _(FIN_WAIT_1, TCP_FLAG_ACK, TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
+  _(FIN_WAIT_1, TCP_FLAG_ACK | TCP_FLAG_FIN, TCP_INPUT_NEXT_RCV_PROCESS,
+    TCP_ERROR_NONE);
+  /* FIN in reply to our FIN from the other side */
+  _(FIN_WAIT_1, TCP_FLAG_FIN, TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
+  /* FIN confirming that the peer (app) has closed */
+  _(FIN_WAIT_2, TCP_FLAG_FIN, TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
+  _(FIN_WAIT_2, TCP_FLAG_FIN | TCP_FLAG_ACK, TCP_INPUT_NEXT_RCV_PROCESS,
+    TCP_ERROR_NONE);
+  _(LAST_ACK, TCP_FLAG_ACK, TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
+#undef _
+}
+
+clib_error_t *
+tcp_input_init (vlib_main_t * vm)
+{
+  clib_error_t *error = 0;
+  tcp_main_t *tm = vnet_get_tcp_main ();
+
+  if ((error = vlib_call_init_function (vm, tcp_init)))
+    return error;
+
+  /* Initialize dispatch table. */
+  tcp_dispatch_table_init (tm);
+
+  return error;
+}
+
+VLIB_INIT_FUNCTION (tcp_input_init);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/tcp/tcp_newreno.c b/src/vnet/tcp/tcp_newreno.c
new file mode 100644
index 0000000..856dffe
--- /dev/null
+++ b/src/vnet/tcp/tcp_newreno.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/tcp/tcp.h>
+
+void
+newreno_congestion (tcp_connection_t * tc)
+{
+  tc->prev_ssthresh = tc->ssthresh;
+  tc->ssthresh = clib_max (tcp_flight_size (tc) / 2, 2 * tc->snd_mss);
+}
+
+void
+newreno_recovered (tcp_connection_t * tc)
+{
+  tc->cwnd = tc->ssthresh;
+}
+
+void
+newreno_rcv_ack (tcp_connection_t * tc)
+{
+  if (tcp_in_slowstart (tc))
+    {
+      tc->cwnd += clib_min (tc->snd_mss, tc->bytes_acked);
+    }
+  else
+    {
+      /* Round up to 1 if needed */
+      tc->cwnd += clib_max (tc->snd_mss * tc->snd_mss / tc->cwnd, 1);
+    }
+}
+
+void
+newreno_rcv_cong_ack (tcp_connection_t * tc, tcp_cc_ack_t ack_type)
+{
+  if (ack_type == TCP_CC_DUPACK)
+    {
+      tc->cwnd += tc->snd_mss;
+    }
+  else if (ack_type == TCP_CC_PARTIALACK)
+    {
+      tc->cwnd -= tc->bytes_acked;
+      if (tc->bytes_acked > tc->snd_mss)
+	tc->bytes_acked += tc->snd_mss;
+    }
+}
+
+void
+newreno_conn_init (tcp_connection_t * tc)
+{
+  tc->ssthresh = tc->snd_wnd;
+  tc->cwnd = tcp_initial_cwnd (tc);
+}
+
+const static tcp_cc_algorithm_t tcp_newreno = {
+  .congestion = newreno_congestion,
+  .recovered = newreno_recovered,
+  .rcv_ack = newreno_rcv_ack,
+  .rcv_cong_ack = newreno_rcv_cong_ack,
+  .init = newreno_conn_init
+};
+
+clib_error_t *
+newreno_init (vlib_main_t * vm)
+{
+  clib_error_t *error = 0;
+
+  tcp_cc_algo_register (TCP_CC_NEWRENO, &tcp_newreno);
+
+  return error;
+}
+
+VLIB_INIT_FUNCTION (newreno_init);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c
new file mode 100644
index 0000000..dbcf1f7
--- /dev/null
+++ b/src/vnet/tcp/tcp_output.c
@@ -0,0 +1,1412 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/tcp/tcp.h>
+#include <vnet/lisp-cp/packets.h>
+
+vlib_node_registration_t tcp4_output_node;
+vlib_node_registration_t tcp6_output_node;
+
+typedef enum _tcp_output_nect
+{
+  TCP_OUTPUT_NEXT_DROP,
+  TCP_OUTPUT_NEXT_IP_LOOKUP,
+  TCP_OUTPUT_N_NEXT
+} tcp_output_next_t;
+
+#define foreach_tcp4_output_next              	\
+  _ (DROP, "error-drop")                        \
+  _ (IP_LOOKUP, "ip4-lookup")
+
+#define foreach_tcp6_output_next              	\
+  _ (DROP, "error-drop")                        \
+  _ (IP_LOOKUP, "ip6-lookup")
+
+static char *tcp_error_strings[] = {
+#define tcp_error(n,s) s,
+#include <vnet/tcp/tcp_error.def>
+#undef tcp_error
+};
+
+typedef struct
+{
+  u16 src_port;
+  u16 dst_port;
+  u8 state;
+} tcp_tx_trace_t;
+
+u16 dummy_mtu = 400;
+
+u8 *
+format_tcp_tx_trace (u8 * s, va_list * args)
+{
+  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+
+  s = format (s, "TBD\n");
+
+  return s;
+}
+
+void
+tcp_set_snd_mss (tcp_connection_t * tc)
+{
+  u16 snd_mss;
+
+  /* TODO find our iface MTU */
+  snd_mss = dummy_mtu;
+
+  /* TODO cache mss and consider PMTU discovery */
+  snd_mss = tc->opt.mss < snd_mss ? tc->opt.mss : snd_mss;
+
+  tc->snd_mss = snd_mss;
+
+  if (tc->snd_mss == 0)
+    {
+      clib_warning ("snd mss is 0");
+      tc->snd_mss = dummy_mtu;
+    }
+}
+
+static u8
+tcp_window_compute_scale (u32 available_space)
+{
+  u8 wnd_scale = 0;
+  while (wnd_scale < TCP_MAX_WND_SCALE
+	 && (available_space >> wnd_scale) > TCP_WND_MAX)
+    wnd_scale++;
+  return wnd_scale;
+}
+
+/**
+ * Compute initial window and scale factor. As per RFC1323, window field in
+ * SYN and SYN-ACK segments is never scaled.
+ */
+u32
+tcp_initial_window_to_advertise (tcp_connection_t * tc)
+{
+  u32 available_space;
+
+  /* Initial wnd for SYN. Fifos are not allocated yet.
+   * Use some predefined value */
+  if (tc->state != TCP_STATE_SYN_RCVD)
+    {
+      return TCP_DEFAULT_RX_FIFO_SIZE;
+    }
+
+  available_space = stream_session_max_enqueue (&tc->connection);
+  tc->rcv_wscale = tcp_window_compute_scale (available_space);
+  tc->rcv_wnd = clib_min (available_space, TCP_WND_MAX << tc->rcv_wscale);
+
+  return clib_min (tc->rcv_wnd, TCP_WND_MAX);
+}
+
+/**
+ * Compute and return window to advertise, scaled as per RFC1323
+ */
+u32
+tcp_window_to_advertise (tcp_connection_t * tc, tcp_state_t state)
+{
+  u32 available_space, wnd, scaled_space;
+
+  if (state != TCP_STATE_ESTABLISHED)
+    return tcp_initial_window_to_advertise (tc);
+
+  available_space = stream_session_max_enqueue (&tc->connection);
+  scaled_space = available_space >> tc->rcv_wscale;
+
+  /* Need to update scale */
+  if (PREDICT_FALSE ((scaled_space == 0 && available_space != 0))
+      || (scaled_space >= TCP_WND_MAX))
+    tc->rcv_wscale = tcp_window_compute_scale (available_space);
+
+  wnd = clib_min (available_space, TCP_WND_MAX << tc->rcv_wscale);
+  tc->rcv_wnd = wnd;
+
+  return wnd >> tc->rcv_wscale;
+}
+
+/**
+ * Write TCP options to segment.
+ */
+u32
+tcp_options_write (u8 * data, tcp_options_t * opts)
+{
+  u32 opts_len = 0;
+  u32 buf, seq_len = 4;
+
+  if (tcp_opts_mss (opts))
+    {
+      *data++ = TCP_OPTION_MSS;
+      *data++ = TCP_OPTION_LEN_MSS;
+      buf = clib_host_to_net_u16 (opts->mss);
+      clib_memcpy (data, &buf, sizeof (opts->mss));
+      data += sizeof (opts->mss);
+      opts_len += TCP_OPTION_LEN_MSS;
+    }
+
+  if (tcp_opts_wscale (opts))
+    {
+      *data++ = TCP_OPTION_WINDOW_SCALE;
+      *data++ = TCP_OPTION_LEN_WINDOW_SCALE;
+      *data++ = opts->wscale;
+      opts_len += TCP_OPTION_LEN_WINDOW_SCALE;
+    }
+
+  if (tcp_opts_sack_permitted (opts))
+    {
+      *data++ = TCP_OPTION_SACK_PERMITTED;
+      *data++ = TCP_OPTION_LEN_SACK_PERMITTED;
+      opts_len += TCP_OPTION_LEN_SACK_PERMITTED;
+    }
+
+  if (tcp_opts_tstamp (opts))
+    {
+      *data++ = TCP_OPTION_TIMESTAMP;
+      *data++ = TCP_OPTION_LEN_TIMESTAMP;
+      buf = clib_host_to_net_u32 (opts->tsval);
+      clib_memcpy (data, &buf, sizeof (opts->tsval));
+      data += sizeof (opts->tsval);
+      buf = clib_host_to_net_u32 (opts->tsecr);
+      clib_memcpy (data, &buf, sizeof (opts->tsecr));
+      data += sizeof (opts->tsecr);
+      opts_len += TCP_OPTION_LEN_TIMESTAMP;
+    }
+
+  if (tcp_opts_sack (opts))
+    {
+      int i;
+      u32 n_sack_blocks = clib_min (vec_len (opts->sacks),
+				    TCP_OPTS_MAX_SACK_BLOCKS);
+
+      if (n_sack_blocks != 0)
+	{
+	  *data++ = TCP_OPTION_SACK_BLOCK;
+	  *data++ = 2 + n_sack_blocks * TCP_OPTION_LEN_SACK_BLOCK;
+	  for (i = 0; i < n_sack_blocks; i++)
+	    {
+	      buf = clib_host_to_net_u32 (opts->sacks[i].start);
+	      clib_memcpy (data, &buf, seq_len);
+	      data += seq_len;
+	      buf = clib_host_to_net_u32 (opts->sacks[i].end);
+	      clib_memcpy (data, &buf, seq_len);
+	      data += seq_len;
+	    }
+	  opts_len += 2 + n_sack_blocks * TCP_OPTION_LEN_SACK_BLOCK;
+	}
+    }
+
+  /* Terminate TCP options */
+  if (opts_len % 4)
+    {
+      *data++ = TCP_OPTION_EOL;
+      opts_len += TCP_OPTION_LEN_EOL;
+    }
+
+  /* Pad with zeroes to a u32 boundary */
+  while (opts_len % 4)
+    {
+      *data++ = TCP_OPTION_NOOP;
+      opts_len += TCP_OPTION_LEN_NOOP;
+    }
+  return opts_len;
+}
+
+always_inline int
+tcp_make_syn_options (tcp_options_t * opts, u32 initial_wnd)
+{
+  u8 len = 0;
+
+  opts->flags |= TCP_OPTS_FLAG_MSS;
+  opts->mss = dummy_mtu;	/*XXX discover that */
+  len += TCP_OPTION_LEN_MSS;
+
+  opts->flags |= TCP_OPTS_FLAG_WSCALE;
+  opts->wscale = tcp_window_compute_scale (initial_wnd);
+  len += TCP_OPTION_LEN_WINDOW_SCALE;
+
+  opts->flags |= TCP_OPTS_FLAG_TSTAMP;
+  opts->tsval = tcp_time_now ();
+  opts->tsecr = 0;
+  len += TCP_OPTION_LEN_TIMESTAMP;
+
+  opts->flags |= TCP_OPTS_FLAG_SACK_PERMITTED;
+  len += TCP_OPTION_LEN_SACK_PERMITTED;
+
+  /* Align to needed boundary */
+  len += (TCP_OPTS_ALIGN - len % TCP_OPTS_ALIGN) % TCP_OPTS_ALIGN;
+  return len;
+}
+
+always_inline int
+tcp_make_synack_options (tcp_connection_t * tc, tcp_options_t * opts)
+{
+  u8 len = 0;
+
+  opts->flags |= TCP_OPTS_FLAG_MSS;
+  opts->mss = dummy_mtu;	/*XXX discover that */
+  len += TCP_OPTION_LEN_MSS;
+
+  if (tcp_opts_wscale (&tc->opt))
+    {
+      opts->flags |= TCP_OPTS_FLAG_WSCALE;
+      opts->wscale = tc->rcv_wscale;
+      len += TCP_OPTION_LEN_WINDOW_SCALE;
+    }
+
+  if (tcp_opts_tstamp (&tc->opt))
+    {
+      opts->flags |= TCP_OPTS_FLAG_TSTAMP;
+      opts->tsval = tcp_time_now ();
+      opts->tsecr = tc->tsval_recent;
+      len += TCP_OPTION_LEN_TIMESTAMP;
+    }
+
+  if (tcp_opts_sack_permitted (&tc->opt))
+    {
+      opts->flags |= TCP_OPTS_FLAG_SACK_PERMITTED;
+      len += TCP_OPTION_LEN_SACK_PERMITTED;
+    }
+
+  /* Align to needed boundary */
+  len += (TCP_OPTS_ALIGN - len % TCP_OPTS_ALIGN) % TCP_OPTS_ALIGN;
+  return len;
+}
+
+always_inline int
+tcp_make_established_options (tcp_connection_t * tc, tcp_options_t * opts)
+{
+  u8 len = 0;
+
+  opts->flags = 0;
+
+  if (tcp_opts_tstamp (&tc->opt))
+    {
+      opts->flags |= TCP_OPTS_FLAG_TSTAMP;
+      opts->tsval = tcp_time_now ();
+      opts->tsecr = tc->tsval_recent;
+      len += TCP_OPTION_LEN_TIMESTAMP;
+    }
+  if (tcp_opts_sack_permitted (&tc->opt))
+    {
+      if (vec_len (tc->snd_sacks))
+	{
+	  opts->flags |= TCP_OPTS_FLAG_SACK;
+	  opts->sacks = tc->snd_sacks;
+	  opts->n_sack_blocks = vec_len (tc->snd_sacks);
+	  len += 2 + TCP_OPTION_LEN_SACK_BLOCK * opts->n_sack_blocks;
+	}
+    }
+
+  /* Align to needed boundary */
+  len += (TCP_OPTS_ALIGN - len % TCP_OPTS_ALIGN) % TCP_OPTS_ALIGN;
+  return len;
+}
+
+always_inline int
+tcp_make_options (tcp_connection_t * tc, tcp_options_t * opts,
+		  tcp_state_t state)
+{
+  switch (state)
+    {
+    case TCP_STATE_ESTABLISHED:
+    case TCP_STATE_FIN_WAIT_1:
+      return tcp_make_established_options (tc, opts);
+    case TCP_STATE_SYN_RCVD:
+      return tcp_make_synack_options (tc, opts);
+    case TCP_STATE_SYN_SENT:
+      return tcp_make_syn_options (opts,
+				   tcp_initial_window_to_advertise (tc));
+    default:
+      clib_warning ("Not handled!");
+      return 0;
+    }
+}
+
+#define tcp_get_free_buffer_index(tm, bidx)                             \
+do {                                                                    \
+  u32 *my_tx_buffers, n_free_buffers;                                   \
+  u32 cpu_index = tm->vlib_main->cpu_index;                             \
+  my_tx_buffers = tm->tx_buffers[cpu_index];                            \
+  if (PREDICT_FALSE(vec_len (my_tx_buffers) == 0))                      \
+    {                                                                   \
+      n_free_buffers = 32;      /* TODO config or macro */              \
+      vec_validate (my_tx_buffers, n_free_buffers - 1);                 \
+      _vec_len(my_tx_buffers) = vlib_buffer_alloc_from_free_list (      \
+          tm->vlib_main, my_tx_buffers, n_free_buffers,                 \
+          VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);                         \
+      tm->tx_buffers[cpu_index] = my_tx_buffers;                        \
+    }                                                                   \
+  /* buffer shortage */                                                 \
+  if (PREDICT_FALSE (vec_len (my_tx_buffers) == 0))                     \
+    return;                                                             \
+  *bidx = my_tx_buffers[_vec_len (my_tx_buffers)-1];                    \
+  _vec_len (my_tx_buffers) -= 1;                                        \
+} while (0)
+
+always_inline void
+tcp_reuse_buffer (vlib_main_t * vm, vlib_buffer_t * b)
+{
+  vlib_buffer_t *it = b;
+  do
+    {
+      it->current_data = 0;
+      it->current_length = 0;
+      it->total_length_not_including_first_buffer = 0;
+    }
+  while ((it->flags & VLIB_BUFFER_NEXT_PRESENT)
+	 && (it = vlib_get_buffer (vm, it->next_buffer)));
+
+  /* Leave enough space for headers */
+  vlib_buffer_make_headroom (b, MAX_HDRS_LEN);
+}
+
+/**
+ * Prepare ACK
+ */
+void
+tcp_make_ack_i (tcp_connection_t * tc, vlib_buffer_t * b, tcp_state_t state,
+		u8 flags)
+{
+  tcp_options_t _snd_opts, *snd_opts = &_snd_opts;
+  u8 tcp_opts_len, tcp_hdr_opts_len;
+  tcp_header_t *th;
+  u16 wnd;
+
+  wnd = tcp_window_to_advertise (tc, state);
+
+  /* Make and write options */
+  tcp_opts_len = tcp_make_established_options (tc, snd_opts);
+  tcp_hdr_opts_len = tcp_opts_len + sizeof (tcp_header_t);
+
+  th = vlib_buffer_push_tcp (b, tc->c_lcl_port, tc->c_rmt_port, tc->snd_nxt,
+			     tc->rcv_nxt, tcp_hdr_opts_len, flags, wnd);
+
+  tcp_options_write ((u8 *) (th + 1), snd_opts);
+
+  /* Mark as ACK */
+  vnet_buffer (b)->tcp.connection_index = tc->c_c_index;
+}
+
+/**
+ * Convert buffer to ACK
+ */
+void
+tcp_make_ack (tcp_connection_t * tc, vlib_buffer_t * b)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  vlib_main_t *vm = tm->vlib_main;
+
+  tcp_reuse_buffer (vm, b);
+  tcp_make_ack_i (tc, b, TCP_STATE_ESTABLISHED, TCP_FLAG_ACK);
+  vnet_buffer (b)->tcp.flags = TCP_BUF_FLAG_ACK;
+}
+
+/**
+ * Convert buffer to FIN-ACK
+ */
+void
+tcp_make_finack (tcp_connection_t * tc, vlib_buffer_t * b)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  vlib_main_t *vm = tm->vlib_main;
+
+  tcp_reuse_buffer (vm, b);
+  tcp_make_ack_i (tc, b, TCP_STATE_ESTABLISHED, TCP_FLAG_ACK | TCP_FLAG_FIN);
+
+  /* Reset flags, make sure ack is sent */
+  tc->flags = TCP_CONN_SNDACK;
+  vnet_buffer (b)->tcp.flags &= ~TCP_BUF_FLAG_DUPACK;
+
+  tc->snd_nxt += 1;
+}
+
+/**
+ * Convert buffer to SYN-ACK
+ */
+void
+tcp_make_synack (tcp_connection_t * tc, vlib_buffer_t * b)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  vlib_main_t *vm = tm->vlib_main;
+  tcp_options_t _snd_opts, *snd_opts = &_snd_opts;
+  u8 tcp_opts_len, tcp_hdr_opts_len;
+  tcp_header_t *th;
+  u16 initial_wnd;
+  u32 time_now;
+
+  memset (snd_opts, 0, sizeof (*snd_opts));
+
+  tcp_reuse_buffer (vm, b);
+
+  /* Set random initial sequence */
+  time_now = tcp_time_now ();
+
+  tc->iss = random_u32 (&time_now);
+  tc->snd_una = tc->iss;
+  tc->snd_nxt = tc->iss + 1;
+  tc->snd_una_max = tc->snd_nxt;
+
+  initial_wnd = tcp_initial_window_to_advertise (tc);
+
+  /* Make and write options */
+  tcp_opts_len = tcp_make_synack_options (tc, snd_opts);
+  tcp_hdr_opts_len = tcp_opts_len + sizeof (tcp_header_t);
+
+  th = vlib_buffer_push_tcp (b, tc->c_lcl_port, tc->c_rmt_port, tc->iss,
+			     tc->rcv_nxt, tcp_hdr_opts_len,
+			     TCP_FLAG_SYN | TCP_FLAG_ACK, initial_wnd);
+
+  tcp_options_write ((u8 *) (th + 1), snd_opts);
+
+  vnet_buffer (b)->tcp.connection_index = tc->c_c_index;
+  vnet_buffer (b)->tcp.flags = TCP_BUF_FLAG_ACK;
+
+  /* Init retransmit timer */
+  tcp_retransmit_timer_set (tm, tc);
+}
+
+always_inline void
+tcp_enqueue_to_ip_lookup (vlib_main_t * vm, vlib_buffer_t * b, u32 bi,
+			  u8 is_ip4)
+{
+  u32 *to_next, next_index;
+  vlib_frame_t *f;
+
+  b->flags |= VNET_BUFFER_LOCALLY_ORIGINATED;
+  b->error = 0;
+
+  /* Default FIB for now */
+  vnet_buffer (b)->sw_if_index[VLIB_TX] = 0;
+
+  /* Send to IP lookup */
+  next_index = is_ip4 ? ip4_lookup_node.index : ip6_lookup_node.index;
+  f = vlib_get_frame_to_node (vm, next_index);
+
+  /* Enqueue the packet */
+  to_next = vlib_frame_vector_args (f);
+  to_next[0] = bi;
+  f->n_vectors = 1;
+  vlib_put_frame_to_node (vm, next_index, f);
+}
+
+int
+tcp_make_reset_in_place (vlib_main_t * vm, vlib_buffer_t * b0,
+			 tcp_state_t state, u32 my_thread_index, u8 is_ip4)
+{
+  u8 tcp_hdr_len = sizeof (tcp_header_t);
+  ip4_header_t *ih4;
+  ip6_header_t *ih6;
+  tcp_header_t *th0;
+  ip4_address_t src_ip40;
+  ip6_address_t src_ip60;
+  u16 src_port0;
+  u32 tmp;
+
+  /* Find IP and TCP headers */
+  if (is_ip4)
+    {
+      ih4 = vlib_buffer_get_current (b0);
+      th0 = ip4_next_header (ih4);
+    }
+  else
+    {
+      ih6 = vlib_buffer_get_current (b0);
+      th0 = ip6_next_header (ih6);
+    }
+
+  /* Swap src and dst ip */
+  if (is_ip4)
+    {
+      ASSERT ((ih4->ip_version_and_header_length & 0xF0) == 0x40);
+      src_ip40.as_u32 = ih4->src_address.as_u32;
+      ih4->src_address.as_u32 = ih4->dst_address.as_u32;
+      ih4->dst_address.as_u32 = src_ip40.as_u32;
+
+      /* Chop the end of the pkt */
+      b0->current_length += ip4_header_bytes (ih4) + tcp_hdr_len;
+    }
+  else
+    {
+      ASSERT ((ih6->ip_version_traffic_class_and_flow_label & 0xF0) == 0x60);
+      clib_memcpy (&src_ip60, &ih6->src_address, sizeof (ip6_address_t));
+      clib_memcpy (&ih6->src_address, &ih6->dst_address,
+		   sizeof (ip6_address_t));
+      clib_memcpy (&ih6->dst_address, &src_ip60, sizeof (ip6_address_t));
+
+      /* Chop the end of the pkt */
+      b0->current_length += sizeof (ip6_header_t) + tcp_hdr_len;
+    }
+
+  /* Try to determine what/why we're actually resetting and swap
+   * src and dst ports */
+  if (state == TCP_STATE_CLOSED)
+    {
+      if (!tcp_syn (th0))
+	return -1;
+
+      tmp = clib_net_to_host_u32 (th0->seq_number);
+
+      /* Got a SYN for no listener. */
+      th0->flags = TCP_FLAG_RST | TCP_FLAG_ACK;
+      th0->ack_number = clib_host_to_net_u32 (tmp + 1);
+      th0->seq_number = 0;
+
+    }
+  else if (state >= TCP_STATE_SYN_SENT)
+    {
+      th0->flags = TCP_FLAG_RST | TCP_FLAG_ACK;
+      th0->seq_number = th0->ack_number;
+      th0->ack_number = 0;
+    }
+
+  src_port0 = th0->src_port;
+  th0->src_port = th0->dst_port;
+  th0->dst_port = src_port0;
+  th0->window = 0;
+  th0->data_offset_and_reserved = (tcp_hdr_len >> 2) << 4;
+  th0->urgent_pointer = 0;
+
+  /* Compute checksum */
+  if (is_ip4)
+    {
+      th0->checksum = ip4_tcp_udp_compute_checksum (vm, b0, ih4);
+    }
+  else
+    {
+      int bogus = ~0;
+      th0->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b0, ih6, &bogus);
+      ASSERT (!bogus);
+    }
+
+  return 0;
+}
+
+/**
+ *  Send reset without reusing existing buffer
+ */
+void
+tcp_send_reset (vlib_buffer_t * pkt, u8 is_ip4)
+{
+  vlib_buffer_t *b;
+  u32 bi;
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  vlib_main_t *vm = tm->vlib_main;
+  u8 tcp_hdr_len, flags = 0;
+  tcp_header_t *th, *pkt_th;
+  u32 seq, ack;
+  ip4_header_t *ih4, *pkt_ih4;
+  ip6_header_t *ih6, *pkt_ih6;
+
+  tcp_get_free_buffer_index (tm, &bi);
+  b = vlib_get_buffer (vm, bi);
+
+  /* Leave enough space for headers */
+  vlib_buffer_make_headroom (b, MAX_HDRS_LEN);
+
+  /* Make and write options */
+  tcp_hdr_len = sizeof (tcp_header_t);
+
+  if (is_ip4)
+    {
+      pkt_ih4 = vlib_buffer_get_current (pkt);
+      pkt_th = ip4_next_header (pkt_ih4);
+    }
+  else
+    {
+      pkt_ih6 = vlib_buffer_get_current (pkt);
+      pkt_th = ip6_next_header (pkt_ih6);
+    }
+
+  if (tcp_ack (pkt_th))
+    {
+      flags = TCP_FLAG_RST;
+      seq = pkt_th->ack_number;
+      ack = 0;
+    }
+  else
+    {
+      flags = TCP_FLAG_RST | TCP_FLAG_ACK;
+      seq = 0;
+      ack = clib_host_to_net_u32 (vnet_buffer (pkt)->tcp.seq_end);
+    }
+
+  th = vlib_buffer_push_tcp_net_order (b, pkt_th->dst_port, pkt_th->src_port,
+				       seq, ack, tcp_hdr_len, flags, 0);
+
+  /* Swap src and dst ip */
+  if (is_ip4)
+    {
+      ASSERT ((pkt_ih4->ip_version_and_header_length & 0xF0) == 0x40);
+      ih4 = vlib_buffer_push_ip4 (vm, b, &pkt_ih4->dst_address,
+				  &pkt_ih4->src_address, IP_PROTOCOL_TCP);
+      th->checksum = ip4_tcp_udp_compute_checksum (vm, b, ih4);
+    }
+  else
+    {
+      int bogus = ~0;
+      pkt_ih6 = (ip6_header_t *) (pkt_th - 1);
+      ASSERT ((pkt_ih6->ip_version_traffic_class_and_flow_label & 0xF0) ==
+	      0x60);
+      ih6 =
+	vlib_buffer_push_ip6 (vm, b, &pkt_ih6->dst_address,
+			      &pkt_ih6->src_address, IP_PROTOCOL_TCP);
+      th->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b, ih6, &bogus);
+      ASSERT (!bogus);
+    }
+
+  tcp_enqueue_to_ip_lookup (vm, b, bi, is_ip4);
+}
+
+void
+tcp_push_ip_hdr (tcp_main_t * tm, tcp_connection_t * tc, vlib_buffer_t * b)
+{
+  tcp_header_t *th = vlib_buffer_get_current (b);
+
+  if (tc->c_is_ip4)
+    {
+      ip4_header_t *ih;
+      ih = vlib_buffer_push_ip4 (tm->vlib_main, b, &tc->c_lcl_ip4,
+				 &tc->c_rmt_ip4, IP_PROTOCOL_TCP);
+      th->checksum = ip4_tcp_udp_compute_checksum (tm->vlib_main, b, ih);
+    }
+  else
+    {
+      ip6_header_t *ih;
+      int bogus = ~0;
+
+      ih = vlib_buffer_push_ip6 (tm->vlib_main, b, &tc->c_lcl_ip6,
+				 &tc->c_rmt_ip6, IP_PROTOCOL_TCP);
+      th->checksum = ip6_tcp_udp_icmp_compute_checksum (tm->vlib_main, b, ih,
+							&bogus);
+      ASSERT (!bogus);
+    }
+}
+
+/**
+ *  Send SYN
+ *
+ *  Builds a SYN packet for a half-open connection and sends it to ipx_lookup.
+ *  The packet is not forwarded through tcpx_output to avoid doing lookups
+ *  in the half_open pool.
+ */
+void
+tcp_send_syn (tcp_connection_t * tc)
+{
+  vlib_buffer_t *b;
+  u32 bi;
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  vlib_main_t *vm = tm->vlib_main;
+  u8 tcp_hdr_opts_len, tcp_opts_len;
+  tcp_header_t *th;
+  u32 time_now;
+  u16 initial_wnd;
+  tcp_options_t snd_opts;
+
+  tcp_get_free_buffer_index (tm, &bi);
+  b = vlib_get_buffer (vm, bi);
+
+  /* Leave enough space for headers */
+  vlib_buffer_make_headroom (b, MAX_HDRS_LEN);
+
+  /* Set random initial sequence */
+  time_now = tcp_time_now ();
+
+  tc->iss = random_u32 (&time_now);
+  tc->snd_una = tc->iss;
+  tc->snd_una_max = tc->snd_nxt = tc->iss + 1;
+
+  initial_wnd = tcp_initial_window_to_advertise (tc);
+
+  /* Make and write options */
+  memset (&snd_opts, 0, sizeof (snd_opts));
+  tcp_opts_len = tcp_make_syn_options (&snd_opts, initial_wnd);
+  tcp_hdr_opts_len = tcp_opts_len + sizeof (tcp_header_t);
+
+  th = vlib_buffer_push_tcp (b, tc->c_lcl_port, tc->c_rmt_port, tc->iss,
+			     tc->rcv_nxt, tcp_hdr_opts_len, TCP_FLAG_SYN,
+			     initial_wnd);
+
+  tcp_options_write ((u8 *) (th + 1), &snd_opts);
+
+  /* Measure RTT with this */
+  tc->rtt_ts = tcp_time_now ();
+  tc->rtt_seq = tc->snd_nxt;
+
+  /* Start retransmit trimer  */
+  tcp_timer_set (tc, TCP_TIMER_RETRANSMIT_SYN, tc->rto * TCP_TO_TIMER_TICK);
+  tc->rto_boff = 0;
+
+  /* Set the connection establishment timer */
+  tcp_timer_set (tc, TCP_TIMER_ESTABLISH, TCP_ESTABLISH_TIME);
+
+  tcp_push_ip_hdr (tm, tc, b);
+  tcp_enqueue_to_ip_lookup (vm, b, bi, tc->c_is_ip4);
+}
+
+always_inline void
+tcp_enqueue_to_output (vlib_main_t * vm, vlib_buffer_t * b, u32 bi, u8 is_ip4)
+{
+  u32 *to_next, next_index;
+  vlib_frame_t *f;
+
+  b->flags |= VNET_BUFFER_LOCALLY_ORIGINATED;
+  b->error = 0;
+
+  /* Decide where to send the packet */
+  next_index = is_ip4 ? tcp4_output_node.index : tcp6_output_node.index;
+  f = vlib_get_frame_to_node (vm, next_index);
+
+  /* Enqueue the packet */
+  to_next = vlib_frame_vector_args (f);
+  to_next[0] = bi;
+  f->n_vectors = 1;
+  vlib_put_frame_to_node (vm, next_index, f);
+}
+
+/**
+ *  Send FIN
+ */
+void
+tcp_send_fin (tcp_connection_t * tc)
+{
+  vlib_buffer_t *b;
+  u32 bi;
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  vlib_main_t *vm = tm->vlib_main;
+
+  tcp_get_free_buffer_index (tm, &bi);
+  b = vlib_get_buffer (vm, bi);
+
+  /* Leave enough space for headers */
+  vlib_buffer_make_headroom (b, MAX_HDRS_LEN);
+
+  tcp_make_finack (tc, b);
+
+  tcp_enqueue_to_output (vm, b, bi, tc->c_is_ip4);
+}
+
+always_inline u8
+tcp_make_state_flags (tcp_state_t next_state)
+{
+  switch (next_state)
+    {
+    case TCP_STATE_ESTABLISHED:
+      return TCP_FLAG_ACK;
+    case TCP_STATE_SYN_RCVD:
+      return TCP_FLAG_SYN | TCP_FLAG_ACK;
+    case TCP_STATE_SYN_SENT:
+      return TCP_FLAG_SYN;
+    case TCP_STATE_LAST_ACK:
+    case TCP_STATE_FIN_WAIT_1:
+      return TCP_FLAG_FIN;
+    default:
+      clib_warning ("Shouldn't be here!");
+    }
+  return 0;
+}
+
+/**
+ * Push TCP header and update connection variables
+ */
+static void
+tcp_push_hdr_i (tcp_connection_t * tc, vlib_buffer_t * b,
+		tcp_state_t next_state)
+{
+  u32 advertise_wnd, data_len;
+  u8 tcp_opts_len, tcp_hdr_opts_len, opts_write_len, flags;
+  tcp_options_t _snd_opts, *snd_opts = &_snd_opts;
+  tcp_header_t *th;
+
+  data_len = b->current_length;
+  vnet_buffer (b)->tcp.flags = 0;
+
+  /* Make and write options */
+  memset (snd_opts, 0, sizeof (*snd_opts));
+  tcp_opts_len = tcp_make_options (tc, snd_opts, next_state);
+  tcp_hdr_opts_len = tcp_opts_len + sizeof (tcp_header_t);
+
+  /* Get rcv window to advertise */
+  advertise_wnd = tcp_window_to_advertise (tc, next_state);
+  flags = tcp_make_state_flags (next_state);
+
+  /* Push header and options */
+  th = vlib_buffer_push_tcp (b, tc->c_lcl_port, tc->c_rmt_port, tc->snd_nxt,
+			     tc->rcv_nxt, tcp_hdr_opts_len, flags,
+			     advertise_wnd);
+
+  opts_write_len = tcp_options_write ((u8 *) (th + 1), snd_opts);
+
+  ASSERT (opts_write_len == tcp_opts_len);
+
+  /* Tag the buffer with the connection index  */
+  vnet_buffer (b)->tcp.connection_index = tc->c_c_index;
+
+  tc->snd_nxt += data_len;
+}
+
+/* Send delayed ACK when timer expires */
+void
+tcp_timer_delack_handler (u32 index)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  vlib_main_t *vm = tm->vlib_main;
+  u32 thread_index = os_get_cpu_number ();
+  tcp_connection_t *tc;
+  vlib_buffer_t *b;
+  u32 bi;
+
+  tc = tcp_connection_get (index, thread_index);
+
+  /* Get buffer */
+  tcp_get_free_buffer_index (tm, &bi);
+  b = vlib_get_buffer (vm, bi);
+
+  /* Fill in the ACK */
+  tcp_make_ack (tc, b);
+
+  tc->timers[TCP_TIMER_DELACK] = TCP_TIMER_HANDLE_INVALID;
+  tc->flags &= ~TCP_CONN_DELACK;
+
+  tcp_enqueue_to_output (vm, b, bi, tc->c_is_ip4);
+}
+
+/** Build a retransmit segment
+ *
+ * @return the number of bytes in the segment or 0 if there's nothing to
+ *         retransmit
+ * */
+u32
+tcp_prepare_retransmit_segment (tcp_connection_t * tc, vlib_buffer_t * b,
+				u32 max_bytes)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  vlib_main_t *vm = tm->vlib_main;
+  u32 n_bytes, offset = 0;
+  sack_scoreboard_hole_t *hole;
+  u32 hole_size;
+
+  tcp_reuse_buffer (vm, b);
+
+  ASSERT (tc->state == TCP_STATE_ESTABLISHED);
+  ASSERT (max_bytes != 0);
+
+  if (tcp_opts_sack_permitted (&tc->opt))
+    {
+      /* XXX get first hole not retransmitted yet  */
+      hole = scoreboard_first_hole (&tc->sack_sb);
+      if (!hole)
+	return 0;
+
+      offset = hole->start - tc->snd_una;
+      hole_size = hole->end - hole->start;
+
+      ASSERT (hole_size);
+
+      if (hole_size < max_bytes)
+	max_bytes = hole_size;
+    }
+  else
+    {
+      if (seq_geq (tc->snd_nxt, tc->snd_una_max))
+	return 0;
+    }
+
+  n_bytes = stream_session_peek_bytes (&tc->connection,
+				       vlib_buffer_get_current (b), offset,
+				       max_bytes);
+  ASSERT (n_bytes != 0);
+
+  tc->snd_nxt += n_bytes;
+  tcp_push_hdr_i (tc, b, tc->state);
+
+  return n_bytes;
+}
+
+static void
+tcp_timer_retransmit_handler_i (u32 index, u8 is_syn)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  vlib_main_t *vm = tm->vlib_main;
+  u32 thread_index = os_get_cpu_number ();
+  tcp_connection_t *tc;
+  vlib_buffer_t *b;
+  u32 bi, max_bytes, snd_space;
+
+  if (is_syn)
+    {
+      tc = tcp_half_open_connection_get (index);
+    }
+  else
+    {
+      tc = tcp_connection_get (index, thread_index);
+    }
+
+  /* Make sure timer handle is set to invalid */
+  tc->timers[TCP_TIMER_RETRANSMIT] = TCP_TIMER_HANDLE_INVALID;
+
+  /* Increment RTO backoff (also equal to number of retries) */
+  tc->rto_boff += 1;
+
+  /* Go back to first un-acked byte */
+  tc->snd_nxt = tc->snd_una;
+
+  /* Get buffer */
+  tcp_get_free_buffer_index (tm, &bi);
+  b = vlib_get_buffer (vm, bi);
+
+  if (tc->state == TCP_STATE_ESTABLISHED)
+    {
+      tcp_fastrecovery_off (tc);
+
+      /* Exponential backoff */
+      tc->rto = clib_min (tc->rto << 1, TCP_RTO_MAX);
+
+      /* Figure out what and how many bytes we can send */
+      snd_space = tcp_available_snd_space (tc);
+      max_bytes = clib_min (tc->snd_mss, snd_space);
+      tcp_prepare_retransmit_segment (tc, b, max_bytes);
+
+      tc->rtx_bytes += max_bytes;
+
+      /* No fancy recovery for now! */
+      scoreboard_clear (&tc->sack_sb);
+    }
+  else
+    {
+      /* Retransmit for SYN/SYNACK */
+      ASSERT (tc->state == TCP_STATE_SYN_RCVD
+	      || tc->state == TCP_STATE_SYN_SENT);
+
+      /* Try without increasing RTO a number of times. If this fails,
+       * start growing RTO exponentially */
+      if (tc->rto_boff > TCP_RTO_SYN_RETRIES)
+	tc->rto = clib_min (tc->rto << 1, TCP_RTO_MAX);
+
+      vlib_buffer_make_headroom (b, MAX_HDRS_LEN);
+      tcp_push_hdr_i (tc, b, tc->state);
+    }
+
+  if (!is_syn)
+    {
+      tcp_enqueue_to_output (vm, b, bi, tc->c_is_ip4);
+
+      /* Re-enable retransmit timer */
+      tcp_retransmit_timer_set (tm, tc);
+    }
+  else
+    {
+      ASSERT (tc->state == TCP_STATE_SYN_SENT);
+
+      /* This goes straight to ipx_lookup */
+      tcp_push_ip_hdr (tm, tc, b);
+      tcp_enqueue_to_ip_lookup (vm, b, bi, tc->c_is_ip4);
+
+      /* Re-enable retransmit timer */
+      tcp_timer_set (tc, TCP_TIMER_RETRANSMIT_SYN,
+		     tc->rto * TCP_TO_TIMER_TICK);
+    }
+}
+
+void
+tcp_timer_retransmit_handler (u32 index)
+{
+  tcp_timer_retransmit_handler_i (index, 0);
+}
+
+void
+tcp_timer_retransmit_syn_handler (u32 index)
+{
+  tcp_timer_retransmit_handler_i (index, 1);
+}
+
+/**
+ * Retansmit first unacked segment */
+void
+tcp_retransmit_first_unacked (tcp_connection_t * tc)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  u32 snd_nxt = tc->snd_nxt;
+  vlib_buffer_t *b;
+  u32 bi;
+
+  tc->snd_nxt = tc->snd_una;
+
+  /* Get buffer */
+  tcp_get_free_buffer_index (tm, &bi);
+  b = vlib_get_buffer (tm->vlib_main, bi);
+
+  tcp_prepare_retransmit_segment (tc, b, tc->snd_mss);
+  tcp_enqueue_to_output (tm->vlib_main, b, bi, tc->c_is_ip4);
+
+  tc->snd_nxt = snd_nxt;
+  tc->rtx_bytes += tc->snd_mss;
+}
+
+void
+tcp_fast_retransmit (tcp_connection_t * tc)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  u32 snd_space, max_bytes, n_bytes, bi;
+  vlib_buffer_t *b;
+
+  ASSERT (tcp_in_fastrecovery (tc));
+
+  clib_warning ("fast retransmit!");
+
+  /* Start resending from first un-acked segment */
+  tc->snd_nxt = tc->snd_una;
+
+  snd_space = tcp_available_snd_space (tc);
+
+  while (snd_space)
+    {
+      tcp_get_free_buffer_index (tm, &bi);
+      b = vlib_get_buffer (tm->vlib_main, bi);
+
+      max_bytes = clib_min (tc->snd_mss, snd_space);
+      n_bytes = tcp_prepare_retransmit_segment (tc, b, max_bytes);
+
+      /* Nothing left to retransmit */
+      if (n_bytes == 0)
+	return;
+
+      tcp_enqueue_to_output (tm->vlib_main, b, bi, tc->c_is_ip4);
+
+      snd_space -= n_bytes;
+    }
+
+  /* If window allows, send new data */
+  tc->snd_nxt = tc->snd_una_max;
+}
+
+always_inline u32
+tcp_session_has_ooo_data (tcp_connection_t * tc)
+{
+  stream_session_t *s =
+    stream_session_get (tc->c_s_index, tc->c_thread_index);
+  return svm_fifo_has_ooo_data (s->server_rx_fifo);
+}
+
+always_inline uword
+tcp46_output_inline (vlib_main_t * vm,
+		     vlib_node_runtime_t * node,
+		     vlib_frame_t * from_frame, int is_ip4)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  u32 n_left_from, next_index, *from, *to_next;
+  u32 my_thread_index = vm->cpu_index;
+
+  from = vlib_frame_vector_args (from_frame);
+  n_left_from = from_frame->n_vectors;
+
+  next_index = node->cached_next_index;
+
+  while (n_left_from > 0)
+    {
+      u32 n_left_to_next;
+
+      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+      while (n_left_from > 0 && n_left_to_next > 0)
+	{
+	  u32 bi0;
+	  vlib_buffer_t *b0;
+	  tcp_connection_t *tc0;
+	  tcp_header_t *th0;
+	  u32 error0 = TCP_ERROR_PKTS_SENT, next0 = TCP_OUTPUT_NEXT_IP_LOOKUP;
+
+	  bi0 = from[0];
+	  to_next[0] = bi0;
+	  from += 1;
+	  to_next += 1;
+	  n_left_from -= 1;
+	  n_left_to_next -= 1;
+
+	  b0 = vlib_get_buffer (vm, bi0);
+	  tc0 = tcp_connection_get (vnet_buffer (b0)->tcp.connection_index,
+				    my_thread_index);
+	  th0 = vlib_buffer_get_current (b0);
+
+	  if (is_ip4)
+	    {
+	      ip4_header_t *ih0;
+	      ih0 = vlib_buffer_push_ip4 (vm, b0, &tc0->c_lcl_ip4,
+					  &tc0->c_rmt_ip4, IP_PROTOCOL_TCP);
+	      th0->checksum = ip4_tcp_udp_compute_checksum (vm, b0, ih0);
+	    }
+	  else
+	    {
+	      ip6_header_t *ih0;
+	      int bogus = ~0;
+
+	      ih0 = vlib_buffer_push_ip6 (vm, b0, &tc0->c_lcl_ip6,
+					  &tc0->c_rmt_ip6, IP_PROTOCOL_TCP);
+	      th0->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b0, ih0,
+								 &bogus);
+	      ASSERT (!bogus);
+	    }
+
+	  /* Filter out DUPACKs if there are no OOO segments left */
+	  if (PREDICT_FALSE
+	      (vnet_buffer (b0)->tcp.flags & TCP_BUF_FLAG_DUPACK))
+	    {
+	      tc0->snt_dupacks--;
+	      ASSERT (tc0->snt_dupacks >= 0);
+	      if (!tcp_session_has_ooo_data (tc0))
+		{
+		  error0 = TCP_ERROR_FILTERED_DUPACKS;
+		  next0 = TCP_OUTPUT_NEXT_DROP;
+		  goto done;
+		}
+	    }
+
+	  /* Retransmitted SYNs do reach this but it should be harmless */
+	  tc0->rcv_las = tc0->rcv_nxt;
+
+	  /* Stop DELACK timer and fix flags */
+	  tc0->flags &=
+	    ~(TCP_CONN_SNDACK | TCP_CONN_DELACK | TCP_CONN_BURSTACK);
+	  if (tcp_timer_is_active (tc0, TCP_TIMER_DELACK))
+	    {
+	      tcp_timer_reset (tc0, TCP_TIMER_DELACK);
+	    }
+
+	  /* If not retransmitting
+	   * 1) update snd_una_max (SYN, SYNACK, new data, FIN)
+	   * 2) If we're not tracking an ACK, start tracking */
+	  if (seq_lt (tc0->snd_una_max, tc0->snd_nxt))
+	    {
+	      tc0->snd_una_max = tc0->snd_nxt;
+	      if (tc0->rtt_ts == 0)
+		{
+		  tc0->rtt_ts = tcp_time_now ();
+		  tc0->rtt_seq = tc0->snd_nxt;
+		}
+	    }
+
+	  /* Set the retransmit timer if not set already and not
+	   * doing a pure ACK */
+	  if (!tcp_timer_is_active (tc0, TCP_TIMER_RETRANSMIT)
+	      && tc0->snd_nxt != tc0->snd_una)
+	    {
+	      tcp_retransmit_timer_set (tm, tc0);
+	      tc0->rto_boff = 0;
+	    }
+
+	  /* set fib index to default and lookup node */
+	  /* XXX network virtualization (vrf/vni) */
+	  vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0;
+	  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
+
+	  b0->flags |= VNET_BUFFER_LOCALLY_ORIGINATED;
+
+	done:
+	  b0->error = error0 != 0 ? node->errors[error0] : 0;
+	  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+	    {
+
+	    }
+
+	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+					   n_left_to_next, bi0, next0);
+	}
+
+      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+    }
+
+  return from_frame->n_vectors;
+}
+
+static uword
+tcp4_output (vlib_main_t * vm, vlib_node_runtime_t * node,
+	     vlib_frame_t * from_frame)
+{
+  return tcp46_output_inline (vm, node, from_frame, 1 /* is_ip4 */ );
+}
+
+static uword
+tcp6_output (vlib_main_t * vm, vlib_node_runtime_t * node,
+	     vlib_frame_t * from_frame)
+{
+  return tcp46_output_inline (vm, node, from_frame, 0 /* is_ip4 */ );
+}
+
+VLIB_REGISTER_NODE (tcp4_output_node) =
+{
+  .function = tcp4_output,.name = "tcp4-output",
+    /* Takes a vector of packets. */
+    .vector_size = sizeof (u32),.n_errors = TCP_N_ERROR,.error_strings =
+    tcp_error_strings,.n_next_nodes = TCP_OUTPUT_N_NEXT,.next_nodes =
+  {
+#define _(s,n) [TCP_OUTPUT_NEXT_##s] = n,
+    foreach_tcp4_output_next
+#undef _
+  }
+,.format_buffer = format_tcp_header,.format_trace = format_tcp_tx_trace,};
+
+VLIB_NODE_FUNCTION_MULTIARCH (tcp4_output_node, tcp4_output)
+VLIB_REGISTER_NODE (tcp6_output_node) =
+{
+  .function = tcp6_output,.name = "tcp6-output",
+    /* Takes a vector of packets. */
+    .vector_size = sizeof (u32),.n_errors = TCP_N_ERROR,.error_strings =
+    tcp_error_strings,.n_next_nodes = TCP_OUTPUT_N_NEXT,.next_nodes =
+  {
+#define _(s,n) [TCP_OUTPUT_NEXT_##s] = n,
+    foreach_tcp6_output_next
+#undef _
+  }
+,.format_buffer = format_tcp_header,.format_trace = format_tcp_tx_trace,};
+
+VLIB_NODE_FUNCTION_MULTIARCH (tcp6_output_node, tcp6_output) u32
+tcp_push_header (transport_connection_t * tconn, vlib_buffer_t * b)
+{
+  tcp_connection_t *tc;
+
+  tc = (tcp_connection_t *) tconn;
+  tcp_push_hdr_i (tc, b, TCP_STATE_ESTABLISHED);
+  return 0;
+}
+
+typedef enum _tcp_reset_next
+{
+  TCP_RESET_NEXT_DROP,
+  TCP_RESET_NEXT_IP_LOOKUP,
+  TCP_RESET_N_NEXT
+} tcp_reset_next_t;
+
+#define foreach_tcp4_reset_next        	\
+  _(DROP, "error-drop")                 \
+  _(IP_LOOKUP, "ip4-lookup")
+
+#define foreach_tcp6_reset_next        	\
+  _(DROP, "error-drop")                 \
+  _(IP_LOOKUP, "ip6-lookup")
+
+static uword
+tcp46_send_reset_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
+			 vlib_frame_t * from_frame, u8 is_ip4)
+{
+  u32 n_left_from, next_index, *from, *to_next;
+  u32 my_thread_index = vm->cpu_index;
+
+  from = vlib_frame_vector_args (from_frame);
+  n_left_from = from_frame->n_vectors;
+
+  next_index = node->cached_next_index;
+
+  while (n_left_from > 0)
+    {
+      u32 n_left_to_next;
+
+      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+      while (n_left_from > 0 && n_left_to_next > 0)
+	{
+	  u32 bi0;
+	  vlib_buffer_t *b0;
+	  u32 error0 = TCP_ERROR_RST_SENT, next0 = TCP_RESET_NEXT_IP_LOOKUP;
+
+	  bi0 = from[0];
+	  to_next[0] = bi0;
+	  from += 1;
+	  to_next += 1;
+	  n_left_from -= 1;
+	  n_left_to_next -= 1;
+
+	  b0 = vlib_get_buffer (vm, bi0);
+
+	  if (tcp_make_reset_in_place (vm, b0, vnet_buffer (b0)->tcp.flags,
+				       my_thread_index, is_ip4))
+	    {
+	      error0 = TCP_ERROR_LOOKUP_DROPS;
+	      next0 = TCP_RESET_NEXT_DROP;
+	      goto done;
+	    }
+
+	  /* Prepare to send to IP lookup */
+	  vnet_buffer (b0)->sw_if_index[VLIB_TX] = 0;
+	  next0 = TCP_RESET_NEXT_IP_LOOKUP;
+
+	done:
+	  b0->error = error0 != 0 ? node->errors[error0] : 0;
+	  b0->flags |= VNET_BUFFER_LOCALLY_ORIGINATED;
+	  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+	    {
+
+	    }
+
+	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+					   n_left_to_next, bi0, next0);
+	}
+      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+    }
+  return from_frame->n_vectors;
+}
+
+static uword
+tcp4_send_reset (vlib_main_t * vm, vlib_node_runtime_t * node,
+		 vlib_frame_t * from_frame)
+{
+  return tcp46_send_reset_inline (vm, node, from_frame, 1);
+}
+
+static uword
+tcp6_send_reset (vlib_main_t * vm, vlib_node_runtime_t * node,
+		 vlib_frame_t * from_frame)
+{
+  return tcp46_send_reset_inline (vm, node, from_frame, 0);
+}
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (tcp4_reset_node) = {
+  .function = tcp4_send_reset,
+  .name = "tcp4-reset",
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,
+  .error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_RESET_N_NEXT,
+  .next_nodes = {
+#define _(s,n) [TCP_RESET_NEXT_##s] = n,
+    foreach_tcp4_reset_next
+#undef _
+  },
+};
+/* *INDENT-ON* */
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (tcp6_reset_node) = {
+  .function = tcp6_send_reset,
+  .name = "tcp6-reset",
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,
+  .error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_RESET_N_NEXT,
+  .next_nodes = {
+#define _(s,n) [TCP_RESET_NEXT_##s] = n,
+    foreach_tcp6_reset_next
+#undef _
+  },
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/tcp/tcp_packet.h b/src/vnet/tcp/tcp_packet.h
new file mode 100644
index 0000000..866c5fd
--- /dev/null
+++ b/src/vnet/tcp/tcp_packet.h
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef included_tcp_packet_h
+#define included_tcp_packet_h
+
+#include <vnet/vnet.h>
+
+/* TCP flags bit 0 first. */
+#define foreach_tcp_flag                                \
+  _ (FIN) /**< No more data from sender. */             \
+  _ (SYN) /**< Synchronize sequence numbers. */         \
+  _ (RST) /**< Reset the connection. */                 \
+  _ (PSH) /**< Push function. */                        \
+  _ (ACK) /**< Ack field significant. */                \
+  _ (URG) /**< Urgent pointer field significant. */     \
+  _ (ECE) /**< ECN-echo. Receiver got CE packet */      \
+  _ (CWR) /**< Sender reduced congestion window */
+
+enum
+{
+#define _(f) TCP_FLAG_BIT_##f,
+  foreach_tcp_flag
+#undef _
+    TCP_N_FLAG_BITS,
+};
+
+enum
+{
+#define _(f) TCP_FLAG_##f = 1 << TCP_FLAG_BIT_##f,
+  foreach_tcp_flag
+#undef _
+};
+
+typedef struct _tcp_header
+{
+  union
+  {
+    struct
+    {
+      u16 src_port; /**< Source port. */
+      u16 dst_port; /**< Destination port. */
+    };
+    struct
+    {
+      u16 src, dst;
+    };
+  };
+
+  u32 seq_number;	/**< Sequence number of the first data octet in this
+                         *   segment, except when SYN is present. If SYN
+                         *   is present the seq number is is the ISN and the
+                         *   first data octet is ISN+1 */
+  u32 ack_number;	/**< Acknowledgement number if ACK is set. It contains
+                         *   the value of the next sequence number the sender
+                         *   of the segment is expecting to receive. */
+  u8 data_offset_and_reserved;
+  u8 flags;		/**< Flags: see the macro above */
+  u16 window;		/**< Number of bytes sender is willing to receive. */
+
+  u16 checksum;		/**< Checksum of TCP pseudo header and data. */
+  u16 urgent_pointer;	/**< Seq number of the byte after the urgent data. */
+} __attribute__ ((packed)) tcp_header_t;
+
+/* Flag tests that return 0 or !0 */
+#define tcp_doff(_th) ((_th)->data_offset_and_reserved >> 4)
+#define tcp_fin(_th) ((_th)->flags & TCP_FLAG_FIN)
+#define tcp_syn(_th) ((_th)->flags & TCP_FLAG_SYN)
+#define tcp_rst(_th) ((_th)->flags & TCP_FLAG_RST)
+#define tcp_psh(_th) ((_th)->flags & TCP_FLAG_PSH)
+#define tcp_ack(_th) ((_th)->flags & TCP_FLAG_ACK)
+#define tcp_urg(_th) ((_th)->flags & TCP_FLAG_URG)
+#define tcp_ece(_th) ((_th)->flags & TCP_FLAG_ECE)
+#define tcp_cwr(_th) ((_th)->flags & TCP_FLAG_CWR)
+
+/* Flag tests that return 0 or 1 */
+#define tcp_is_syn(_th) !!((_th)->flags & TCP_FLAG_SYN)
+#define tcp_is_fin(_th) !!((_th)->flags & TCP_FLAG_FIN)
+
+always_inline int
+tcp_header_bytes (tcp_header_t * t)
+{
+  return tcp_doff (t) * sizeof (u32);
+}
+
+/*
+ * TCP options.
+ */
+
+typedef enum tcp_option_type
+{
+  TCP_OPTION_EOL = 0,			/**< End of options. */
+  TCP_OPTION_NOOP = 1,			/**< No operation. */
+  TCP_OPTION_MSS = 2,			/**< Limit MSS. */
+  TCP_OPTION_WINDOW_SCALE = 3,		/**< Window scale. */
+  TCP_OPTION_SACK_PERMITTED = 4,	/**< Selective Ack permitted. */
+  TCP_OPTION_SACK_BLOCK = 5,		/**< Selective Ack block. */
+  TCP_OPTION_TIMESTAMP = 8,		/**< Timestamps. */
+  TCP_OPTION_UTO = 28,			/**< User timeout. */
+  TCP_OPTION_AO = 29,			/**< Authentication Option. */
+} tcp_option_type_t;
+
+#define foreach_tcp_options_flag                                        \
+  _ (MSS)               /**< MSS advertised in SYN */                   \
+  _ (TSTAMP)            /**< Timestamp capability advertised in SYN */  \
+  _ (WSCALE)            /**< Wnd scale capability advertised in SYN */  \
+  _ (SACK_PERMITTED)    /**< SACK capability advertised in SYN */       \
+  _ (SACK)		/**< SACK present */
+
+enum
+{
+#define _(f) TCP_OPTS_FLAG_BIT_##f,
+  foreach_tcp_options_flag
+#undef _
+    TCP_OPTIONS_N_FLAG_BITS,
+};
+
+enum
+{
+#define _(f) TCP_OPTS_FLAG_##f = 1 << TCP_OPTS_FLAG_BIT_##f,
+  foreach_tcp_options_flag
+#undef _
+};
+
+typedef struct _sack_block
+{
+  u32 start;		/**< Start sequence number */
+  u32 end;		/**< End sequence number */
+} sack_block_t;
+
+typedef struct
+{
+  u8 flags;		/** Option flags, see above */
+
+  /* Received options */
+  u16 mss;		/**< Maximum segment size advertised by peer */
+  u8 wscale;		/**< Window scale advertised by peer */
+  u32 tsval;		/**< Peer's timestamp value */
+  u32 tsecr;		/**< Echoed/reflected time stamp */
+  sack_block_t *sacks;	/**< SACK blocks received */
+  u8 n_sack_blocks;	/**< Number of SACKs blocks */
+} tcp_options_t;
+
+/* Flag tests that return 0 or !0 */
+#define tcp_opts_mss(_to) ((_to)->flags & TCP_OPTS_FLAG_MSS)
+#define tcp_opts_tstamp(_to) ((_to)->flags & TCP_OPTS_FLAG_TSTAMP)
+#define tcp_opts_wscale(_to) ((_to)->flags & TCP_OPTS_FLAG_WSCALE)
+#define tcp_opts_sack(_to) ((_to)->flags & TCP_OPTS_FLAG_SACK)
+#define tcp_opts_sack_permitted(_to) ((_to)->flags & TCP_OPTS_FLAG_SACK_PERMITTED)
+
+/* TCP option lengths */
+#define TCP_OPTION_LEN_EOL              1
+#define TCP_OPTION_LEN_NOOP             1
+#define TCP_OPTION_LEN_MSS              4
+#define TCP_OPTION_LEN_WINDOW_SCALE     3
+#define TCP_OPTION_LEN_SACK_PERMITTED   2
+#define TCP_OPTION_LEN_TIMESTAMP        10
+#define TCP_OPTION_LEN_SACK_BLOCK        8
+
+#define TCP_WND_MAX                     65535U
+#define TCP_MAX_WND_SCALE               14	/* See RFC 1323 */
+#define TCP_OPTS_ALIGN                  4
+#define TCP_OPTS_MAX_SACK_BLOCKS        3
+#endif /* included_tcp_packet_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/tcp/tcp_pg.c b/src/vnet/tcp/tcp_pg.c
new file mode 100644
index 0000000..dc32404
--- /dev/null
+++ b/src/vnet/tcp/tcp_pg.c
@@ -0,0 +1,236 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * ip/tcp_pg: TCP packet-generator interface
+ *
+ * Copyright (c) 2008 Eliot Dresselhaus
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <vnet/ip/ip.h>
+#include <vnet/pg/pg.h>
+
+/* TCP flags bit 0 first. */
+#define foreach_tcp_flag			\
+  _ (FIN)					\
+  _ (SYN)					\
+  _ (RST)					\
+  _ (PSH)					\
+  _ (ACK)					\
+  _ (URG)					\
+  _ (ECE)					\
+  _ (CWR)
+
+static void
+tcp_pg_edit_function (pg_main_t * pg,
+		      pg_stream_t * s,
+		      pg_edit_group_t * g,
+		      u32 * packets,
+		      u32 n_packets)
+{
+  vlib_main_t * vm = vlib_get_main();
+  u32 ip_offset, tcp_offset;
+
+  tcp_offset = g->start_byte_offset;
+  ip_offset = (g-1)->start_byte_offset;
+
+  while (n_packets >= 1)
+    {
+      vlib_buffer_t * p0;
+      ip4_header_t * ip0;
+      tcp_header_t * tcp0;
+      ip_csum_t sum0;
+      u32 tcp_len0;
+
+      p0 = vlib_get_buffer (vm, packets[0]);
+      n_packets -= 1;
+      packets += 1;
+
+      ASSERT (p0->current_data == 0);
+      ip0 = (void *) (p0->data + ip_offset);
+      tcp0 = (void *) (p0->data + tcp_offset);
+      tcp_len0 = clib_net_to_host_u16 (ip0->length) - sizeof (ip0[0]);
+
+      /* Initialize checksum with header. */
+      if (BITS (sum0) == 32)
+	{
+	  sum0 = clib_mem_unaligned (&ip0->src_address, u32);
+	  sum0 = ip_csum_with_carry (sum0, clib_mem_unaligned (&ip0->dst_address, u32));
+	}
+      else
+	sum0 = clib_mem_unaligned (&ip0->src_address, u64);
+
+      sum0 = ip_csum_with_carry
+	(sum0, clib_host_to_net_u32 (tcp_len0 + (ip0->protocol << 16)));
+
+      /* Invalidate possibly old checksum. */
+      tcp0->checksum = 0;
+
+      sum0 = ip_incremental_checksum_buffer (vm, p0, tcp_offset, tcp_len0, sum0);
+
+      tcp0->checksum = ~ ip_csum_fold (sum0);
+    }
+}
+
+typedef struct {
+  pg_edit_t src, dst;
+  pg_edit_t seq_number, ack_number;
+  pg_edit_t data_offset_and_reserved;
+#define _(f) pg_edit_t f##_flag;
+  foreach_tcp_flag
+#undef _
+  pg_edit_t window;
+  pg_edit_t checksum;
+  pg_edit_t urgent_pointer;
+} pg_tcp_header_t;
+
+static inline void
+pg_tcp_header_init (pg_tcp_header_t * p)
+{
+  /* Initialize fields that are not bit fields in the IP header. */
+#define _(f) pg_edit_init (&p->f, tcp_header_t, f);
+  _ (src);
+  _ (dst);
+  _ (seq_number);
+  _ (ack_number);
+  _ (window);
+  _ (checksum);
+  _ (urgent_pointer);
+#undef _
+
+  /* Initialize bit fields. */
+#define _(f)						\
+  pg_edit_init_bitfield (&p->f##_flag, tcp_header_t,	\
+			 flags,				\
+			 TCP_FLAG_BIT_##f, 1);
+
+  foreach_tcp_flag
+#undef _
+
+  pg_edit_init_bitfield (&p->data_offset_and_reserved, tcp_header_t,
+			 data_offset_and_reserved,
+			 4, 4);
+}
+
+uword
+unformat_pg_tcp_header (unformat_input_t * input, va_list * args)
+{
+  pg_stream_t * s = va_arg (*args, pg_stream_t *);
+  pg_tcp_header_t * p;
+  u32 group_index;
+  
+  p = pg_create_edit_group (s, sizeof (p[0]), sizeof (tcp_header_t),
+			    &group_index);
+  pg_tcp_header_init (p);
+
+  /* Defaults. */
+  pg_edit_set_fixed (&p->seq_number, 0);
+  pg_edit_set_fixed (&p->ack_number, 0);
+
+  pg_edit_set_fixed (&p->data_offset_and_reserved, 
+                     sizeof (tcp_header_t) / sizeof (u32));
+
+  pg_edit_set_fixed (&p->window, 4096);
+  pg_edit_set_fixed (&p->urgent_pointer, 0);
+
+#define _(f) pg_edit_set_fixed (&p->f##_flag, 0);
+  foreach_tcp_flag
+#undef _
+
+  p->checksum.type = PG_EDIT_UNSPECIFIED;
+
+  if (! unformat (input, "TCP: %U -> %U",
+		  unformat_pg_edit,
+		    unformat_tcp_udp_port, &p->src,
+		  unformat_pg_edit,
+		    unformat_tcp_udp_port, &p->dst))
+    goto error;
+
+  /* Parse options. */
+  while (1)
+    {
+      if (unformat (input, "window %U",
+		    unformat_pg_edit,
+		    unformat_pg_number, &p->window))
+	;
+
+      else if (unformat (input, "checksum %U",
+			 unformat_pg_edit,
+			 unformat_pg_number, &p->checksum))
+	;
+
+      /* Flags. */
+#define _(f) else if (unformat (input, #f)) pg_edit_set_fixed (&p->f##_flag, 1);
+  foreach_tcp_flag
+#undef _
+
+      /* Can't parse input: try next protocol level. */
+      else
+	break;
+    }
+
+  {
+    ip_main_t * im = &ip_main;
+    u16 dst_port;
+    tcp_udp_port_info_t * pi;
+
+    pi = 0;
+    if (p->dst.type == PG_EDIT_FIXED)
+      {
+	dst_port = pg_edit_get_value (&p->dst, PG_EDIT_LO);
+	pi = ip_get_tcp_udp_port_info (im, dst_port);
+      }
+
+    if (pi && pi->unformat_pg_edit
+	&& unformat_user (input, pi->unformat_pg_edit, s))
+      ;
+
+    else if (! unformat_user (input, unformat_pg_payload, s))
+      goto error;
+
+    if (p->checksum.type == PG_EDIT_UNSPECIFIED)
+      {
+	pg_edit_group_t * g = pg_stream_get_group (s, group_index);
+	g->edit_function = tcp_pg_edit_function;
+	g->edit_function_opaque = 0;
+      }
+
+    return 1;
+  }
+
+ error:
+  /* Free up any edits we may have added. */
+  pg_free_edit_group (s);
+  return 0;
+}
+
diff --git a/src/vnet/tcp/tcp_syn_filter4.c b/src/vnet/tcp/tcp_syn_filter4.c
new file mode 100644
index 0000000..c7605a3
--- /dev/null
+++ b/src/vnet/tcp/tcp_syn_filter4.c
@@ -0,0 +1,542 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vlib/vlib.h>
+#include <vnet/vnet.h>
+#include <vnet/pg/pg.h>
+#include <vppinfra/error.h>
+#include <vnet/feature/feature.h>
+#include <vnet/ip/ip.h>
+#include <vppinfra/xxhash.h>
+
+typedef struct
+{
+  f64 next_reset;
+  f64 reset_interval;
+  u8 *syn_counts;
+} syn_filter4_runtime_t;
+
+typedef struct
+{
+  u32 next_index;
+  int not_a_syn;
+  u8 filter_value;
+} syn_filter4_trace_t;
+
+/* packet trace format function */
+static u8 *
+format_syn_filter4_trace (u8 * s, va_list * args)
+{
+  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+  syn_filter4_trace_t *t = va_arg (*args, syn_filter4_trace_t *);
+
+  s = format (s, "SYN_FILTER4: next index %d, %s",
+	      t->next_index, t->not_a_syn ? "not a syn" : "syn");
+  if (t->not_a_syn == 0)
+    s = format (s, ", filter value %d\n", t->filter_value);
+  else
+    s = format (s, "\n");
+  return s;
+}
+
+static vlib_node_registration_t syn_filter4_node;
+
+#define foreach_syn_filter_error                \
+_(THROTTLED, "TCP SYN packet throttle drops")   \
+_(OK, "TCP SYN packets passed")
+
+typedef enum
+{
+#define _(sym,str) SYN_FILTER_ERROR_##sym,
+  foreach_syn_filter_error
+#undef _
+    SYN_FILTER_N_ERROR,
+} syn_filter_error_t;
+
+static char *syn_filter4_error_strings[] = {
+#define _(sym,string) string,
+  foreach_syn_filter_error
+#undef _
+};
+
+typedef enum
+{
+  SYN_FILTER_NEXT_DROP,
+  SYN_FILTER_N_NEXT,
+} syn_filter_next_t;
+
+extern vnet_feature_arc_registration_t vnet_feat_arc_ip4_local;
+
+static uword
+syn_filter4_node_fn (vlib_main_t * vm,
+		     vlib_node_runtime_t * node, vlib_frame_t * frame)
+{
+  u32 n_left_from, *from, *to_next;
+  syn_filter_next_t next_index;
+  u32 ok_syn_packets = 0;
+  vnet_feature_main_t *fm = &feature_main;
+  u8 arc_index = vnet_feat_arc_ip4_local.feature_arc_index;
+  vnet_feature_config_main_t *cm = &fm->feature_config_mains[arc_index];
+  syn_filter4_runtime_t *rt = (syn_filter4_runtime_t *) node->runtime_data;
+  f64 now = vlib_time_now (vm);
+  /* Shut up spurious gcc warnings. */
+  u8 *c0 = 0, *c1 = 0, *c2 = 0, *c3 = 0;
+
+  from = vlib_frame_vector_args (frame);
+  n_left_from = frame->n_vectors;
+  next_index = node->cached_next_index;
+
+  if (now > rt->next_reset)
+    {
+      memset (rt->syn_counts, 0, vec_len (rt->syn_counts));
+      rt->next_reset = now + rt->reset_interval;
+    }
+
+  while (n_left_from > 0)
+    {
+      u32 n_left_to_next;
+
+      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+      while (n_left_from >= 8 && n_left_to_next >= 4)
+	{
+	  u32 bi0, bi1, bi2, bi3;
+	  vlib_buffer_t *b0, *b1, *b2, *b3;
+	  u32 next0, next1, next2, next3;
+	  ip4_header_t *ip0, *ip1, *ip2, *ip3;
+	  tcp_header_t *tcp0, *tcp1, *tcp2, *tcp3;
+	  u32 not_a_syn0 = 1, not_a_syn1 = 1, not_a_syn2 = 1, not_a_syn3 = 1;
+	  u64 hash0, hash1, hash2, hash3;
+
+	  /* Prefetch next iteration. */
+	  {
+	    vlib_buffer_t *p4, *p5, *p6, *p7;
+
+	    p4 = vlib_get_buffer (vm, from[4]);
+	    p5 = vlib_get_buffer (vm, from[5]);
+	    p6 = vlib_get_buffer (vm, from[6]);
+	    p7 = vlib_get_buffer (vm, from[7]);
+
+	    vlib_prefetch_buffer_header (p4, LOAD);
+	    vlib_prefetch_buffer_header (p5, LOAD);
+	    vlib_prefetch_buffer_header (p6, LOAD);
+	    vlib_prefetch_buffer_header (p7, LOAD);
+
+	    CLIB_PREFETCH (p4->data, CLIB_CACHE_LINE_BYTES, STORE);
+	    CLIB_PREFETCH (p5->data, CLIB_CACHE_LINE_BYTES, STORE);
+	    CLIB_PREFETCH (p6->data, CLIB_CACHE_LINE_BYTES, STORE);
+	    CLIB_PREFETCH (p7->data, CLIB_CACHE_LINE_BYTES, STORE);
+	  }
+
+	  /* speculatively enqueue b0 and b1 to the current next frame */
+	  to_next[0] = bi0 = from[0];
+	  to_next[1] = bi1 = from[1];
+	  to_next[2] = bi2 = from[2];
+	  to_next[3] = bi3 = from[3];
+	  from += 4;
+	  to_next += 4;
+	  n_left_from -= 4;
+	  n_left_to_next -= 4;
+
+	  b0 = vlib_get_buffer (vm, bi0);
+	  b1 = vlib_get_buffer (vm, bi1);
+	  b2 = vlib_get_buffer (vm, bi2);
+	  b3 = vlib_get_buffer (vm, bi3);
+
+	  vnet_get_config_data
+	    (&cm->config_main, &b0->current_config_index,
+	     &next0, 0 /* sizeof (c0[0]) */ );
+	  vnet_get_config_data
+	    (&cm->config_main, &b1->current_config_index,
+	     &next1, 0 /* sizeof (c0[0]) */ );
+	  vnet_get_config_data
+	    (&cm->config_main, &b2->current_config_index,
+	     &next2, 0 /* sizeof (c0[0]) */ );
+	  vnet_get_config_data
+	    (&cm->config_main, &b3->current_config_index,
+	     &next3, 0 /* sizeof (c0[0]) */ );
+
+	  /* Not TCP? */
+	  ip0 = vlib_buffer_get_current (b0);
+	  if (ip0->protocol != IP_PROTOCOL_TCP)
+	    goto trace00;
+
+	  tcp0 = ip4_next_header (ip0);
+	  /*
+	   * Not a SYN?
+	   * $$$$ hack: the TCP bitfield flags seem not to compile
+	   * correct code.
+	   */
+	  if (PREDICT_TRUE (!(tcp0->flags & 0x2)))
+	    goto trace00;
+
+	  not_a_syn0 = 0;
+	  hash0 = clib_xxhash ((u64) ip0->src_address.as_u32);
+	  c0 = &rt->syn_counts[hash0 & (_vec_len (rt->syn_counts) - 1)];
+	  if (PREDICT_FALSE (*c0 >= 0x80))
+	    {
+	      next0 = SYN_FILTER_NEXT_DROP;
+	      b0->error = node->errors[SYN_FILTER_ERROR_THROTTLED];
+	      goto trace00;
+	    }
+	  *c0 += 1;
+	  ok_syn_packets++;
+
+	trace00:
+	  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
+			     && (b0->flags & VLIB_BUFFER_IS_TRACED)))
+	    {
+	      syn_filter4_trace_t *t =
+		vlib_add_trace (vm, node, b0, sizeof (*t));
+	      t->not_a_syn = not_a_syn0;
+	      t->next_index = next0;
+	      t->filter_value = not_a_syn0 ? 0 : *c0;
+	    }
+
+	  /* Not TCP? */
+	  ip1 = vlib_buffer_get_current (b1);
+	  if (ip1->protocol != IP_PROTOCOL_TCP)
+	    goto trace01;
+
+	  tcp1 = ip4_next_header (ip1);
+	  /*
+	   * Not a SYN?
+	   * $$$$ hack: the TCP bitfield flags seem not to compile
+	   * correct code.
+	   */
+	  if (PREDICT_TRUE (!(tcp1->flags & 0x2)))
+	    goto trace01;
+
+	  not_a_syn1 = 0;
+	  hash1 = clib_xxhash ((u64) ip1->src_address.as_u32);
+	  c1 = &rt->syn_counts[hash1 & (_vec_len (rt->syn_counts) - 1)];
+	  if (PREDICT_FALSE (*c1 >= 0x80))
+	    {
+	      next1 = SYN_FILTER_NEXT_DROP;
+	      b1->error = node->errors[SYN_FILTER_ERROR_THROTTLED];
+	      goto trace01;
+	    }
+	  *c1 += 1;
+	  ok_syn_packets++;
+
+	trace01:
+	  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
+			     && (b1->flags & VLIB_BUFFER_IS_TRACED)))
+	    {
+	      syn_filter4_trace_t *t =
+		vlib_add_trace (vm, node, b1, sizeof (*t));
+	      t->not_a_syn = not_a_syn1;
+	      t->next_index = next1;
+	      t->filter_value = not_a_syn1 ? 0 : *c1;
+	    }
+
+	  /* Not TCP? */
+	  ip2 = vlib_buffer_get_current (b2);
+	  if (ip2->protocol != IP_PROTOCOL_TCP)
+	    goto trace02;
+
+	  tcp2 = ip4_next_header (ip2);
+	  /*
+	   * Not a SYN?
+	   * $$$$ hack: the TCP bitfield flags seem not to compile
+	   * correct code.
+	   */
+	  if (PREDICT_TRUE (!(tcp2->flags & 0x2)))
+	    goto trace02;
+
+	  not_a_syn2 = 0;
+	  hash2 = clib_xxhash ((u64) ip2->src_address.as_u32);
+	  c2 = &rt->syn_counts[hash2 & (_vec_len (rt->syn_counts) - 1)];
+	  if (PREDICT_FALSE (*c2 >= 0x80))
+	    {
+	      next2 = SYN_FILTER_NEXT_DROP;
+	      b2->error = node->errors[SYN_FILTER_ERROR_THROTTLED];
+	      goto trace02;
+	    }
+	  *c2 += 1;
+	  ok_syn_packets++;
+
+	trace02:
+	  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
+			     && (b2->flags & VLIB_BUFFER_IS_TRACED)))
+	    {
+	      syn_filter4_trace_t *t =
+		vlib_add_trace (vm, node, b2, sizeof (*t));
+	      t->not_a_syn = not_a_syn2;
+	      t->next_index = next2;
+	      t->filter_value = not_a_syn2 ? 0 : *c2;
+	    }
+
+	  /* Not TCP? */
+	  ip3 = vlib_buffer_get_current (b3);
+	  if (ip3->protocol != IP_PROTOCOL_TCP)
+	    goto trace03;
+
+	  tcp3 = ip4_next_header (ip3);
+	  /*
+	   * Not a SYN?
+	   * $$$$ hack: the TCP bitfield flags seem not to compile
+	   * correct code.
+	   */
+	  if (PREDICT_TRUE (!(tcp3->flags & 0x2)))
+	    goto trace03;
+
+	  not_a_syn3 = 0;
+	  hash3 = clib_xxhash ((u64) ip3->src_address.as_u32);
+	  c3 = &rt->syn_counts[hash3 & (_vec_len (rt->syn_counts) - 1)];
+	  if (PREDICT_FALSE (*c3 >= 0x80))
+	    {
+	      next3 = SYN_FILTER_NEXT_DROP;
+	      b3->error = node->errors[SYN_FILTER_ERROR_THROTTLED];
+	      goto trace03;
+	    }
+	  *c3 += 1;
+	  ok_syn_packets++;
+
+	trace03:
+	  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
+			     && (b3->flags & VLIB_BUFFER_IS_TRACED)))
+	    {
+	      syn_filter4_trace_t *t =
+		vlib_add_trace (vm, node, b3, sizeof (*t));
+	      t->not_a_syn = not_a_syn3;
+	      t->next_index = next3;
+	      t->filter_value = not_a_syn3 ? 0 : *c3;
+	    }
+	  vlib_validate_buffer_enqueue_x4 (vm, node, next_index,
+					   to_next, n_left_to_next,
+					   bi0, bi1, bi2, bi3,
+					   next0, next1, next2, next3);
+	}
+
+      while (n_left_from > 0 && n_left_to_next > 0)
+	{
+	  u32 bi0;
+	  vlib_buffer_t *b0;
+	  u32 next0;
+	  ip4_header_t *ip0;
+	  tcp_header_t *tcp0;
+	  u32 not_a_syn0 = 1;
+	  u32 hash0;
+	  u8 *c0;
+
+	  /* speculatively enqueue b0 to the current next frame */
+	  bi0 = from[0];
+	  to_next[0] = bi0;
+	  from += 1;
+	  to_next += 1;
+	  n_left_from -= 1;
+	  n_left_to_next -= 1;
+
+	  b0 = vlib_get_buffer (vm, bi0);
+
+	  vnet_get_config_data
+	    (&cm->config_main, &b0->current_config_index,
+	     &next0, 0 /* sizeof (c0[0]) */ );
+
+	  /* Not TCP? */
+	  ip0 = vlib_buffer_get_current (b0);
+	  if (ip0->protocol != IP_PROTOCOL_TCP)
+	    goto trace0;
+
+	  tcp0 = ip4_next_header (ip0);
+	  /*
+	   * Not a SYN?
+	   * $$$$ hack: the TCP bitfield flags seem not to compile
+	   * correct code.
+	   */
+	  if (PREDICT_TRUE (!(tcp0->flags & 0x2)))
+	    goto trace0;
+
+	  not_a_syn0 = 0;
+	  hash0 = clib_xxhash ((u64) ip0->src_address.as_u32);
+	  c0 = &rt->syn_counts[hash0 & (_vec_len (rt->syn_counts) - 1)];
+	  if (PREDICT_FALSE (*c0 >= 0x80))
+	    {
+	      next0 = SYN_FILTER_NEXT_DROP;
+	      b0->error = node->errors[SYN_FILTER_ERROR_THROTTLED];
+	      goto trace0;
+	    }
+	  *c0 += 1;
+	  ok_syn_packets++;
+
+	trace0:
+
+	  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
+			     && (b0->flags & VLIB_BUFFER_IS_TRACED)))
+	    {
+	      syn_filter4_trace_t *t =
+		vlib_add_trace (vm, node, b0, sizeof (*t));
+	      t->not_a_syn = not_a_syn0;
+	      t->next_index = next0;
+	      t->filter_value = not_a_syn0 ? 0 : *c0;
+	    }
+
+	  /* verify speculative enqueue, maybe switch current next frame */
+	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+					   to_next, n_left_to_next,
+					   bi0, next0);
+	}
+
+      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+    }
+
+  vlib_node_increment_counter (vm, syn_filter4_node.index,
+			       SYN_FILTER_ERROR_OK, ok_syn_packets);
+  return frame->n_vectors;
+}
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (syn_filter4_node, static) =
+{
+  .function = syn_filter4_node_fn,
+  .name = "syn-filter-4",
+  .vector_size = sizeof (u32),
+  .format_trace = format_syn_filter4_trace,
+  .type = VLIB_NODE_TYPE_INTERNAL,
+
+  .runtime_data_bytes = sizeof (syn_filter4_runtime_t),
+  .n_errors = ARRAY_LEN(syn_filter4_error_strings),
+  .error_strings = syn_filter4_error_strings,
+
+  .n_next_nodes = SYN_FILTER_N_NEXT,
+
+  /* edit / add dispositions here */
+  .next_nodes = {
+    [SYN_FILTER_NEXT_DROP] = "error-drop",
+  },
+};
+/* *INDENT-ON* */
+
+VLIB_NODE_FUNCTION_MULTIARCH (syn_filter4_node, syn_filter4_node_fn);
+
+/* *INDENT-OFF* */
+VNET_FEATURE_INIT (syn_filter_4, static) =
+{
+  .arc_name = "ip4-local",
+  .node_name = "syn-filter-4",
+  .runs_before = VNET_FEATURES("ip4-local-end-of-arc"),
+};
+/* *INDENT-ON* */
+
+int
+syn_filter_enable_disable (u32 sw_if_index, int enable_disable)
+{
+  vnet_main_t *vnm = vnet_get_main ();
+  vnet_sw_interface_t *sw;
+  int rv = 0;
+
+  /* Utterly wrong? */
+  if (pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))
+    return VNET_API_ERROR_INVALID_SW_IF_INDEX;
+
+  /* Not a physical port? */
+  sw = vnet_get_sw_interface (vnm, sw_if_index);
+  if (sw->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
+    return VNET_API_ERROR_INVALID_SW_IF_INDEX;
+
+  if (enable_disable)
+    {
+      vlib_main_t *vm = vlib_get_main ();
+      syn_filter4_runtime_t *rt;
+
+      rt = vlib_node_get_runtime_data (vm, syn_filter4_node.index);
+      vec_validate (rt->syn_counts, 1023);
+      /*
+       * Given perfect disperson / optimal hashing results:
+       * Allow 128k (successful) syns/sec. 1024, buckets each of which
+       * absorb 128 syns before filtering. Reset table once a second.
+       * Reality bites, lets try resetting once every 100ms.
+       */
+      rt->reset_interval = 0.1;	/* reset interval in seconds */
+    }
+
+  rv = vnet_feature_enable_disable ("ip4-local", "syn-filter-4",
+				    sw_if_index, enable_disable, 0, 0);
+
+  return rv;
+}
+
+static clib_error_t *
+syn_filter_enable_disable_command_fn (vlib_main_t * vm,
+				      unformat_input_t * input,
+				      vlib_cli_command_t * cmd)
+{
+  vnet_main_t *vnm = vnet_get_main ();
+  u32 sw_if_index = ~0;
+  int enable_disable = 1;
+  int rv;
+
+  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+    {
+      if (unformat (input, "disable"))
+	enable_disable = 0;
+      else if (unformat (input, "%U", unformat_vnet_sw_interface,
+			 vnm, &sw_if_index))
+	;
+      else
+	break;
+    }
+
+  if (sw_if_index == ~0)
+    return clib_error_return (0, "Please specify an interface...");
+
+  rv = syn_filter_enable_disable (sw_if_index, enable_disable);
+
+  switch (rv)
+    {
+    case 0:
+      break;
+
+    case VNET_API_ERROR_INVALID_SW_IF_INDEX:
+      return clib_error_return
+	(0, "Invalid interface, only works on physical ports");
+      break;
+
+    case VNET_API_ERROR_UNIMPLEMENTED:
+      return clib_error_return (0,
+				"Device driver doesn't support redirection");
+      break;
+
+    case VNET_API_ERROR_INVALID_VALUE:
+      return clib_error_return (0, "feature arc not found");
+
+    case VNET_API_ERROR_INVALID_VALUE_2:
+      return clib_error_return (0, "feature node not found");
+
+    default:
+      return clib_error_return (0, "syn_filter_enable_disable returned %d",
+				rv);
+    }
+  return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (sr_content_command, static) =
+{
+  .path = "ip syn filter",
+  .short_help = "ip syn filter <interface-name> [disable]",
+  .function = syn_filter_enable_disable_command_fn,
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/tcp/tcp_timer.h b/src/vnet/tcp/tcp_timer.h
new file mode 100644
index 0000000..fa25268
--- /dev/null
+++ b/src/vnet/tcp/tcp_timer.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __included_tcp_timer_h__
+#define __included_tcp_timer_h__
+
+#include <vppinfra/tw_timer_16t_2w_512sl.h>
+#include <vppinfra/tw_timer_16t_1w_2048sl.h>
+
+#endif /* __included_tcp_timer_h__ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
