Tuesday, 27 August 2013

Cannot get mt process output

Cannot get mt process output

I try to get mt my Tshark process output, the executed command return one
by one the packets that has checksum error:
protected string[] invokeProcess(WiresharkProcesses process, string args)
{
try
{
switch (process)
{
case WiresharkProcesses.Capinfo:
processToInvoke = Path.Combine(getbBasePath, "capinfos.exe");
break;
case WiresharkProcesses.Editcap:
processToInvoke = Path.Combine(getbBasePath, "editcap.exe");
break;
case WiresharkProcesses.Tshark:
processToInvoke = Path.Combine(getbBasePath, "tshark.exe");
break;
case WiresharkProcesses.Wireshark:
processToInvoke = Path.Combine(getbBasePath,
"wireshark.exe");
break;
}
ProcessStartInfo capinfosProcess = new
ProcessStartInfo(processToInvoke);
capinfosProcess.Arguments = args;
capinfosProcess.WindowStyle = ProcessWindowStyle.Hidden;
capinfosProcess.RedirectStandardOutput = true;
capinfosProcess.RedirectStandardInput = true;
capinfosProcess.RedirectStandardError = true;
capinfosProcess.CreateNoWindow = true;
capinfosProcess.UseShellExecute = false;
capinfosProcess.ErrorDialog = false;
List<string> lineList = new List<string>();
using (Process pros = Process.Start(capinfosProcess))
{
pros.ErrorDataReceived += pros_ErrorDataReceived;
pros.OutputDataReceived += pros_OutputDataReceived;
pros.EnableRaisingEvents = true;
pros.BeginOutputReadLine();
pros.BeginErrorReadLine();
StreamReader reader = pros.StandardOutput;
while (!reader.EndOfStream)
{
lineList.Add(reader.ReadLine());
}
pros.WaitForExit();
}
return lineList.ToArray();
}
catch (Exception)
{
return null;
}
}
my problem is that my output is empty but when i am run the same command
using command line i can see my output for example this is the output for
1 packet with checksum error:
Frame 1: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)
Encapsulation type: Ethernet (1)
Arrival Time: Aug 26, 2013 11:41:51.779691000 Jerusalem Daylight Time
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1377506511.779691000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 74 bytes (592 bits)
Capture Length: 74 bytes (592 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: eth:ip:udp:dns]
Ethernet II, Src: Vmware_96:2c:da (00:50:56:96:2c:da), Dst:
Vmware_b1:6b:03 (00:50:56:b1:6b:03)
Destination: Vmware_b1:6b:03 (00:50:56:b1:6b:03)
Address: Vmware_b1:6b:03 (00:50:56:b1:6b:03)
.... ..0. .... .... .... .... = LG bit: Globally unique address
(factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Source: Vmware_96:2c:da (00:50:56:96:2c:da)
Address: Vmware_96:2c:da (00:50:56:96:2c:da)
.... ..0. .... .... .... .... = LG bit: Globally unique address
(factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Type: IP (0x0800)
Internet Protocol Version 4, Src: 192.0.16.6 (192.0.16.6), Dst:
192.0.16.200 (192.0.16.200)
Version: 4
Header length: 20 bytes
Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00:
Not-ECT (Not ECN-Capable Transport))
0000 00.. = Differentiated Services Codepoint: Default (0x00)
.... ..00 = Explicit Congestion Notification: Not-ECT (Not
ECN-Capable Transport) (0x00)
Total Length: 60
Identification: 0x0162 (354)
Flags: 0x00
0... .... = Reserved bit: Not set
.0.. .... = Don't fragment: Not set
..0. .... = More fragments: Not set
Fragment offset: 0
Time to live: 128
Protocol: UDP (17)
Header checksum: 0x0000 [incorrect, should be 0x9880 (may be caused by
"IP checksum offload"?)]
[Good: False]
[Bad: True]
[Expert Info (Error/Checksum): Bad checksum]
[Message: Bad checksum]
[Severity level: Error]
[Group: Checksum]
Source: 192.0.16.6 (192.0.16.6)
Destination: 192.0.16.200 (192.0.16.200)
[Source GeoIP: Unknown]
[Destination GeoIP: Unknown]
User Datagram Protocol, Src Port: 65512 (65512), Dst Port: domain (53)
Source port: 65512 (65512)
Destination port: domain (53)
Length: 40
Checksum: 0xa108 [validation disabled]
[Good Checksum: False]
[Bad Checksum: False]
Domain Name System (query)
Transaction ID: 0xe471
Flags: 0x0100 Standard query
0... .... .... .... = Response: Message is a query
.000 0... .... .... = Opcode: Standard query (0)
.... ..0. .... .... = Truncated: Message is not truncated
.... ...1 .... .... = Recursion desired: Do query recursively
.... .... .0.. .... = Z: reserved (0)
.... .... ...0 .... = Non-authenticated data: Unacceptable
Questions: 1
Answer RRs: 0
Authority RRs: 0
Additional RRs: 0
Queries
mail.yandex.ru: type A, class IN
Name: mail.yandex.ru
Type: A (Host address)
Class: IN (0x0001)

No comments:

Post a Comment