The document discusses extending the ns network simulator. It can be extended in OTcl by modifying code and adding new files without recompiling. It can also be extended in C++ by modifying code, adding new files, and recompiling. The document provides examples of extending ns by adding a new message agent and packet header in both OTcl and C++. It also discusses debugging extensions in OTcl and C++ as well as addressing memory issues.
NS2 - the network simulator which is proved useful in studying the dynamic nature of communication networks. Simulation of wired as well as wireless network functions and protocols( e.g. routing algorithms, TCP, UDP ) can be done using NS2
NS2 - the network simulator which is proved useful in studying the dynamic nature of communication networks. Simulation of wired as well as wireless network functions and protocols( e.g. routing algorithms, TCP, UDP ) can be done using NS2
XDP in Practice: DDoS Mitigation @CloudflareC4Media
Video and slides synchronized, mp3 and slide download available at URL https://bit.ly/2NtlaER.
Gilberto Bertin discusses the architecture of Cloudflare’s automatic DDoS mitigation pipeline, the initial packet filtering solution based on Iptables, and why Cloudflare had to introduce userspace offload. Bertin also describes how they switched from a proprietary offload technology to XDP for network stack bypass and how they are using XDP to load balance traffic. Filmed at qconlondon.com.
Gilberto Bertin works as a System Engineer at Cloudflare London. After working on variety of technologies like P2P VPNs and userspace TCP/IP stacks, he joined the Cloudflare DDoS team in London to help filter all the bad internet traffic.
In this talk Jiří Pírko discusses the design and evolution of the VLAN implementation in Linux, the challenges and pitfalls as well as hardware acceleration and alternative implementations.
Jiří Pírko is a major contributor to kernel networking and the creator of libteam for link aggregation.
Presentation of Mr.Vibin Chander, CEO, Shabari Software Solutions, CBE. Delivered during the Faculty development Program on NS2 organized by Department of Computer Science, Rathinam College of Arts and Science (Autonomous), Eachanari, Coimbatore - 641021.
XDP in Practice: DDoS Mitigation @CloudflareC4Media
Video and slides synchronized, mp3 and slide download available at URL https://bit.ly/2NtlaER.
Gilberto Bertin discusses the architecture of Cloudflare’s automatic DDoS mitigation pipeline, the initial packet filtering solution based on Iptables, and why Cloudflare had to introduce userspace offload. Bertin also describes how they switched from a proprietary offload technology to XDP for network stack bypass and how they are using XDP to load balance traffic. Filmed at qconlondon.com.
Gilberto Bertin works as a System Engineer at Cloudflare London. After working on variety of technologies like P2P VPNs and userspace TCP/IP stacks, he joined the Cloudflare DDoS team in London to help filter all the bad internet traffic.
In this talk Jiří Pírko discusses the design and evolution of the VLAN implementation in Linux, the challenges and pitfalls as well as hardware acceleration and alternative implementations.
Jiří Pírko is a major contributor to kernel networking and the creator of libteam for link aggregation.
Presentation of Mr.Vibin Chander, CEO, Shabari Software Solutions, CBE. Delivered during the Faculty development Program on NS2 organized by Department of Computer Science, Rathinam College of Arts and Science (Autonomous), Eachanari, Coimbatore - 641021.
This presentation introduces Data Plane Development Kit overview and basics. It is a part of a Network Programming Series.
First, the presentation focuses on the network performance challenges on the modern systems by comparing modern CPUs with modern 10 Gbps ethernet links. Then it touches memory hierarchy and kernel bottlenecks.
The following part explains the main DPDK techniques, like polling, bursts, hugepages and multicore processing.
DPDK overview explains how is the DPDK application is being initialized and run, touches lockless queues (rte_ring), memory pools (rte_mempool), memory buffers (rte_mbuf), hashes (rte_hash), cuckoo hashing, longest prefix match library (rte_lpm), poll mode drivers (PMDs) and kernel NIC interface (KNI).
At the end, there are few DPDK performance tips.
Tags: access time, burst, cache, dpdk, driver, ethernet, hub, hugepage, ip, kernel, lcore, linux, memory, pmd, polling, rss, softswitch, switch, userspace, xeon
Capturing NIC and Kernel TX and RX Timestamps for Packets in GoScyllaDB
Go gives us net.Dial and net.Listen for sending and receiving data at Layer 4. Now you will see how to send and receive raw packets directly to and from the NIC at Layer 1 to get timestamp information from timestamping-enabled NICs and when packets enter and leave the Linux kernel. Capturing these timestamps allows us to get better granularity when measuring latency and jitter instead of relying on time.Now() in userspace where that is subject to additional time introduced by the OS and Go runtime schedulers.
Simple, fast, and scalable torch7 tutorialJin-Hwa Kim
A tutorial based on basic information of Torch7. It covers installation, simple runable codes, tensor manipulations, sweep out key-packages and post-hoc audience q&a.
Kernel Recipes 2014 - NDIV: a low overhead network traffic diverterAnne Nicolas
NDIV is a young, very simple, yet efficient network traffic diverter. Its purpose is to help build network applications that intercept packets at line rate with a very low processing overhead. A first example application is a stateless HTTP server reaching line rate on all packet sizes.
Willy Tarreau, HaproxyTech
Imagine writing a pure Python library which can achieve the performance of Fortran or C/C++.
To this end we have developed Pyccel, which translates Python code to either Fortran or C, and makes the generated code callable from Python. The generated Fortran or C code is not only fast, but also human-readable; hence it can easily be profiled and optimized for the target machine.
Pyccel has a focus on high-performance computing applications, where the efficient usage of the available hardware resources is fundamental.
To this end it provides type annotations, function decorators, and OpenMP pragmas.
Pyccel is easy to use, is almost completely written in Python, and compares favourably against other Python accelerators.
2. Outline
Extending ns
In OTcl
In C++
Debugging
2
3. ns Directory Structure
ns-allinone
Tcl8.3 TK8.3 OTcl tclcl ns-2 nam-1
tcl ... C++ code
ex test lib mcast ...
examples validation tests
OTcl code
3
4. Extending ns in OTcl
If you don’t want to compile
source your changes in your sim
scripts
Otherwise
Modifyingcode; recompile
Adding new files
• Change Makefile (NS_TCL_LIB),
tcl/lib/ns-lib.tcl
• Recompile
4
5. Example: Agent/Message
C n2 n4 C
cross
128Kb, 50ms
traffic
n0 n1
10Mb, 1ms 10Mb, 1ms
S n3 n5 R
msg agent
5
6. Agent/Message
pkt: 64 bytes
of arbitrary Receiver-side
string processing
S R
A UDP agent (without UDP header)
Up to 64 bytes user message
Good for fast prototyping a simple idea
Usage requires extending ns functionality
6
12. Agent/Message: Step 6
Routing
# Packet loss produced by queueing
# Routing protocol: let’s run distance
vector
$ns rtproto DV
12
13. Agent/Message: Step 7
Cross traffic
set udp0 [new Agent/UDP]
$ns attach-agent $n(2) $udp0
set null0 [new Agent/NULL]
$ns attach-agent $n(4) $null0
$ns connect $udp0 $null0
set exp0 [new
Application/Traffic/Exponential]
$exp0 set rate_ 128k
$exp0 attach-agent $udp0
$ns at 1.0 “$exp0 start”
13
14. Agent/Message: Step 8
Message agents
set sdr [new Sender]
$sdr set seq_ 0
$sdr set packetSize_ 1000
set rcvr [new Receiver]
$rcvr set packetSize_ 40
$ns attach-agent $n(3) $sdr
$ns attach-agent $n(5) $rcvr
$ns connect $sdr $rcvr
$ns at 1.1 “$sdr send-next”
14
15. Agent/Message: Step 9
End-of-simulation wrapper (as usual)
$ns at 2.0 finish
proc finish {} {
global ns fd
$ns flush-trace
close $fd
exit 0
}
$ns run
15
16. Agent/Message: Result
Example output
> ./ns msg.tcl
Receiver gets seq 0 from 3
Sender gets ack 0 from 5
Receiver gets seq 1 from 3
Sender gets ack 1 from 5
Receiver gets seq 2 from 3
Sender gets ack 2 from 5
Receiver gets seq 3 from 3
Sender gets ack 3 from 5
Receiver gets seq 4 from 3
Sender gets ack 4 from 5
Receiver gets seq 5 from 3
16
17. Add Your Changes into ns
ns-allinone
Tcl8.3 TK8.3 OTcl tclcl ns-2 nam-1
tcl ... C++ code
ex test mysrc lib mcast ...
examples validation tests msg.tcl OTcl code
17
18. Add Your Change into ns
tcl/lib/ns-lib.tcl
Class Simulator
…
source ../mysrc/msg.tcl
Makefile
NS_TCL_LIB =
tcl/mysrc/msg.tcl
…
Or: change Makefile.in, make distclean,
then ./configure --enable-debug ,
make depend and make
18
19. Outline
Extending ns
In OTcl
In C++
• New components
19
20. Extending ns in C++
Modifying code
makedepend
Recompile
Adding code in new files
Change Makefile
make depend
recompile
20
21. Creating New Components
Guidelines
Two styles
New agent based on existing packet
headers
Add new packet header
21
22. Guidelines
Decide position in class hierarchy
I.e., which class to derive from?
Create new packet header (if
necessary)
Create C++ class, fill in methods
Define OTcl linkage (if any)
Write OTcl code (if any)
Build (and debug)
22
23. New Agent, Old Header
TCP jump start
Wide-open transmission window at
the beginning
From cwnd_ += 1 To cwnd_ =
MAXWIN_
23
27. TCP Jump Start – Step 4
Create an instance of jump-start TCP
in your tcl script tcp-js.tcl
Set MAXWIN_ value in tcl
Add tcp-js.o in Makefile.in
Re-configure, make depend and
recompile
Run yr tcl script tcp-js.tcl
27
28. Packet Format
ts_
cmn header
header ptype_
ip header
data uid_
tcp header
size_
rtp header
iface_
trace header
...
28
29. New Packet Header
Create new header structure
Enable tracing support of new header
Create static class for OTcl linkage
(packet.h)
Enable new header in OTcl (tcl/lib/ns-
packet.tcl)
This does not apply when you add a
new field into an existing header!
29
30. How Packet Header Works
Packet
PacketHeader/Common
next_
hdrlen_
bits_ size determined hdr_cmn
at compile time PacketHeader/IP
size determined size determined hdr_ip
at simulator at compile time PacketHeader/TCP
startup time
(PacketHeaderManager) size determined hdr_tcp
at compile time
……
30
31. Example: Agent/Message
New packet header for 64-byte
message
New transport agent to process this
new header
31
33. New Packet Header
– Step 2
PacketHeader/Message
static class MessageHeaderClass :
public PacketHeaderClass {
public:
MessageHeaderClass() :
PacketHeaderClass("PacketHeader/Message
",
sizeof(hdr_msg)) {
bind_offset(&hdr_msg::offset_);
}
} class_msghdr;
33
34. New Packet Header
– Step 3
Enable tracing (packet.h):
enum packet_t {
PT_TCP,
…,
PT_MESSAGE,
PT_NTYPE // This MUST be the LAST one
};
class p_info {
……
name_[PT_MESSAGE] = “message”;
name_[PT_NTYPE]= "undefined";
……
};
34
35. New Packet Header
– Step 4
Register new header (tcl/lib/ns-
packet.tcl)
foreach prot {
{ Common off_cmn_ }
…
{ Message off_msg_ }
}
add-packet-header $prot
35
36. Packet Header: Caution
Some old code, e.g.:
RtpAgent::RtpAgent() {
……
bind(“off_rtp_”, &off_rtp);
}
……
hdr_rtp* rh = (hdr_rtp*)p-
>access(off_rtp_);
Don’t follow this example!
36
44. C++/OTcl Debugging
(gdb) call Tcl::instance().eval(“debug 1”)
15: lappend auto_path $dbg_library
dbg15.3> w
*0: application
15: lappend auto_path $dbg_library
dbg15.4> Simulator info instances
_o1
dbg15.5> _o1 now
0
dbg15.6> # and other fun stuff
dbg15.7> c
(gdb) where
#0 0x102218 in write()
......
44
45. Memory Debugging in ns
Purify
SetPURIFY macro in ns Makefile
Usually, put -colloctor=<ld_path>
Gray Watson’s dmalloc library
http://www.dmalloc.com
make distclean
./configure --with-dmalloc=<dmalloc_path>
Analyze results: dmalloc_summarize
45
46. dmalloc: Usage
Turn on dmalloc
aliasdmalloc ’eval ‘dmalloc –C !*`’
dmalloc -l log low
dmalloc_summarize ns < logfile
ns must be in current directory
Itemize how much memory is
allocated in each function
46
47. Pitfalls
Scalability vs flexibility
Or, how to write scalable simulation?
Memory conservation tips
Memory leaks
47
48. Scalability vs Flexibility
It’s tempting to write all-OTcl
simulation
Benefit:
quick prototyping
Cost: memory + runtime
Solution
Control the granularity of your split
object by migrating methods from
OTcl to C++
48
49. THE Merit of OTcl
high Program size, complexity low
C/C++ OTcl
split objects
Smoothly adjust the granularity of scripting to
balance extensibility and performance
With complete compatibility with existing
simulation scripts
49
50. Object Granularity Tips
Functionality
Per-packet processing C++
Hooks, frequently changing code
OTcl
Data management
Complex/large data structure C++
One-time configuration variables
OTcl
50
51. Memory Conservation Tips
Remove unused packet headers
Avoid trace-all
Use arrays for a sequence of variables
Instead of n$i, say n($i)
n$i
Avoid OTcl temporary variables
Use dynamic binding
delay_bind() instead of bind()
See object.{h,cc}
See tips for running large sim in ns at
www.isi.edu/ns/nsnam/ns-largesim.html
51
52. Memory Conservation Tips
Remove unused packet headers
Avoid trace-all
Use arrays for a sequence of variables
Instead of n$i, say n($i)
n$i
Avoid OTcl temporary variables
Use dynamic binding
delay_bind() instead of bind()
See object.{h,cc}
See tips for running large sim in ns at
www.isi.edu/ns/nsnam/ns-largesim.html
52
53. Memory Leaks
Purify or dmalloc, but be careful about split
objects:
for {set i 0} {$i < 500} {incr i} {
set a [new RandomVariable/Constant]
}
It leaks memory, but can’t be detected!
Solution
Explicitly delete EVERY split object that was
new-ed
53
54. Final Word
My extended ns dumps OTcl scripts!
Find the last 10-20 lines of the dump
Is the error related to “_o*** cmd …” ?
• Check your command()
Otherwise, check the otcl script
pointed by the error message
54