ABSTRACT: In order to perform realistic network simulations, one needs a traffic generator that is capable of generating realistic synthetic traffic in a closed-loop fashion that "looks like" traffic found on an actual network. We describe such a traffic generation system for the widely used ns-2 simulator. The system takes as input a packet header trace taken from a network link of interest. The trace is "reverse compiled" into a source-level characterization of each TCP connection present in the trace. The characterization, called a connection vector, is then used as input to an ns module called tmix that emulates the socket-level behavior of the source application that created the corresponding connection in the trace. This emulation faithfully reproduces the essential pattern of socket reads and writes that the original application performed without knowledge of what the original application actually was. When combined with a network path emulation component we have constructed called DelayBox, the resulting traffic generated in the simulation is statistically representative of the traffic measured on the real link. This approach to synthetic traffic generation allows one to automatically repro-duce in ns the full range of TCP connections found on an arbitrary link. Thus with our tools, researchers no longer need make arbitrary decisions on how traffic is generated in simulations and can instead easily generate TCP traffic that represents the use of a net-work by the full mix of applications measured on actual network links of interest. The method is evaluated by applying it to packet header traces taken from campus and wide-area networks and comparing the statistical properties of traffic on the measured links with traffic generated by tmix in ns.