diff -r 789dd0f5ca94 examples/tcp-echo.cc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/tcp-echo.cc	Fri Jun 13 19:08:56 2008 +0200
@@ -0,0 +1,129 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008 Louis Pasteur University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: David Gross <david.gross@eturs.u-strasbg.fr>
+ */
+
+// Network topology
+//
+//       n0    n1
+//       |     |
+//       ========
+//         LAN
+//
+// - TCP flows from n0 to n1 and back
+// - DropTail queues 
+// - Tracing of queues and packet receptions to file "tcp-echo6.tr"
+
+#include <fstream>
+#include "ns3/core-module.h"
+#include "ns3/simulator-module.h"
+#include "ns3/helper-module.h"
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("TcpEchoExample");
+
+int main (int argc, char **argv)
+{
+#if 1
+  LogComponentEnable ("TcpEchoExample", LOG_LEVEL_INFO);
+/*  LogComponentEnable("Object", LOG_LEVEL_ALL);
+  LogComponentEnable("Queue", LOG_LEVEL_ALL);
+  LogComponentEnable("DropTailQueue", LOG_LEVEL_ALL);
+  LogComponentEnable("Channel", LOG_LEVEL_ALL);
+  LogComponentEnable("CsmaChannel", LOG_LEVEL_ALL);
+  LogComponentEnable("NetDevice", LOG_LEVEL_ALL);
+  LogComponentEnable("CsmaNetDevice", LOG_LEVEL_ALL);
+  LogComponentEnable("PacketSocket", LOG_LEVEL_ALL);
+  LogComponentEnable("Socket", LOG_LEVEL_ALL);
+*/
+	LogComponentEnable("Ipv4EndPointDemux", LOG_LEVEL_ALL);
+  LogComponentEnable("TcpSocketImpl", LOG_LEVEL_ALL);
+  LogComponentEnable("TcpL4Protocol", LOG_LEVEL_ALL);
+  LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL);
+  LogComponentEnable("Ipv4StaticRouting", LOG_LEVEL_ALL);
+  LogComponentEnable("Ipv4Interface", LOG_LEVEL_ALL);
+  LogComponentEnable("NdiscIpv4Interface", LOG_LEVEL_ALL);
+  LogComponentEnable("Ipv4LoopbackInterface", LOG_LEVEL_ALL);
+  LogComponentEnable("OnOffApplication", LOG_LEVEL_ALL);
+  LogComponentEnable("PacketSinkApplication", LOG_LEVEL_ALL);
+	LogComponentEnable("Icmpv6L4Protocol", LOG_LEVEL_ALL);
+  LogComponentEnable("TcpEchoClientApplication", LOG_LEVEL_ALL);
+  LogComponentEnable("TcpEchoServerApplication", LOG_LEVEL_ALL);
+	LogComponentEnable("NdiscCache", LOG_LEVEL_ALL);
+#endif
+
+  CommandLine cmd;
+  cmd.Parse (argc, argv);
+
+
+	/* Explicitly create the nodes required by the topology (shown above). */
+  NS_LOG_INFO ("Create nodes.");
+  NodeContainer n;
+	n.Create(2);
+
+	InternetStackHelper internetv4;
+  internetv4.Install (n);
+
+	/* Explicitly create the channels required by the topology (shown above).*/
+  NS_LOG_INFO ("Create channels.");
+  CsmaHelper csma;
+  csma.SetChannelParameter ("BitRate", DataRateValue(5000000));
+  csma.SetChannelParameter ("Delay", TimeValue(MilliSeconds (2)));
+  NetDeviceContainer d = csma.Install (n);
+
+  Ipv4AddressHelper ipv4;
+	ipv4.SetBase ("10.1.1.0", "255.255.255.0");
+  NS_LOG_INFO ("Assign IPv6 Addresses.");
+	Ipv4InterfaceContainer i = ipv4.Assign (d);
+
+  NS_LOG_INFO ("Create Applications.");
+
+	/* Create a TcpEchoServer application on node one. */
+  uint16_t port = 7;  // well-known echo port number
+  TcpEchoServerHelper server;
+  server.SetPort (port);
+  ApplicationContainer apps = server.Install (n.Get(1));
+  apps.Start (Seconds (0.0));
+  apps.Stop (Seconds (10.0));
+
+	/* Create a TcpEchoClient application to send TCP datagrams from node zero to node one.  */
+  uint32_t packetSize = 1024;
+  uint32_t maxPacketCount = 1;
+  Time interPacketInterval = Seconds (1.);
+  TcpEchoClientHelper client;
+  client.SetRemote (i.GetAddress (1), port);
+  client.SetLocal (i.GetAddress (0));
+  client.SetAppAttribute ("MaxPackets", UintegerValue (maxPacketCount));
+  client.SetAppAttribute ("Interval", TimeValue(interPacketInterval));
+  client.SetAppAttribute ("PacketSize", UintegerValue (packetSize));
+  apps = client.Install (n.Get (0));
+  apps.Start (Seconds (2.0));
+  apps.Stop (Seconds (10.0));
+
+  std::ofstream ascii;
+  ascii.open ("tcp-echo.tr");
+  CsmaHelper::EnablePcapAll ("tcp-echo");
+  CsmaHelper::EnableAsciiAll (ascii);
+  
+	NS_LOG_INFO ("Run Simulation.");
+  Simulator::Run ();
+  Simulator::Destroy ();
+  NS_LOG_INFO ("Done.");
+}
+
diff -r 789dd0f5ca94 examples/wscript
--- a/examples/wscript	Fri Jun 13 15:35:07 2008 +0100
+++ b/examples/wscript	Fri Jun 13 19:08:56 2008 +0200
@@ -25,6 +25,10 @@ def build(bld):
     obj = bld.create_ns3_program('udp-echo',
         ['csma', 'internet-stack'])
     obj.source = 'udp-echo.cc'
