http://qs1969.pair.com?node_id=1044434

bh_perl has asked for the wisdom of the Perl Monks concerning the following question:


hi...

I want to collect data from the legacy switch to our server. My server will connect to cisco router using XOT protocol and the cisco will connect to legacy swicth using X.25 protocol.

I have trace the data packet using nettl command and the trace message as below:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ARPA/9000 NETWORKING^^^^^^^^^^^^^^^^^^^^ +^^^^^^@#% Timestamp : Fri Jul 12 PST 2013 15:30:40.370025 Process ID : [ICS] Subsystem : NS_LS_T +CP User ID ( UID ) : -1 Trace Kind : PDU IN +TRACE Device ID : -1 Path ID : 0 Connection ID : 0 Location : 00123 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~ -------------------------------- TCP Header -------------------------- +-------- sport: 1998 --> dport: 61236 flags: PUSH ACK seq: 0xfd2fed0a urp: 0x0 chksum: 0xe16a data len: 519 ack: 0x2f975faf win: 0x1ed9 optlen: 0 -------------------------------- XOT --------------------------------- +-------- 0: 00 00 02 03 10 01 22 33 20 20 20 20 20 20 20 20 ......"3 + 16: 4a 42 48 42 30 30 32 39 30 30 30 30 30 30 32 30 JBHB00290000002 +0 32: 30 31 30 30 30 30 30 30 30 30 30 30 33 33 31 36 010000000000331 +6 48: 37 36 34 34 31 20 20 20 20 20 20 20 20 20 20 20 76441 + 64: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 + < printing suppressed for one or more repetitions of the previous lin +e > 112: 20 20 20 20 20 20 20 20 20 20 30 32 30 37 32 37 02072 +7 128: 36 33 35 30 37 20 30 32 20 20 20 20 20 20 20 20 63507 02 + 144: 20 20 20 20 20 20 31 33 30 37 31 32 31 34 34 33 130712144 +3 160: 33 32 30 30 30 31 31 30 20 20 20 20 20 20 20 20 32000110 + 176: 4a 42 48 42 30 30 30 34 30 30 30 30 30 30 33 30 JBHB00040000003 +0 192: 30 31 30 30 30 30 30 30 30 30 30 38 39 36 33 32 010000000008963 +2 208: 30 30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 00 + 224: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 + < printing suppressed for one or more repetitions of the previous lin +e > 272: 20 20 20 20 20 20 20 20 20 20 30 32 30 37 32 37 02072 +7 288: 36 33 38 30 30 20 30 32 20 20 20 20 20 20 20 20 63800 02 + 304: 20 20 20 20 20 20 31 33 30 37 31 32 31 34 34 34 130712144 +4 320: 31 31 30 30 30 30 33 33 20 20 20 20 20 20 20 20 11000033 + 336: 4a 42 48 42 30 30 31 34 30 30 30 30 30 30 32 30 JBHB00140000002 +0 352: 30 39 30 30 30 30 30 30 30 30 30 35 32 30 37 34 090000000005207 +4 368: 34 35 20 20 20 20 20 20 20 20 20 20 20 20 20 20 45 + 384: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 + < printing suppressed for one or more repetitions of the previous lin +e > 432: 20 20 20 20 20 20 20 20 20 20 39 39 00 00 00 00 99... +. 448: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ............... +. < printing suppressed for one or more repetitions of the previous lin +e > 512: 00 00 00 00 00 00 00 -- -- -- -- -- -- -- -- -- ............... +. vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvARPA/9000 NETWORKINGvvvvvvvvvvvvvvvvvvvv +vvvvvv@#% Timestamp : Fri Jul 12 PST 2013 15:30:40.370127 Process ID : 2095611 Subsystem : NS_LS_T +CP User ID ( UID ) : 111 Trace Kind : PDU OUT + TRACE Device ID : -1 Path ID : 0 Connection ID : 0 Location : 00123 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~ -------------------------------- TCP Header -------------------------- +-------- sport: 61236 --> dport: 1998 flags: PUSH ACK seq: 0x2f975faf urp: 0x0 chksum: 0x1b data len: 7 ack: 0xfd2fef11 win: 0x8000 optlen: 0 -------------------------------- XOT --------------------------------- +-------- 0: 00 00 00 03 10 01 41 -- -- -- -- -- -- -- -- -- ......A........ +.

