Pages

Showing posts with label network. Show all posts
Showing posts with label network. Show all posts

1/02/2019

Capture on Windows Server without any Wireshark or other install




Netsh trace start capture=yes tracefile=c:\temp\trace.etl 
Netsh trace stop
 .\etl-to-pcap.ps1 -Path c:\temp\trace.etl -Destination c:\temp\trace.pcap



etl-to-pcap.ps1
[CmdletBinding()]

param(
[Parameter(Position=0)]
[ValidateScript({
    if( -Not ($_ | Test-Path) ){
        throw "File or folder $_ does not exist"
    }

    if($_.Extension -ne ".etl"){
        throw "Source file must be .etl file"
    }
    return $true
})]
[System.IO.FileInfo]$Path,

[Parameter(Position=1)]
[ValidateScript({
    if( -Not ($path.DirectoryName | Test-Path) ){
        throw "File or folder does not exist"
    }

    if($_.Extension -ne ".pcap") {
        throw "Estination file must be .pcap file"
    }
    return $true
})]
[System.IO.FileInfo]$Destination,

[Parameter(Position=2)]
[Uint32]$MaxPacketSizeBytes = 65536)


$csharp_code = @'
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace chentiangemalc
{
    public static class NetworkRoutines
    {
    public static long ConvertEtlToPcap(string source, string destination, UInt32 maxPacketSize)
        {
            int result = 0;
            using (BinaryWriter writer = new BinaryWriter(File.Open(destination, FileMode.Create)))
            {

                UInt32 magic_number = 0xa1b2c3d4;
                UInt16 version_major = 2;
                UInt16 version_minor = 4;
                Int32 thiszone = 0;
                UInt32 sigfigs = 0;
                UInt32 snaplen = maxPacketSize;
                UInt32 network = 1; // LINKTYPE_ETHERNET

                writer.Write(magic_number);
                writer.Write(version_major);
                writer.Write(version_minor);
                writer.Write(thiszone);
                writer.Write(sigfigs);
                writer.Write(snaplen);
                writer.Write(network);

                long c = 0;
                long t = 0;
                using (var reader = new EventLogReader(source, PathType.FilePath))
                {
                    EventRecord record;
                    while ((record = reader.ReadEvent()) != null)
                    {
                        c++;
                        t++;
                        if (c == 10000)
                        {
                            Console.WriteLine(String.Format("Processed {0} events with {1} packets processed",t,result));
                            c = 0;
                        }
                        using (record)
                        {
                            if (record.ProviderName == "Microsoft-Windows-NDIS-PacketCapture")
                            {
                                result++;
                                DateTime timeCreated = (DateTime)record.TimeCreated;
                                UInt32 ts_sec = (UInt32)((timeCreated.Subtract(new DateTime(1970, 1, 1))).TotalSeconds);
                                UInt32 ts_usec = (UInt32)(((timeCreated.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds) - ((UInt32)((timeCreated.Subtract(new DateTime(1970, 1, 1))).TotalSeconds * 1000))) * 1000;
                                UInt32 incl_len = (UInt32)record.Properties[2].Value;
                                if (incl_len > maxPacketSize)
                                {
                                   Console.WriteLine(String.Format("Packet size of {0} exceeded max packet size {1}, packet ignored",incl_len,maxPacketSize));
                                }
                                UInt32 orig_len = incl_len;

                                writer.Write(ts_sec);
                                writer.Write(ts_usec);
                                writer.Write(incl_len);
                                writer.Write(orig_len);
                                writer.Write((byte[])record.Properties[3].Value);

                            }
                        }
                    }
                }
            }
            return result;
        }
    }
}
'@

Add-Type -Type $csharp_code

$result = [chentiangemalc.NetworkRoutines]::ConvertEtlToPcap($Path.FullName,$Destination.FullName,$MaxPacketSizeBytes)

Write-Host "$result packets converted."





4/21/2016

Cisco Nexus: EthAnalyzer

I've been fighting with getting EthAnalyzer trying to get it to do something useful.  But it always only showed me traffic to/from the switch itself, not packets that pass through it. 
Today I found the following information and EUREKA!
ethanalyzer data plane traffic analysis



ACLs and Ethanalyzer for Data Plane Sampling:
The Ethanalyzer captures only traffic on CPU, so seems as unsuitable solution for the data plane traffic analysis. However, this limitation can be avoided with a use of ACL logging to sample specific packets from data plane.
              .   .   .
When we use ACLs and the “log” keyword, access control entries (ACEs) with log keyword cause system to punt a copy of matching packets to supervisor CPU. Key point is that original traffic forwarded or dropped in hardware with no performance penalty. Note that punted copies subjected to hardware rate limiter, forwarding engine hardware enforces rate to avoid saturating inband interface/CPU.

So the following accomplished what I have been trying to do for a long time:
IP access list acl-cap

  10 permit ip 10.10.10.11/32 any log

  20 permit ip any any
Eth6/28
  ip port access-group acl-cap in

ethanalyzer local int inband limit-captured-frames 0 autostop duration 60 write bootflash:test-2.pcap




8/21/2014

NETMON CMD LINE

Run Windows Network Monitor from CMD

I had a confusing problem with Network Monitor 3.4. When I opened it, I got a warning about parsers not loading. Then the capture would not start saying the capture filter was invalid. Eventually I tried it from the command prompt and it worked.
NMCap /network * /capture /file output.cap:50M

4/14/2014

Link: DMVPN Explained

Link: DMVPN Explained

The following is a great blog post about how mGRE tunnels work and DMVPN: DMVPN Explained
As a PDF: DMVPN-Explained.PDF

2/06/2014

Wireshark Troubleshooting

Wireshark Troubleshooting Videos

There is a lot of great stuff on YouTube. By the way I find it is even more excellent to watch YouTube with my Roku. But I digress. There are a lot of Laura Chappell videos about network troubleshooting with Wireshark. Much of it is in the Laura's Lab Kit distribution at: http://llk11-2014.s3.amazonaws.com/lauraslabkit11b.zip Here is one example of a great video that demonstrates Wireshark features for troubleshooting: https://www.youtube.com/watch?v=70dRbN4Y2no&feature=player_embedded&list=UUfdeux1c9erKgFAwSpTlICA Links to others and my notes from each are available in this document: Wireshark Notes

Cisco Daisy Chained Consoles

Cisco Daisy Chain Console

Daisy Chaining from one device to another can be a great backup method to access network devices without having to have a modem (or more than one.) So, if I want to be able to get to the console on a core switch at a site after having a local contact boot it up, I could enable this by connecting a cisco rollover cable from my router to the switch. This would allow me to connect to the router over the WAN side interface and then connect to the switch from the router.

Cable to buy

Need a “rollover cable.” This is the product:
Rollover Cable
http://www.cdw.com/shop/products/StarTech.com-Cisco-Console-Rollover-Cable-RJ45-Ethernet-network-cable/2437620.aspx

Setup

  • connect rollover cable from router AUX port to Core Switch CONSOLE port
  • Config on Router:
    • line aux 0
    • transport input telnet ssh

How to use

  • Connect to router and logon
  • telnet [ROUTER IP] 2001
  • Logon
  • To exit and return to router session, type CTRL+SHIFT+6 and then hit X

12/20/2013

9/10/2013

STP loops strike again

STP loops strike again
this is a very interesting post about a L2 loop experience.  The "best practice" I've always been told, isn't enough.
And an interesting solution:
use switchport port-security and limit the number of MAC addresses accepted on the switch port.

6/21/2011

Tweaking Windows 7 / Vista TCP/IP settings

SpeedGuide.net :: Windows 7, Vista, 2008 Tweaks: "Tweaking Windows 7 / Vista TCP/IP settings"
Disable Windows Scaling heuristics

Windows Vista/7 has the ability to automatically change its own TCP Window auto-tuning behavior to a more conservative state regardless of any user settings. It is possible for Windows to override the autotuninlevel even after an user sets their custom TCP auto-tuning level. When that behavior occurs, the "netsh int tcp show global" command displays the following message:


** The above autotuninglevel setting is the result of Windows Scaling heuristics
overriding any local/policy configuration on at least one profile.

To prevent that behavior and enforce any user-set TCP Window auto-tunning level, you should execute the following command:


netsh int tcp set heuristics disabled

possible settings are: disabled,enabled,default (sets to the Windows default state)
recommended: disabled (to retain user-set auto-tuning level)

Note this should be executed in elevated command prompt (with admin priviledges) before setting the autotuninlevel in next section. If the command is accepted by the OS you will see an "Ok." on a new line.

The corresponding Registry value (not necessary to edit if setting via netsh) is located in:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters
EnableWsd=0   (default: 1, recommended: 0)


TCP Auto-Tuning

To turn off the default RWIN auto tuning behavior, (in elevated command prompt) type:

netsh int tcp set global autotuninglevel=disabled

The default auto-tuning level is "normal", and the possible settings for the above command are:

disabled: uses a fixed value for the tcp receive window. Limits it to 64KB (limited at 65535).
highlyrestricted: allows the receive window to grow beyond its default value, very conservatively
restricted: somewhat restricted growth of the tcp receive window beyond its default value
normal: default value, allows the receive window to grow to accommodate most conditions
experimental: allows the receive window to grow to accommodate extreme scenarios (not recommended, it can degrade performance in common scenarios, only intended for research purposes. It enables RWIN values of over 16 MB)

Our recommendation: normal (unless you're experiencing problems).

If you're experiencing problems with your NAT router or SPI firewall, try the "restricted", "highlyrestricted", or even "disabled" state.

Notes:
- Reportedly, some older residential NAT routers with a SPI firewall may have problems with enabled tcp auto-tuning in it's "normal" state, resulting in slow speeds, packet loss, reduced network performance in general.
- auto-tuning also causes problems with really old routers that do not support TCP Windows scaling. See MSKB 935400
- netsh set commands take effect immediately after executing, there is no need to reboot.
- sometimes when using "normal" mode and long lasting connections (p2p software / torrents), tcp windows can get very large and consume too much resources, if you're experiencing problems try a more conservative (restricted) setting.

Disable TCP autotuning

How to disable the TCP autotuning diagnostic tool: "How to disable the TCP autotuning diagnostic tool"

10/22/2009

Good article: Storms RIP the Net

This is an informative recounting by Laura Chappel of the investigation and repair of network traffic issue crippling a network. Nothing could stay connected even long enough to do a "normal" packet capture.
She had them setup a quick packet capture outside the GUI to allow for getting on and getting the capture before being bumped off.

tshark -c 100 -w gen1.pcap


The -c parameter indicates the number of packets to capture. The -w parameter is
used to define the name of the trace file to create.

Looking at the 100 packets the fact that the IP Identification field matched for every packet indicated that this was a looping condition rather than some kind of denial of service from a single host.

A switch loop is easy to create and often hard to troubleshoot, unless you are looking for this exact condition. And often the opportunity to create a loop is made available to the masses with proliferation of workgroup switches to avoid spending a couple hundred bucks on having another jack installed. ("Gee, here's an end of a cable coming out of a big tangle under my desk. It must need plugged in...")

Separating broadcast domains into several VLAN's, like one per floor or some other logical separation, can limit the scope of a problem due to a switch loop. At least only one VLAN will be down and you have a narrower search area for the loop -- check the log on one or two switches instead of 20-30.

10/30/2007

Network Latency



Latency due to distance = approximately 1ms per 100km

from: http://www.nessoft.com/kb/42

There are two *normal* factors that significantly influence latency
  • The latency of the connecting device. For a cable modem, this can normally be between 5 and 40 ms. For a DSL modem this is normally 10 to 70ms. For a dial-up modem, this is normally anywhere from 100 to 220ms. For a cellular link, this can be from 200 to 600 ms. For a T1, this is normally 0 to 10 ms.

  • The distance the data is traveling. Data travels at (very roughly) 120,000 miles (or 192,000 kilometers) per second, or 120 miles (192 km) per ms (millisecond) over a network connection. With traceroute, we have to send the data there and back again, so the latency will raise roughly 1ms for every 60 miles (96km, although with the level of accuracy we're using here, we should say "100km") of distance between you and the target.

7/01/2005

Network::Cisco::IOS


I often want to look at how ports are configured on a switch, the descr, what vlan, etc.
"show run | include" type commands don't really help because the port config is on multiple lines.

The following are very useful, if only I could remember them:

show int status
show int summary