+
+    obj = bld.create_ns3_program('tcp-echo',
+        ['csma', 'internet-stack'])
+    obj.source = 'tcp-echo.cc'
 
     obj = bld.create_ns3_program('csma-broadcast',
         ['csma', 'internet-stack'])
diff -r 789dd0f5ca94 src/applications/tcp-echo/tcp-echo-client.cc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/applications/tcp-echo/tcp-echo-client.cc	Fri Jun 13 19:08:56 2008 +0200
@@ -0,0 +1,187 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007-2008 Louis Pasteur University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: David Gross <david.gross@eturs.u-strasbg.fr>
+ */
+
+#include "ns3/log.h"
+#include "ns3/ipv4-address.h"
+#include "ns3/nstime.h"
+#include "ns3/inet-socket-address.h"
+#include "ns3/socket.h"
+#include "ns3/simulator.h"
+#include "ns3/socket-factory.h"
+#include "ns3/packet.h"
+#include "ns3/uinteger.h"
+#include "ns3/tcp-header.h"
+
+#include "tcp-echo-client.h"
+
+namespace ns3
+{
+
+	NS_LOG_COMPONENT_DEFINE("TcpEchoClientApplication");
+	NS_OBJECT_ENSURE_REGISTERED (TcpEchoClient);
+
+	TypeId TcpEchoClient::GetTypeId ()
+	{
+		static TypeId tid = TypeId ("ns3::TcpEchoClient")
+			.SetParent<Application> ()
+			.AddConstructor<TcpEchoClient> ()
+			.AddAttribute ("MaxPackets", "XXX",
+					UintegerValue (100),
+					MakeUintegerAccessor (&TcpEchoClient::m_count),
+					MakeUintegerChecker<uint32_t> ())
+			.AddAttribute ("Interval", "XXX",
+					TimeValue (Seconds(1.0)),
+					MakeTimeAccessor (&TcpEchoClient::m_interval),
+					MakeTimeChecker ())
+			.AddAttribute ("RemoteIpv4", "XXX",
+					Ipv4AddressValue (),
+					MakeIpv4AddressAccessor (&TcpEchoClient::m_peerAddress),
+					MakeIpv4AddressChecker ())
+			.AddAttribute ("LocalIpv4", "XXX",
+					Ipv4AddressValue (),
+					MakeIpv4AddressAccessor (&TcpEchoClient::m_localAddress),
+					MakeIpv4AddressChecker ())
+			.AddAttribute ("RemotePort", "XXX",
+					UintegerValue (0),
+					MakeUintegerAccessor (&TcpEchoClient::m_peerPort),
+					MakeUintegerChecker<uint16_t> ())
+			.AddAttribute ("PacketSize", "Size of packets generated",
+					UintegerValue (100),
+					MakeUintegerAccessor (&TcpEchoClient::m_size),
+					MakeUintegerChecker<uint32_t> ())
+			;
+		return tid;
+	}
+
+	TcpEchoClient::TcpEchoClient()
+	{
+		NS_LOG_FUNCTION_NOARGS();
+		m_sent = 0;
+		m_socket = 0;
+		m_sendEvent = EventId ();
+	}
+
+	TcpEchoClient::~TcpEchoClient()
+	{
+		NS_LOG_FUNCTION_NOARGS();
+	}
+
+	void TcpEchoClient::SetRemote (Ipv4Address ipv6, uint16_t port)
+	{
+		NS_LOG_FUNCTION(this << ipv6 << port);
+		m_peerAddress = ipv6;
+		m_peerPort = port;
+	}
+
+	void TcpEchoClient::SetLocal (Ipv4Address ipv6)
+	{
+		NS_LOG_FUNCTION(this << ipv6);
+		m_localAddress = ipv6;
+	}
+
+	void TcpEchoClient::DoDispose()
+	{
+		NS_LOG_FUNCTION_NOARGS();
+		Application::DoDispose();
+	}
+
+	void TcpEchoClient::StartApplication()
+	{
+		NS_LOG_FUNCTION_NOARGS();
+
+		TypeId tid = TypeId::LookupByName ("ns3::TcpSocketFactory");   
+		Ptr<SocketFactory> socketFactory = GetNode()->GetObject<SocketFactory> (tid);
+
+		m_socket = socketFactory->CreateSocket();
+		m_socket->Bind();
+		m_socket->Connect (InetSocketAddress (m_peerAddress, m_peerPort));
+		m_socket->SetRecvCallback (MakeCallback (&TcpEchoClient::HandleRead, this));
+/*		m_socket->SetAcceptCallback (MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
+				MakeNullCallback<void, Ptr<Socket>, const Address&> (),
+				MakeCallback(&TcpEchoClient::CloseConnection, this) );
+*/
+		ScheduleTransmit(Seconds(0.));
+	}
+
+	void TcpEchoClient::StopApplication()
+	{
+		NS_LOG_FUNCTION_NOARGS();
+
+		m_socket->Close();
+
+		if (m_socket)
+		{
+			m_socket->SetRecvCallback(MakeNullCallback<void, Ptr<Socket> > ());
+		}
+
+		Simulator::Cancel(m_sendEvent);
+	}
+
+	void TcpEchoClient::ScheduleTransmit(Time dt)
+	{
+		NS_LOG_FUNCTION(this << dt);
+		m_sendEvent = Simulator::Schedule(dt, &TcpEchoClient::Send, this);
+	}
+
+	void TcpEchoClient::Send()
+	{
+		NS_LOG_FUNCTION_NOARGS();
+		NS_ASSERT(m_sendEvent.IsExpired());
+
+		Ptr<Packet> p = Create<Packet> (m_size);
+
+		m_socket->Send(p);
+
+		++m_sent;
+		NS_LOG_INFO("Sent " << m_size << " bytes to " << m_peerAddress);
+
+		if (m_sent < m_count)
+		{
+			ScheduleTransmit(m_interval);
+		}
+	}
+
+	void TcpEchoClient::HandleRead(Ptr<Socket> socket)
+  {
+    NS_LOG_FUNCTION (this << socket);
+    Ptr<Packet> packet=0;
+    while (packet = socket->Recv ())
+    {
+      SocketRxAddressTag tag;
+      bool found=false;
+      found  = packet->FindFirstMatchingTag (tag);
+      NS_ASSERT (found);
+      Address from = tag.GetAddress ();
+      /* XXX packet->RemoveTag (tag); */
+      if (InetSocketAddress::IsMatchingType (from))
+      {
+        InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
+        NS_LOG_INFO ("Client Received " << packet->GetSize() << " bytes from " << address.GetIpv4());
+      }
+    }
+  }
+	
+	void TcpEchoClient::CloseConnection(Ptr<Socket> socket)
+	{
+		socket->Close();
+	}
+
+} /* namespace ns3 */
+
diff -r 789dd0f5ca94 src/applications/tcp-echo/tcp-echo-client.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/applications/tcp-echo/tcp-echo-client.h	Fri Jun 13 19:08:56 2008 +0200
@@ -0,0 +1,161 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007-2008 Louis Pasteur University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: David Gross <david.gross@eturs.u-strasbg.fr>
+ */
+
+#ifndef TCP_ECHO6_CLIENT_H
+#define TCP_ECHO6_CLIENT_H
+
+#include <list>
+
+#include "ns3/application.h"
+#include "ns3/event-id.h"
+#include "ns3/ptr.h"
+#include "ns3/ipv4-address.h"
+
+namespace ns3
+{
+	class Socket;
+	class Packet;
+
+	/**
+	 * \class TcpEchoClient
+	 * \brief A simple TCPv6 echo client.
+	 */
+	class TcpEchoClient : public Application
+	{
+		public:
+			/**
+			 * \brief Get the type ID.
+			 * \return type ID
+			 */
+			static TypeId GetTypeId (void);
+
+			/**
+			 * \brief Constructor.
+			 */
+			TcpEchoClient();
+
+			/**
+			 * \brief Destructor.
+			 */
+			virtual ~TcpEchoClient();
+
+			/**
+			 * \brief Set the remote peer.
+			 * \param ipv6 IPv6 address of the peer
+			 * \param port port of the peer
+			 */
+			void SetRemote (Ipv4Address ipv6, uint16_t port);
+
+			/**
+			 * \brief Set the local address.
+			 * \param ipv6 local IPv6 address
+			 */
+			void SetLocal (Ipv4Address ipv6);
+
+		protected:
+			/**
+			 * \brief Dispose the instance.
+			 */
+			virtual void DoDispose();
+
+		private:
+			/**
+			 * \brief Start the application.
+			 */
+			virtual void StartApplication();
+
+			/**
+			 * \brief Stop the application.
+			 */
+			virtual void StopApplication();
+
+			/**
+			 * \brief Schedule sending a packet.
+			 * \param dt interval between packet
+			 */
+			void ScheduleTransmit(Time dt);
+
+			/**
+			 * \brief The send method.
+			 */
+			void Send();
+
+			/**
+			 * \brief The receive method.
+			 * \param socket socket that receive the packet
+			 */
+			void HandleRead(Ptr<Socket> socket);
+
+			/**
+			 * \brief Close the connection.
+			 * \param socket the socket
+			 */
+			void CloseConnection(Ptr<Socket> socket);
+
+			/**
+			 * \brief Server IPv6 address.
+			 */
+			Ipv4Address m_peerAddress;
+
+			/**
+			 * \brief Local IPv6 address.
+			 */
+			Ipv4Address m_localAddress;
+
+			/**
+			 * \brief Server port.
+			 */
+			uint16_t m_peerPort;
+
+			/**
+			 * \brief Number of packets that will be sent.
+			 */
+			uint32_t m_count;
+
+			/**
+			 * \brief Interval between two packets.
+			 */
+			Time m_interval;
+
+			/**
+			 * \brief Size of the packets.
+			 */
+			uint32_t m_size;
+
+			/**
+			 * \brief Number of packets sent.
+			 */
+			uint32_t m_sent;
+
+			/**
+			 * \brief The socket.
+			 */
+			Ptr<Socket> m_socket;
+
+			/**
+			 * \brief The event ID.
+			 */
+			EventId m_sendEvent;
+	};
+
+} /* namespace ns3 */
+
+#endif /* TCP_ECHO6_CLIENT_H */
+
diff -r 789dd0f5ca94 src/applications/tcp-echo/tcp-echo-server.cc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/applications/tcp-echo/tcp-echo-server.cc	Fri Jun 13 19:08:56 2008 +0200
@@ -0,0 +1,132 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 Louis Pasteur University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
+ */
+
+#include "ns3/log.h"
+#include "ns3/ipv4-address.h"
+#include "ns3/nstime.h"
+#include "ns3/inet-socket-address.h"
+#include "ns3/simulator.h"
+#include "ns3/socket.h"
+#include "ns3/socket-factory.h"
+#include "ns3/packet.h"
+#include "ns3/uinteger.h"
+
+#include "tcp-echo-server.h"
+
+namespace ns3
+{
+
+	NS_LOG_COMPONENT_DEFINE("TcpEchoServerApplication");
+	NS_OBJECT_ENSURE_REGISTERED (TcpEchoServer);
+
+	TypeId TcpEchoServer::GetTypeId ()
+	{
+		static TypeId tid = TypeId ("ns3::TcpEchoServer")
+			.SetParent<Application> ()
+			.AddConstructor<TcpEchoServer> ()
+			.AddAttribute ("Port", "Port on which we listen for incoming packets.",
+					UintegerValue (9),
+					MakeUintegerAccessor (&TcpEchoServer::m_port),
+					MakeUintegerChecker<uint16_t> ())
+			;
+		return tid;
+	}
+
+	TcpEchoServer::TcpEchoServer()
+	{
+		NS_LOG_FUNCTION_NOARGS();
+	}
+
+	TcpEchoServer::~TcpEchoServer()
+	{
+		NS_LOG_FUNCTION_NOARGS();
+	}
+
+	void TcpEchoServer::DoDispose()
+	{
+		NS_LOG_FUNCTION_NOARGS();
+		Application::DoDispose();
+	}
+
+	void TcpEchoServer::StartApplication()
+	{
+		NS_LOG_FUNCTION_NOARGS();
+
+		if (!m_socket)
+		{
+			TypeId tid = TypeId::LookupByName ("ns3::TcpSocketFactory");
+			Ptr<SocketFactory> socketFactory = GetNode()->GetObject<SocketFactory>(tid);
+			m_socket=socketFactory->CreateSocket();
+			InetSocketAddress local = InetSocketAddress (m_port);
+			m_socket->Bind(local);
+			m_socket->Listen(0);
+		}
+
+		m_socket->SetAcceptCallback (MakeNullCallback<bool, Ptr<Socket>, const Address &> (), MakeNullCallback<void, Ptr<Socket>, const Address&> (),	MakeCallback(&TcpEchoServer::CloseConnection, this) );
+		m_socket->SetRecvCallback(MakeCallback(&TcpEchoServer::HandleRead, this));
+	}
+
+	void TcpEchoServer::StopApplication()
+	{
+		NS_LOG_FUNCTION_NOARGS();
+
+		m_socket->Close();
+
+		if (m_socket)
+		{
+			m_socket->SetRecvCallback(MakeNullCallback<void, Ptr<Socket> > ());
+		}
+	}
+
+	void TcpEchoServer::CloseConnection(Ptr<Socket> socket)
+	{
+		socket->Close();
+	}
+
+	void TcpEchoServer::Respond(Ptr<Socket> s, Ptr<Packet> p)
+	{
+		s->Send(p);
+	}
+
+	void TcpEchoServer::HandleRead(Ptr<Socket> socket)
+  {
+    NS_LOG_FUNCTION (this << socket);
+    Ptr<Packet> packet=0;
+    while (packet = socket->Recv ())
+    {
+      SocketRxAddressTag tag;
+      bool found=false;
+      found  = packet->FindFirstMatchingTag (tag);
+      NS_ASSERT (found);
+      Address from = tag.GetAddress ();
+      
+			/* XXX packet->RemoveTag (tag); */
+      if (InetSocketAddress::IsMatchingType (from))
+      {
+        InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
+        NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " << address.GetIpv4());
+        NS_LOG_LOGIC ("Echoing packet");
+        socket->Send (packet);
+      }
+    }
+  }
+
+} /* namespace ns3 */
+
diff -r 789dd0f5ca94 src/applications/tcp-echo/tcp-echo-server.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/applications/tcp-echo/tcp-echo-server.h	Fri Jun 13 19:08:56 2008 +0200
@@ -0,0 +1,107 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007-2008 Louis Pasteur University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: David Gross <david.gross@eturs.u-strasbg.fr>
+ */
+
+#ifndef TCP_ECHO6_SERVER_H
+#define TCP_ECHO6_SERVER_H
+
+#include "ns3/application.h"
+#include "ns3/event-id.h"
+#include "ns3/ptr.h"
+#include "ns3/address.h"
+
+namespace ns3
+{
+	class Socket;
+	class Packet;
+
+	/**
+	 * \class TcpEchoServer
+	 * \brief A simple TCPv6 echo server.
+	 */
+	class TcpEchoServer : public Application
+	{
+		public:
+			/**
+			 * \brief Get the type ID.
+			 * \return type ID
+			 */
+			static TypeId GetTypeId ();
+
+			/**
+			 * \brief Constructor.
+			 */
+			TcpEchoServer();
+
+			/**
+			 * \brief Destructor.
+			 */
+			virtual ~TcpEchoServer();
+
+			void Respond(Ptr<Socket> s, Ptr<Packet> p);
+
+		protected:
+			/**
+			 * \brief Dispose the object.
+			 */
+			virtual void DoDispose();
+
+		private:
+			/**
+			 * \brief Start the application.
+			 */
+			virtual void StartApplication();
+
+			/**
+			 * \brief Stop the application.
+			 */
+			virtual void StopApplication();
+
+			/**
+			 * \brief Receive method of the application.
+			 * \param socket the socket
+			 */
+			void HandleRead(Ptr<Socket> socket);
+
+			/**
+			 * \brief Close the connection.
+			 * \param socket the socket
+			 */
+			void CloseConnection(Ptr<Socket> socket);
+
+			/**
+			 * \brief Server port.
+			 */
+			uint16_t m_port;
+
+			/**
+			 * \brief Server socket.
+			 */
+			Ptr<Socket> m_socket;
+
+			/**
+			 * \brief Local address.
+			 */
+			Address m_local;
+	};
+
+} /* namespace ns3 */
+
+#endif /* TCP_ECHO6_SERVER_H */
+
diff -r 789dd0f5ca94 src/applications/tcp-echo/waf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/applications/tcp-echo/waf	Fri Jun 13 19:08:56 2008 +0200
@@ -0,0 +1,1 @@
+exec "`dirname "$0"`"/../../../waf "$@"
diff -r 789dd0f5ca94 src/applications/tcp-echo/wscript
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/applications/tcp-echo/wscript	Fri Jun 13 19:08:56 2008 +0200
@@ -0,0 +1,15 @@
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+def build(bld):
+    module = bld.create_ns3_module('tcp-echo', ['internet-stack'])
+    module.source = [
+        'tcp-echo-client.cc',
+        'tcp-echo-server.cc',
+        ]
+    headers = bld.create_obj('ns3header')
+    headers.module = 'tcp-echo'
+    headers.source = [
+        'tcp-echo-client.h',
+        'tcp-echo-server.h',
+        ]
+
diff -r 789dd0f5ca94 src/helper/tcp-echo-helper.cc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/helper/tcp-echo-helper.cc	Fri Jun 13 19:08:56 2008 +0200
@@ -0,0 +1,88 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008 Louis Pasteur University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: David Gross <david.gross@eturs.u-strasbg.fr>
+ */
+
+#include "tcp-echo-helper.h"
+#include "ns3/tcp-echo-server.h"
+#include "ns3/tcp-echo-client.h"
+#include "ns3/uinteger.h"
+
+namespace ns3 {
+
+	TcpEchoServerHelper::TcpEchoServerHelper ()
+		: m_port (9)
+	{
+	}
+
+	void TcpEchoServerHelper::SetPort (uint16_t port)
+	{
+		m_port = port;
+	}
+
+	ApplicationContainer TcpEchoServerHelper::Install (NodeContainer c)
+	{
+		ApplicationContainer apps;
+		for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
+		{
+			Ptr<Node> node = *i;
+			Ptr<TcpEchoServer> server = CreateObject<TcpEchoServer> ("Port", UintegerValue(m_port));
+			node->AddApplication (server);
+			apps.Add (server);
+		}
+		return apps;
+	}
+
+	TcpEchoClientHelper::TcpEchoClientHelper ()
+	{
+		m_factory.SetTypeId (TcpEchoClient::GetTypeId ());
+	}
+
+	void TcpEchoClientHelper::SetRemote (Ipv4Address ip, uint16_t port)
+	{
+		m_remoteIp = ip;
+		m_remotePort = port;
+	}
+
+	void TcpEchoClientHelper::SetLocal (Ipv4Address ip)
+	{
+		m_localIp = ip;
+	}
+
+	void TcpEchoClientHelper::SetAppAttribute (std::string name, const AttributeValue& value)
+	{
+		m_factory.Set (name, value);
+	}
+
+	ApplicationContainer TcpEchoClientHelper::Install (NodeContainer c)
+	{
+		ApplicationContainer apps;
+		for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
+		{
+			Ptr<Node> node = *i;
+			Ptr<TcpEchoClient> client = m_factory.Create<TcpEchoClient> ();
+			client->SetRemote (m_remoteIp, m_remotePort);
+			client->SetLocal (m_localIp);
+			node->AddApplication (client);
+			apps.Add (client);
+		}
+		return apps;  
+	}
+
+} /* namespace ns3 */
+
diff -r 789dd0f5ca94 src/helper/tcp-echo-helper.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/helper/tcp-echo-helper.h	Fri Jun 13 19:08:56 2008 +0200
@@ -0,0 +1,130 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008 Louis Pasteur University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: David Gross <david.gross@eturs.u-strasbg.fr>
+ */
+
+#ifndef TCP_ECHO6_HELPER_H
+#define TCP_ECHO6_HELPER_H
+
+#include <list>
+#include <stdint.h>
+
+#include "application-container.h"
+#include "node-container.h"
+#include "ns3/object-factory.h"
+#include "ns3/ipv4-address.h"
+
+namespace ns3 {
+
+	/**
+	 * \class TcpEchoServerHelper
+	 * \brief TCPv6 Echo server helper.
+	 */
+	class TcpEchoServerHelper
+	{
+		public:
+			/**
+			 * \brief Constructor.
+			 */
+			TcpEchoServerHelper ();
+
+			/**
+			 * \brief Set the bind port.
+			 * \param port port to bind
+			 */
+			void SetPort (uint16_t port);
+
+			/**
+			 * \brief Install the application in Nodes.
+			 * \param c list of Nodes
+			 * \return application container
+			 */
+			ApplicationContainer Install (NodeContainer c);
+
+		private:
+			/**
+			 * \brief Local port.
+			 */
+			uint16_t m_port;
+	};
+
+	/**
+	 * \class TcpEchoClientHelper
+	 * \brief TCPv6 Echo client helper.
+	 */
+	class TcpEchoClientHelper
+	{
+		public:
+			/**
+			 * \brief Constructor.
+			 */
+			TcpEchoClientHelper ();
+
+			/**
+			 * \brief Set the remote IPv6 address and port.
+			 * \param ip IPv6 address
+			 * \param port port to connect
+			 */
+			void SetRemote (Ipv4Address ip, uint16_t port);
+
+			/**
+			 * \brief Set the local address.
+			 * \param ipv6 local IPv6 address
+			 */
+			void SetLocal (Ipv4Address ipv6);
+
+			/**
+			 * \brief Set Some attributes.
+			 * \param name attribute name
+			 * \param value attribute value
+			 */
+			void SetAppAttribute (std::string name, const AttributeValue& value);
+
+			/**
+			 * \brief Install the application in Nodes.
+			 * \param c list of Nodes
+			 * \return application container
+			 */
+			ApplicationContainer Install (NodeContainer c);
+
+		private:
+			/**
+			 * \brief An object factory.
+			 */
+			ObjectFactory m_factory;
+
+			/**
+			 * \brief The remote IPv6.
+			 */
+			Ipv4Address m_remoteIp;
+
+			/**
+			 * \brief The remote port.
+			 */
+			uint16_t m_remotePort;
+
+			/**
+			 * \brief The local IPv6.
+			 */
+			Ipv4Address m_localIp;
+	};
+
+} /* namespace ns3 */
+
+#endif /* TCP_ECHO6_HELPER_H */
+
diff -r 789dd0f5ca94 src/helper/wscript
--- a/src/helper/wscript	Fri Jun 13 15:35:07 2008 +0100
+++ b/src/helper/wscript	Fri Jun 13 19:08:56 2008 +0200
@@ -1,7 +1,7 @@
 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
 def build(bld):