Based on the trace packet, my server will connect to the cisco router from port 1998 to port 61236 on the cisco. Then the cisco acknowledge our server using the same port.

My question is how could i sent data from my server to the cisco using port 1998 to port 61236 and how could i get the data sent by cisco router from port 61236 to my server on port 1998?. Please i really need your help..

This is my sample program:
#!/usr/bin/perl use strict; use warnings; use IO::Socket::INET; use MIME::Base64; my ($size); my $host = shift || "19.25.15.22"; my $port = shift || 1998; my $dir = "/acecdev/nv2am/bh"; my $data = `cat $dir/cdr-data.dat |sed 's/ //g'`; my $binary = pack ("H*", $data); print "DATA : $data\n"; print "ASCII: $binary\n"; # auto-flush on socket $| = 1; # create a connecting socket my $socket = new IO::Socket::INET ( PeerHost => $host, PeerPort => $port, Proto => 'tcp', ); die "cannot connect to the server $!\n" unless $socket; print "Connected to server [$host] with port $port\n"; # data to send to a server if ($socket->send($binary)) { $size = $socket->send($binary); print "Sent binary data as request to $host [length $size]\n"; } else { print "message not sent\n"; } # notify server that request has been sent shutdown($socket, 1); # read the message sent by server. #my $serverdata = <$socket>; #print "Message from Server : $serverdata \n"; # Send some message to server. #my $clientdata = "This is the Client speaking :)"; #print $socket "$clientdata \n"; # receive a response of up to 1024 characters from server my $response = ""; $ socket->recv($response, 1024); print "received response: $response\n"; $socket->close();

This is the output after i run the program
DATA : 4A4248423030303430303030303033303031303030303030303030383936333 +230302020202020202020202020202020202020202020202020202020202020202020 +202020202020202020202020202020202020202020202020202020202020202020202 +020202020203032303732373633383030203032202020202020202020202020202031 +333037313231343434313130303030333320202020202020204A42484230303134303 +030303030323030393030303030303030303532303734343520202020202020202020 +202020202020202020202020202020202020202020202020202020202020202020202 +020202020202020202020202020202020202020202020202020202039390000000000 +000000000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000000000 +00 ASCII: JBHB000400000030010000000008963200 + 02072763800 02 + 130712144411000033 JBHB001400000020090000000005207445 + 99 Connected to server [19.25.15.22] with port 1998 Sent binary data as request to 19.25.15.22 [length 344] Message from Server :

Replies are listed 'Best First'.
Re: How to communicate between port for socket programming
by golux (Chaplain) on Jul 15, 2013 at 23:17 UTC
    Hi bh_perl,

    First, you've already asked the same question here. We've asked you some questions in return that you still haven't answered, such as ...

    1. Do you have access to the server-side code?
    2. Have you tried logging to a local file to see what's happening on the server side?
    3. What happens when you check the return value from the call to recv?
    4. What happens when you inspect $? after calling recv?
    5. How did you obtain the data trace packet? (This from zork42)

    It doesn't help to repost your question. Besides which, the code you posted is not the code you ran, because these lines are commented out:

    # read the message sent by server. #my $serverdata = <$socket>; #print "Message from Server : $serverdata \n";

    and yet your output (impossibly) contains:

    Message from Server :

    I would suggest you go back to your previous node and think about the suggestions and questions we've already posed.

    And please make sure that your output is from the same code posted, otherwise it will make it hard for us to help you.

    say  substr+lc crypt(qw $i3 SI$),4,5