<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Altentee &#187; Performance &#38; Test Automation Experts &#187; network</title>
	<atom:link href="http://altentee.com/tag/network/feed/" rel="self" type="application/rss+xml" />
	<link>http://altentee.com</link>
	<description>Performance and Test Automation Experts</description>
	<lastBuildDate>Sat, 12 Jun 2010 00:35:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Determining Network Time in Watir Scripts</title>
		<link>http://altentee.com/2009/determining-network-time-in-watir-scripts/</link>
		<comments>http://altentee.com/2009/determining-network-time-in-watir-scripts/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 01:35:08 +0000</pubDate>
		<dc:creator>Tim Koopmans</dc:creator>
				<category><![CDATA[90kts]]></category>
		<category><![CDATA[Altentee]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[watir]]></category>

		<guid isPermaLink="false">http://90kts.com/blog/2009/determining-network-time-in-watir-scripts/</guid>
		<description><![CDATA[<p>By this I mean I wanted to determine how much network and server time was spent processing a request initiated by a Watir script. Server time as defined by time to first buffer and network time as time to last buffer (minus the first).</p>
<p>I couldn&#8217;t really do this from Ruby itself, so I installed Fiddler. [...]]]></description>
			<content:encoded><![CDATA[<p>By this I mean I wanted to determine how much network and server time was spent processing a request initiated by a Watir script. Server time as defined by time to first buffer and network time as time to last buffer (minus the first).</p>
<p>I couldn&#8217;t really do this from Ruby itself, so I installed <strong><a href="http://www.fiddler2.com/fiddler2/">Fiddler</a></strong>. Fiddler lets you capture traffic in much the same way as ethereal / wireshark but with a nice GUI. There are some <strong><a href="http://www.fiddler2.com/Fiddler/Dev/ScriptSamples.asp">Fiddler customization scripts</a></strong> which let you display this info in the Custom column i.e.<br />
<code>oSession["ui-customcolumn"] = "FB: " + oSession["X-TTFB"] + "; LB: " + oSession["X-TTLB"];</code></p>
<p>But if you&#8217;re a neat freak like me and want them in separate columns then do this:<br />
<code><br />
public  static  BindUIColumn("Time")<br />
  function  CalcMethodCol1(oS:  Session){<br />
    if (null != oS.oRequest) return DateTime.Now.ToString("dd/MM/yy HH:mm:ss.ffff");<br />
    else return String.Empty;<br />
  }</p>
<p>  public  static  BindUIColumn("AbbreviatedUrl")<br />
  function  CalcMethodCol2(oS:  Session){<br />
    if (null != oS.oRequest) return oS.url.substring(oS.url.lastIndexOf("/"));<br />
    else return String.Empty;<br />
  }</p>
<p>  public  static  BindUIColumn("TTFBuffer")<br />
  function  CalcMethodCol3(oS:  Session){<br />
    if (null != oS.oResponse) return oS["X-TTFB"];<br />
    else return String.Empty;<br />
  }</p>
<p>  public  static  BindUIColumn("TTLBuffer")<br />
  function  CalcMethodCol4(oS:  Session){<br />
    if (null != oS.oResponse) return oS["X-TTLB"];<br />
    else return String.Empty;<br />
  }<br />
</code></p>
<p>You place them before you declare the <strong>static function OnBeforeRequest</strong>. The time stamp used above ends up being the &#8216;end&#8217; timestamp, not the &#8217;start&#8217; so you just need to subtract time to last buffer to determine that. You end up with this in your summary view:<br />
<a href='http://90kts.com/blog/wp-content/uploads/2009/03/ttfb.png' title='ttfb.png'><img src='http://90kts.com/blog/wp-content/uploads/2009/03/ttfb.png' alt='ttfb.png' /></a></p>
<p>Once this is done you can pretty up the results by copying the &#8216;Full Summary&#8217; for your selected sessions in Fiddler and pasting them into Excel. This was the main reason for doing this. If you&#8217;re happy with the Fiddler &#8216;timeline&#8217; view then you don&#8217;t need to bother. I just wanted the data so I could merge/correlate with other data sources.<br />
<a href='http://90kts.com/blog/wp-content/uploads/2009/03/gantt.png' title='gantt.png'><img src='http://90kts.com/blog/wp-content/uploads/2009/03/gantt.png' alt='gantt.png' /></a></p>
<p>Would be interested to know if anyone has achieved this in ruby itself. I was thinking of using the <strong><a href="http://90kts.com/blog/2008/httpwatch-a-free-alternative-using-ruby/">webrick/httpproxy</a></strong> but would have come short if testing a HTTPS web app.</p>
]]></content:encoded>
			<wfw:commentRss>http://altentee.com/2009/determining-network-time-in-watir-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Faking it! (UDP packets that is&#8230;)</title>
		<link>http://altentee.com/2007/faking-it-udp-packets-that-is/</link>
		<comments>http://altentee.com/2007/faking-it-udp-packets-that-is/#comments</comments>
		<pubDate>Wed, 02 May 2007 22:51:51 +0000</pubDate>
		<dc:creator>Tim Koopmans</dc:creator>
				<category><![CDATA[90kts]]></category>
		<category><![CDATA[Altentee]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://90kts.com/blog/2007/faking-it-udp-packets-that-is/</guid>
		<description><![CDATA[<p>An associate of mine recently wanted a load script that could simulate thousands of UDP packets carrying a custom payload coming from different IP addresses. They were implementing a customised RFID solution that needed to simulate load from a lot of sources (think active RFID tags).</p>
<p>There are many different ways you can accomplish this, solutions [...]]]></description>
			<content:encoded><![CDATA[<p>An associate of mine recently wanted a load script that could simulate thousands of UDP packets carrying a custom payload coming from different IP addresses. They were implementing a customised RFID solution that needed to simulate load from a lot of sources (think active RFID tags).</p>
<p>There are many different <a href="http://webloadtesting.typepad.com/web_performance/2004/05/ip_spoofing_let.html">ways</a> you can accomplish this, solutions like LoadRunner will offer the ability to spoof source IP addresses, but in this case the client couldn&#8217;t afford hefty licensing fees. So getting back to basics, I launched the *flood* from a cygwin shell running ruby.</p>
<p>The code looked a little like this&#8230;</p>
<p><span id="more-274"></span><br />
<strong>UDP Faker.rb</strong><br />
<code><br />
def ipchecksum(data)<br />
    checksum = data.unpack("n*").inject(0) { |s, x| s + x }<br />
    ((checksum >> 16) + (checksum &#038; 0xffff)) ^ 0xffff<br />
end</p>
<p>require 'socket'</p>
<p>class UDP_Faker</p>
<p>    @@id = 1234 - 1</p>
<p>    def initialize<br />
        @s = Socket.new(Socket::PF_INET, Socket::SOCK_RAW, Socket::IPPROTO_RAW)<br />
        @s.setsockopt(Socket::IPPROTO_IP, Socket::IP_HDRINCL, 1)<br />
    end</p>
<p>    def send(src, sport, dst, dport, payload = '')<br />
        dst_numeric = dst.split(/\./).map { |x| x.to_i }<br />
        to = [ Socket::AF_INET,<br />
            dport, dst_numeric, '' ].flatten.pack('snCCCCa8')<br />
        packet = make_ip_header([<br />
            [ '01000101', 'B8' ],                # version, hlen<br />
            [ 0, 'C' ],                          # tos<br />
            [ 28 + payload.size, 'n' ],          # total len<br />
            [ @@id += 1, 'n' ],                  # id<br />
            [ 0, 'n' ],                          # flags, offset<br />
            [ 64, 'C' ],                         # ttl<br />
            [ 17, 'C' ],                         # protocol<br />
            [ 0, 'n' ],                          # checksum<br />
            [ ip2long(src), 'N' ],               # source<br />
            [ ip2long(dst), 'N' ],               # destination<br />
        ])<br />
        packet << make_udp_header([<br />
            [ sport, 'n'],                        # source port<br />
            [ dport, 'n' ],                       # destination port<br />
            [ 8 + payload.size, 'n' ],            # len<br />
            [ 0, 'n' ]                            # checksum (mandatory)<br />
        ])<br />
        packet << payload<br />
        @s.send(packet, 0, to)<br />
    end</p>
<p>    private</p>
<p>    def ip2long(ip)<br />
        long = 0<br />
        ip.split(/\./).reverse.each_with_index do |x, i|<br />
            long += x.to_i << (i * 8  )<br />
        end<br />
        long<br />
    end</p>
<p>    def ipchecksum(data)<br />
        checksum = data.unpack("n*").inject(0) { |s, x| s + x }<br />
        ((checksum >> 16) + (checksum &#038; 0xffff)) ^ 0xffff<br />
    end</p>
<p>    def make_ip_header(parts)<br />
        template = ''<br />
        data = []<br />
        parts.each do |part|<br />
            data += part[0..-2]<br />
            template << part[-1]<br />
        end<br />
        data_str = data.pack(template)<br />
        checksum = ipchecksum(data_str)<br />
        data[-3] = checksum<br />
        data.pack(template)<br />
    end</p>
<p>    def make_udp_header(parts)<br />
        template = ''<br />
        data = []<br />
        parts.each do |part|<br />
            data += part[0..-2]<br />
            template << part[-1]<br />
        end<br />
        data.pack(template)<br />
    end</p>
<p>end</p>
<p>testRun = UDP_Faker.new<br />
loop do<br />
	#             Source IP	     Port  Destination IP   Port   Payload<br />
	testRun.send('203.64.36.24', 2069, '124.191.161.6', 81,    'Blob: here comes the data ...')<br />
end<br />
# TODO: Loop through a range of source IP addy's.<br />
# Return response from server. Use correctly formatted blob.<br />
</code></p>
<p>In a similar vein, but long since shutdown, the guys at <a href="http://www.thehackerschoice.com">Hackers Choice</a> provided some excellent C code for flooding TCP connections, which I also found useful in this project in order to conduct some stress to break testing. Understandably, some people might misuse this script, but for internal uses, I found it extremely useful to flood the TCP/IP stack. You can dowload the code here: <a href='http://90kts.com/blog/wp-content/uploads/2007/05/flood_connect.c' title='flood_connect.c'>flood_connect.c</a></p>
<p>It's usage is along the lines of this:<br />
<code><br />
Options:<br />
    -S           use SSL after TCP connect (not usuable with -u, sets port=443)<br />
    -u           use UDP protocol (default: TCP) (not usable with -c)<br />
    -p port      port to connect to (default: %d)<br />
    -f forks     number of forks to additionally spawn (default: 0)<br />
    -i file      data to send to the port (default: none)<br />
    -n connects  maximum number of connects (default: unlimited)<br />
    -N delay     delay between connects in ms (default: 0)<br />
    -c           close after connect (and sending data, if used with -i)<br />
                 use twice to shutdown SSL sessions hard (-S -c -c)<br />
    -C delay     delay before closing the port (for use with -c) (default: 0)<br />
    -d           dump data read from server<br />
    -D delay     delay before trying to read+dump data from server (default: 0)<br />
    -e           stop when no more connects possible (default: retry forever)<br />
    -k           no keep-alive after finnishing with connects, terminate!<br />
    -v           verbose mode<br />
    TARGET       target to flood attack (ip or dns)<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://altentee.com/2007/faking-it-udp-packets-that-is/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