-    helper = bld.create_ns3_module('helper', ['internet-stack', 'wifi', 'point-to-point', 'csma', 'olsr', 'global-routing', 'onoff', 'packet-sink', 'udp-echo'])
+    helper = bld.create_ns3_module('helper', ['internet-stack', 'wifi', 'point-to-point', 'csma', 'olsr', 'global-routing', 'onoff', 'packet-sink', 'udp-echo', 'tcp-echo'])
     helper.source = [
         'node-container.cc',
         'net-device-container.cc',
@@ -20,6 +20,7 @@ def build(bld):
         'packet-socket-helper.cc',
         'ipv4-interface-container.cc',
         'udp-echo-helper.cc',
+        'tcp-echo-helper.cc',
         ]
 
     headers = bld.create_obj('ns3header')
@@ -42,4 +43,5 @@ def build(bld):
         'packet-socket-helper.h',
         'ipv4-interface-container.h',
         'udp-echo-helper.h',
+        'tcp-echo-helper.h',
         ]
diff -r 789dd0f5ca94 src/wscript
--- a/src/wscript	Fri Jun 13 15:35:07 2008 +0100
+++ b/src/wscript	Fri Jun 13 19:08:56 2008 +0200
@@ -22,6 +22,7 @@ all_modules = (
     'applications/onoff',
     'applications/packet-sink',
     'applications/udp-echo',
+    'applications/tcp-echo',
     'routing/olsr',
     'routing/global-routing',
     'mobility',
