Re: TCL UDP Extension - need help with getting hex on the wire
- From: dkushner99@xxxxxxxxx
- Date: Tue, 03 Jul 2007 13:42:30 -0700
On Jul 3, 12:20 pm, Ron Fox <f...@xxxxxxxxxxxx> wrote:
uh.. I think if I did
puts $socket \
"0001001eac18501c00000100001400000001040000040000000004010004ac18cc64"
It would also be ascii on the wire..
What you should probably do is look at the Tcl [binary] command and
use [binary format] to create your packets.
dkushne...@xxxxxxxxx wrote:
I'm using the TCLUDPExtension to build an LDP simulation tool. I've
used TCLs TCP sockets quite a bit but needUDPfor this application as
well. I have a question.
When I send aUDPpacket using theUDPextension, I form a packet (in
hex) as I would using TCP sockets but the data is not sent the same as
it would be with the TCP sockets. With TCP sockets I just create the
packet in hex and send it and I get whet I want on the wire, but the
UDPextension seems to send ascii or something. In the decode below, I
see the packet in the right hand display, but I want to see the hex in
the left side of the decode display ... I think it's being translated
or something. Can someone please let me know how to format the packet
so that it ends up as hex on the wire?
This is what I send:
::ldpSimTool::sendUdp $srv
"0001001eac18501c00000100001400000001040000040000000004010004ac18cc64"
This is on the wire:
0000 01 00 5e 00 00 02 00 14 22 44 95 52 08 00 45 00 ..^.....
"D.R..E.
0010 00 62 68 41 00 00 01 11 75 13 ac 18 50 1c e0 00 .bhA....
u...P...
0020 00 02 02 86 02 86 00 4e e1 02 30 78 30 30 30 31 .......N ..
0x0001
0030 30 30 31 65 61 63 31 38 35 30 31 63 30 30 30 30 001eac18
501c0000
0040 30 31 30 30 30 30 31 34 30 30 30 30 30 30 30 31 01000014
00000001
0050 30 34 30 30 30 30 30 34 30 30 30 30 30 30 30 30 04000004
00000000
0060 30 34 30 31 30 30 30 34 61 63 31 38 63 63 36 34 04010004
ac18cc64
The problem is that I don't want any translation ... I want to see the
hex not ascii on the wire.- Hide quoted text -
- Show quoted text -
Yes, the formatting works (see below) ... but now I have another
problem. Now, I get an extra byte on the end of the packet - it looks
like padding but I'm not sure why:
NEW PROBLEM:
I sent this:
% ::ldpSimTool::sendUdp $srv
0001001eac18501c00000100001400000001040000040000000004010004ac18cc64
TX: Sending UDP packet
"0001001eac18501c00000100001400000001040000040000000004010004ac18cc64" ...
And this went out on the wire (extra byte "00" on the wire:
RX-DEBUG:
0001001eac18501c00000100001400000001040000040000000004010004ac18cc6400
RX 172.24.80.28 646: 70
{0001001eac18501c00000100001400000001040000040000000004010004ac18cc6400}
FIXES FORMATTING ISSUE:
proc udpEventHandler {sock} {
set pkt [read $sock]
puts "RX-DEBUG: $pkt"
binary scan $pkt "H*" datapacket
puts "RX-DEBUG: $datapacket"
set peer [fconfigure $sock -peer]
puts "RX $peer: [string length $datapacket] {$datapacket}"
decodePdu $datapacket RX
return
}
proc udpStart { } {
global srv
set allrtrsThisSbnt "224.0.0.2" ;# All routers multicast
addr.
set ldpPort "646" ;# LDP UDP port
set srv [udp_open $ldpPort]
fconfigure $srv -buffering none -translation binary -blocking 0
fconfigure $srv -mcastadd $allrtrsThisSbnt -remote [list
$allrtrsThisSbnt $ldpPort]
fileevent $srv readable [list ::ldpSimTool::udpEventHandler
$srv]
puts "Listening on udp port: [fconfigure $srv -myport]"
return $srv
}
proc sendUdp { handle datapacket } {
## Plain Hex in, format for Sending
set formattedDatapacket [binary format H*H* $datapacket 0]
puts "TX: Sending UDP packet \"$datapacket\" ..."
decodePdu $datapacket TX
puts -nonewline $handle "$formattedDatapacket"
}
.
- Follow-Ups:
- Re: TCL UDP Extension - need help with getting hex on the wire
- From: dkushner99
- Re: TCL UDP Extension - need help with getting hex on the wire
- References:
- TCL UDP Extension - need help with getting hex on the wire
- From: dkushner99
- Re: TCL UDP Extension - need help with getting hex on the wire
- From: Ron Fox
- TCL UDP Extension - need help with getting hex on the wire
- Prev by Date: Tcl-URL! - weekly Tcl news and links (Jul 3)
- Next by Date: Re: TCL UDP Extension - need help with getting hex on the wire
- Previous by thread: Re: TCL UDP Extension - need help with getting hex on the wire
- Next by thread: Re: TCL UDP Extension - need help with getting hex on the wire
- Index(es):
Relevant Pages
|