IEC'00 ns Lab 2 - advanced simulation in ns
Exercise 3: Changing TCP to compete with UDP
In previous exercise, the TCP flow seems to occupy a little less
share of the bandwidth. Can you modify the existing TCP (Tahoe)
implementation in ns-2 and make it more aggressive?
In the following, we will show an example that we have talked about in
the lecture, i.e., the TCP Jump Start.
You are encouraged to explore other simple tricks by looking at
tcp.h in ns.
An Aggressive TCP - Jump Start
- Go to your ns directory, e.g., ns-allinone-2.1b6/ns-2.1b6,
create a new file tcp-js.h which contains the
following:
class JSTcpAgent : public TcpAgent {
public:
virtual void set_initial_window() {
cwnd_ = maxwin_;
}
private:
int maxwin_;
};
- Still in your ns directory, create a new file tcp-js.cc:
#include "tcp-js.h"
static JSTcpClass : public TclClass {
public:
JSTcpClass() : TclClass("Agent/TCP/JS") {}
TclObject* create(int, const char*const*) {
return (new JSTcpAgent());
}
};
JSTcpAgent::JSTcpAgent() {
bind("MAXWIN_", maxwin_);
}
- Add tcp-js.cc into your Makefile:
OBJ_CC = \
tcp-js.cc \
......
- Re-compile ns. In ns-2.1b6/, do:
prompt> make depend
prompt> make
- In your previous simulation script (lab2a.tcl), change all Agent/TCP (but not
the Agent/TCP/Sink !) to Agent/TCP/JS.
Re-run the previous simulation and:
- Use nam to show visualize TCP sequence plot, notice anything
different?
- Compare the bandwidth share between TCP and UDP.
- If you finished all these, try tweaking TCP a little bit
more. A good starting point: find TcpAgent::slowdown(int how) and
TcpAgent::opencwnd() in tcp.cc, try changing the way that cwnd_ is
increased and reduced, observe its effect using TCP sequence plot in
nam.
References: