diff --git a/vnet/vnet/pg/stream.c b/vnet/vnet/pg/stream.c
new file mode 100644
index 0000000..1dd5624
--- /dev/null
+++ b/vnet/vnet/pg/stream.c
@@ -0,0 +1,420 @@
+/*
+ * 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.
+ */
+/*
+ * pg_stream.c: packet generator streams
+ *
+ * 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/vnet.h>
+#include <vnet/pg/pg.h>
+
+/* Mark stream active or inactive. */
+void pg_stream_enable_disable (pg_main_t * pg, pg_stream_t * s, int want_enabled)
+{
+  vnet_main_t * vnm = vnet_get_main();
+  pg_interface_t * pi = vec_elt_at_index (pg->interfaces, s->pg_if_index);
+
+  want_enabled = want_enabled != 0;
+
+  if (pg_stream_is_enabled (s) == want_enabled)
+    /* No change necessary. */
+    return;
+      
+  if (want_enabled)
+    s->n_packets_generated = 0;
+
+  /* Toggle enabled flag. */
+  s->flags ^= PG_STREAM_FLAGS_IS_ENABLED;
+
+  ASSERT (! pool_is_free (pg->streams, s));
+
+  pg->enabled_streams
+    = clib_bitmap_set (pg->enabled_streams, s - pg->streams, want_enabled);
+
+  vnet_hw_interface_set_flags (vnm, pi->hw_if_index,
+			       (want_enabled
+				? VNET_HW_INTERFACE_FLAG_LINK_UP
+				: 0));
+
+  vnet_sw_interface_set_flags (vnm, pi->sw_if_index,
+			       (want_enabled
+				? VNET_SW_INTERFACE_FLAG_ADMIN_UP
+				: 0));
+			       
+  vlib_node_set_state (pg->vlib_main,
+		       pg_input_node.index,
+		       (clib_bitmap_is_zero (pg->enabled_streams)
+			? VLIB_NODE_STATE_DISABLED
+			: VLIB_NODE_STATE_POLLING));
+
+  s->packet_accumulator = 0;
+  s->time_last_generate = 0;
+}
+
+static u8 * format_pg_interface_name (u8 * s, va_list * args)
+{
+  pg_main_t * pg = &pg_main;
+  u32 if_index = va_arg (*args, u32);
+  pg_interface_t * pi;
+
+  pi = vec_elt_at_index (pg->interfaces, if_index);
+  s = format (s, "pg/stream-%d", pi->stream_index);
+
+  return s;
+}
+
+VNET_DEVICE_CLASS (pg_dev_class,static) = {
+  .name = "pg",
+  .tx_function = pg_output,
+  .format_device_name = format_pg_interface_name,
+};
+
+static uword pg_set_rewrite (vnet_main_t * vnm,
+			     u32 sw_if_index,
+			     u32 l3_type,
+			     void * dst_address,
+			     void * rewrite,
+			     uword max_rewrite_bytes)
+{
+  u16 * h = rewrite;
+
+  if (max_rewrite_bytes < sizeof (h[0]))
+    return 0;
+
+  h[0] = clib_host_to_net_u16 (l3_type);
+  return sizeof (h[0]);
+}
+
+VNET_HW_INTERFACE_CLASS (pg_interface_class,static) = {
+  .name = "Packet generator",
+  .set_rewrite = pg_set_rewrite,
+};
+
+u32 pg_interface_find_free (pg_main_t * pg, uword stream_index)
+{
+  vnet_main_t * vnm = vnet_get_main();
+  pg_interface_t * pi;
+  vnet_hw_interface_t * hi;
+  u32 i, l;
+
+  if ((l = vec_len (pg->free_interfaces)) > 0)
+    {
+      i = pg->free_interfaces[l - 1];
+      _vec_len (pg->free_interfaces) = l - 1;
+      pi = vec_elt_at_index (pg->interfaces, i);
+      pi->stream_index = stream_index;
+    }    
+  else
+    {
+      i = vec_len (pg->interfaces);
+      vec_add2 (pg->interfaces, pi, 1);
+
+      pi->stream_index = stream_index;
+      pi->hw_if_index = vnet_register_interface (vnm,
+						 pg_dev_class.index, i,
+						 pg_interface_class.index, stream_index);
+      hi = vnet_get_hw_interface (vnm, pi->hw_if_index);
+      pi->sw_if_index = hi->sw_if_index;
+    }
+
+  return i;
+}
+
+static void do_edit (pg_stream_t * stream,
+		     pg_edit_group_t * g,
+		     pg_edit_t * e,
+		     uword want_commit)
+{
+  u32 i, i0, i1, mask, n_bits_left;
+  u8 * v, * s, * m;
+
+  i0 = e->lsb_bit_offset / BITS (u8);
+
+  /* Make space for edit in value and mask. */
+  vec_validate (g->fixed_packet_data, i0);
+  vec_validate (g->fixed_packet_data_mask, i0);
+
+  if (e->type != PG_EDIT_FIXED)
+    {
+      switch (e->type)
+	{
+	case PG_EDIT_RANDOM:
+	case PG_EDIT_INCREMENT:
+	  e->last_increment_value = pg_edit_get_value (e, PG_EDIT_LO);
+	  break;
+
+	default:
+	  break;
+	}
+
+      if (want_commit) 
+        {
+          ASSERT(e->type != PG_EDIT_INVALID_TYPE);
+          vec_add1 (g->non_fixed_edits, e[0]);
+        }
+      return;
+    }
+
+  s = g->fixed_packet_data;
+  m = g->fixed_packet_data_mask;
+
+  n_bits_left = e->n_bits;
+  i0 = e->lsb_bit_offset / BITS (u8);
+  i1 = e->lsb_bit_offset % BITS (u8);
+
+  v = e->values[PG_EDIT_LO];
+  i = pg_edit_n_alloc_bytes (e) - 1;
+
+  /* Odd low order bits?. */
+  if (i1 != 0 && n_bits_left > 0)
+    {
+      u32 n = clib_min (n_bits_left, BITS (u8) - i1);
+
+      mask = pow2_mask (n) << i1;
+
+      ASSERT (i0 < vec_len (s));
+      ASSERT (i < vec_len (v));
+      ASSERT ((v[i] &~ mask) == 0);
+
+      s[i0] |= v[i] & mask;
+      m[i0] |= mask;
+
+      i0--;
+      i--;
+      n_bits_left -= n;
+    }
+
+  /* Even bytes. */
+  while (n_bits_left >= 8)
+    {
+      ASSERT (i0 < vec_len (s));
+      ASSERT (i < vec_len (v));
+
+      s[i0] = v[i];
+      m[i0] = ~0;
+
+      i0--;
+      i--;
+      n_bits_left -= 8;
+    }
+
+  /* Odd high order bits. */
+  if (n_bits_left > 0)
+    {
+      mask = pow2_mask (n_bits_left);
+
+      ASSERT (i0 < vec_len (s));
+      ASSERT (i < vec_len (v));
+      ASSERT ((v[i] &~ mask) == 0);
+
+      s[i0] |= v[i] & mask;
+      m[i0] |= mask;
+    }
+
+  if (want_commit)
+    pg_edit_free (e);
+}
+
+void pg_edit_group_get_fixed_packet_data (pg_stream_t * s,
+					  u32 group_index,
+					  void * packet_data,
+					  void * packet_data_mask)
+{
+  pg_edit_group_t * g = pg_stream_get_group (s, group_index);
+  pg_edit_t * e;
+
+  vec_foreach (e, g->edits)
+    do_edit (s, g, e, /* want_commit */ 0);
+
+  memcpy (packet_data, g->fixed_packet_data, vec_len (g->fixed_packet_data));
+  memcpy (packet_data_mask, g->fixed_packet_data_mask, vec_len (g->fixed_packet_data_mask));
+}
+
+static void perform_fixed_edits (pg_stream_t * s)
+{
+  pg_edit_group_t * g;
+  pg_edit_t * e;
+  word i;
+
+  for (i = vec_len (s->edit_groups) - 1; i >= 0; i--)
+    {
+      g = vec_elt_at_index (s->edit_groups, i);
+      vec_foreach (e, g->edits)
+	do_edit (s, g, e, /* want_commit */ 1);
+
+      /* All edits have either been performed or added to
+	 g->non_fixed_edits.  So, we can delete the vector. */
+      vec_free (g->edits);
+    }
+
+  vec_free (s->fixed_packet_data_mask);
+  vec_free (s->fixed_packet_data);
+  vec_foreach (g, s->edit_groups)
+    {
+      int i;
+      g->start_byte_offset = vec_len (s->fixed_packet_data);
+
+      /* Relocate and copy non-fixed edits from group to stream. */
+      vec_foreach (e, g->non_fixed_edits)
+	e->lsb_bit_offset += g->start_byte_offset * BITS (u8);
+
+      for (i = 0; i < vec_len (g->non_fixed_edits); i++)
+        ASSERT(g->non_fixed_edits[i].type != PG_EDIT_INVALID_TYPE);
+      
+      vec_add (s->non_fixed_edits,
+	       g->non_fixed_edits,
+	       vec_len (g->non_fixed_edits));
+      vec_free (g->non_fixed_edits);
+
+      vec_add (s->fixed_packet_data,
+	       g->fixed_packet_data,
+	       vec_len (g->fixed_packet_data));
+      vec_add (s->fixed_packet_data_mask,
+	       g->fixed_packet_data_mask,
+	       vec_len (g->fixed_packet_data_mask));
+    }
+}
+
+void pg_stream_add (pg_main_t * pg, pg_stream_t * s_init)
+{
+  vlib_main_t * vm = pg->vlib_main;
+  pg_stream_t * s;
+  uword * p;
+
+  if (! pg->stream_index_by_name)
+    pg->stream_index_by_name
+      = hash_create_vec (0, sizeof (s->name[0]), sizeof (uword));
+
+  /* Delete any old stream with the same name. */
+  if (s_init->name
+      && (p = hash_get_mem (pg->stream_index_by_name, s_init->name)))
+    {
+      pg_stream_del (pg, p[0]);
+    }
+
+  pool_get (pg->streams, s);
+  s[0] = s_init[0];
+
+  /* Give it a name. */
+  if (! s->name)
+    s->name = format (0, "stream%d", s - pg->streams);
+  else
+    s->name = vec_dup (s->name);
+
+  hash_set_mem (pg->stream_index_by_name, s->name, s - pg->streams);
+
+  /* Get fixed part of buffer data. */
+  perform_fixed_edits (s);
+
+  /* Determine packet size. */
+  switch (s->packet_size_edit_type)
+    {
+    case PG_EDIT_INCREMENT:
+    case PG_EDIT_RANDOM:
+      if (s->min_packet_bytes == s->max_packet_bytes)
+	s->packet_size_edit_type = PG_EDIT_FIXED;
+      break;
+
+    default:
+      /* Get packet size from fixed edits. */
+      s->packet_size_edit_type = PG_EDIT_FIXED;
+      if (! s->replay_packet_templates)
+	s->min_packet_bytes = s->max_packet_bytes = vec_len (s->fixed_packet_data);
+      break;
+    }
+
+  s->last_increment_packet_size = s->min_packet_bytes;
+
+  {
+    pg_buffer_index_t * bi;
+    int n;
+
+    if (! s->buffer_bytes)
+      s->buffer_bytes = s->max_packet_bytes;
+
+    s->buffer_bytes = vlib_buffer_round_size (s->buffer_bytes);
+
+    n = s->max_packet_bytes / s->buffer_bytes;
+    n += (s->max_packet_bytes % s->buffer_bytes) != 0;
+
+    vec_resize (s->buffer_indices, n);
+
+    vec_foreach (bi, s->buffer_indices)
+      bi->free_list_index = vlib_buffer_create_free_list (vm, s->buffer_bytes,
+							  "pg stream %d buffer #%d",
+							  s - pg->streams,
+							  1 + (bi - s->buffer_indices));
+  }
+
+  /* Find an interface to use. */
+  s->pg_if_index = pg_interface_find_free (pg, s - pg->streams);
+
+  {
+    pg_interface_t * pi = vec_elt_at_index (pg->interfaces, s->pg_if_index);
+    vlib_rx_or_tx_t rx_or_tx;
+
+    vlib_foreach_rx_tx (rx_or_tx)
+      {
+	if (s->sw_if_index[rx_or_tx] == ~0)
+	  s->sw_if_index[rx_or_tx] = pi->sw_if_index;
+      }
+  }
+
+  /* Connect the graph. */
+  s->next_index = vlib_node_add_next (vm, pg_input_node.index, s->node_index);
+}
+
+void pg_stream_del (pg_main_t * pg, uword index)
+{
+  vlib_main_t * vm = pg->vlib_main;
+  pg_stream_t * s;
+  pg_buffer_index_t * bi;
+
+  s = pool_elt_at_index (pg->streams, index);
+
+  pg_stream_enable_disable (pg, s, /* want_enabled */ 0);
+  vec_add1 (pg->free_interfaces, s->pg_if_index);
+  hash_unset_mem (pg->stream_index_by_name, s->name);
+
+  vec_foreach (bi, s->buffer_indices)
+    {
+      vlib_buffer_delete_free_list (vm, bi->free_list_index);
+      clib_fifo_free (bi->buffer_fifo);
+    }
+
+  pg_stream_free (s);
+  pool_put (pg->streams, s);
+}
+
